From b9aad3310eea3458e8ebd5f9ccd63b2133637231 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 17 May 2018 17:09:55 -0400 Subject: [PATCH] PowerPC: Move MMU-specifics from PowerPC.h to MMU.h PowerPC.h at this point is pretty much a general glob of stuff, and it's unfortunate, since it means pulling in a lot of unrelated header dependencies and a bunch of other things that don't need to be seen by things that just want to read memory. Breaking this out into its own header keeps all the MMU-related stuff together and also limits the amount of header dependencies being included (the primary motivation for this being the former reason). --- Source/Core/Core/ActionReplay.cpp | 2 +- Source/Core/Core/Boot/Boot_BS2Emu.cpp | 1 + Source/Core/Core/Core.vcxproj | 1 + Source/Core/Core/Core.vcxproj.filters | 3 + .../Core/Core/Debugger/Debugger_SymbolMap.cpp | 2 +- .../Core/Core/Debugger/PPCDebugInterface.cpp | 1 + Source/Core/Core/Debugger/RSO.cpp | 2 +- Source/Core/Core/FifoPlayer/FifoPlayer.cpp | 1 + Source/Core/Core/GeckoCode.cpp | 3 +- Source/Core/Core/HLE/HLE_Misc.cpp | 3 +- Source/Core/Core/HLE/HLE_OS.cpp | 1 + Source/Core/Core/HLE/HLE_VarArgs.h | 2 +- Source/Core/Core/HW/Memmap.h | 2 +- Source/Core/Core/PatchEngine.cpp | 1 + Source/Core/Core/PowerPC/BreakPoints.cpp | 2 +- .../Core/PowerPC/Interpreter/Interpreter.cpp | 1 + .../Interpreter/Interpreter_Branch.cpp | 1 + .../Interpreter/Interpreter_LoadStore.cpp | 1 + .../Interpreter_LoadStorePaired.cpp | 1 + .../Interpreter_SystemRegisters.cpp | 1 + Source/Core/Core/PowerPC/Jit64/Jit.cpp | 1 + .../Core/PowerPC/Jit64Common/EmuCodeBlock.cpp | 2 + .../PowerPC/JitArm64/JitArm64_BackPatch.cpp | 1 + .../PowerPC/JitArm64/JitArm64_LoadStore.cpp | 1 + .../JitArm64/JitArm64_LoadStoreFloating.cpp | 1 + Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp | 1 + .../Core/Core/PowerPC/JitCommon/JitCache.cpp | 1 + Source/Core/Core/PowerPC/JitInterface.cpp | 1 + Source/Core/Core/PowerPC/MMU.cpp | 3 +- Source/Core/Core/PowerPC/MMU.h | 121 ++++++++++++++++++ Source/Core/Core/PowerPC/PPCAnalyst.cpp | 1 + Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 2 +- Source/Core/Core/PowerPC/PowerPC.cpp | 2 +- Source/Core/Core/PowerPC/PowerPC.h | 106 --------------- .../PowerPC/SignatureDB/MEGASignatureDB.cpp | 2 +- .../Core/PowerPC/SignatureDB/SignatureDB.cpp | 2 +- Source/Core/DolphinQt2/CheatsManager.cpp | 1 + .../DolphinQt2/Debugger/CodeViewWidget.cpp | 1 + .../Core/DolphinQt2/Debugger/CodeWidget.cpp | 1 + .../DolphinQt2/Debugger/MemoryViewWidget.cpp | 3 + .../Core/DolphinQt2/Debugger/WatchWidget.cpp | 1 + Source/Core/DolphinQt2/MenuBar.cpp | 2 +- Source/Core/DolphinWX/Debugger/CodeView.cpp | 2 +- Source/Core/DolphinWX/Debugger/CodeWindow.cpp | 1 + Source/Core/DolphinWX/Debugger/MemoryView.cpp | 2 +- Source/Core/DolphinWX/Debugger/WatchView.cpp | 7 +- 46 files changed, 175 insertions(+), 126 deletions(-) create mode 100644 Source/Core/Core/PowerPC/MMU.h diff --git a/Source/Core/Core/ActionReplay.cpp b/Source/Core/Core/ActionReplay.cpp index 6055a7057c..02e70cc5cc 100644 --- a/Source/Core/Core/ActionReplay.cpp +++ b/Source/Core/Core/ActionReplay.cpp @@ -39,7 +39,7 @@ #include "Core/ARDecrypt.h" #include "Core/ConfigManager.h" -#include "Core/PowerPC/PowerPC.h" +#include "Core/PowerPC/MMU.h" namespace ActionReplay { diff --git a/Source/Core/Core/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Boot/Boot_BS2Emu.cpp index 1a3b4bfe28..3ff0a86e25 100644 --- a/Source/Core/Core/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Boot/Boot_BS2Emu.cpp @@ -26,6 +26,7 @@ #include "Core/IOS/FS/FileSystem.h" #include "Core/IOS/IOS.h" #include "Core/IOS/Uids.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" #include "DiscIO/Enums.h" diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index ad815d88a4..c7f1f31247 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -524,6 +524,7 @@ + diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index a16e67b8e1..6c20122943 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -1305,6 +1305,9 @@ PowerPC + + PowerPC + PowerPC diff --git a/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp b/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp index 5099adb176..46cb8cd89c 100644 --- a/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp +++ b/Source/Core/Core/Debugger/Debugger_SymbolMap.cpp @@ -12,7 +12,7 @@ #include "Common/StringUtil.h" #include "Core/Core.h" -#include "Core/HW/Memmap.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index a984b8c30b..b931307502 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -12,6 +12,7 @@ #include "Core/Core.h" #include "Core/HW/DSP.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/Core/Debugger/RSO.cpp b/Source/Core/Core/Debugger/RSO.cpp index 52cdaa0a9d..a2df397be2 100644 --- a/Source/Core/Core/Debugger/RSO.cpp +++ b/Source/Core/Core/Debugger/RSO.cpp @@ -12,8 +12,8 @@ #include "Common/CommonFuncs.h" #include "Common/Logging/Log.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" -#include "Core/PowerPC/PowerPC.h" void RSOHeaderView::Load(u32 address) { diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index e0c49d26b2..fc2ce96808 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -22,6 +22,7 @@ #include "Core/HW/SystemTimers.h" #include "Core/HW/VideoInterface.h" #include "Core/Host.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/CommandProcessor.h" diff --git a/Source/Core/Core/GeckoCode.cpp b/Source/Core/Core/GeckoCode.cpp index c66d779156..512767eb7c 100644 --- a/Source/Core/Core/GeckoCode.cpp +++ b/Source/Core/Core/GeckoCode.cpp @@ -12,10 +12,11 @@ #include "Common/ChunkFile.h" #include "Common/CommonPaths.h" +#include "Common/CommonTypes.h" #include "Common/FileUtil.h" #include "Core/ConfigManager.h" -#include "Core/HW/Memmap.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" namespace Gecko diff --git a/Source/Core/Core/HLE/HLE_Misc.cpp b/Source/Core/Core/HLE/HLE_Misc.cpp index 9388b16a2c..bcbf36afa8 100644 --- a/Source/Core/Core/HLE/HLE_Misc.cpp +++ b/Source/Core/Core/HLE/HLE_Misc.cpp @@ -4,11 +4,12 @@ #include "Core/HLE/HLE_Misc.h" +#include "Common/Common.h" #include "Common/CommonTypes.h" -#include "Common/Logging/Log.h" #include "Core/GeckoCode.h" #include "Core/HW/CPU.h" #include "Core/Host.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" namespace HLE_Misc diff --git a/Source/Core/Core/HLE/HLE_OS.cpp b/Source/Core/Core/HLE/HLE_OS.cpp index f0b4bead98..8ea2071aaf 100644 --- a/Source/Core/Core/HLE/HLE_OS.cpp +++ b/Source/Core/Core/HLE/HLE_OS.cpp @@ -12,6 +12,7 @@ #include "Common/MsgHandler.h" #include "Common/StringUtil.h" #include "Core/HLE/HLE_VarArgs.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" namespace HLE_OS diff --git a/Source/Core/Core/HLE/HLE_VarArgs.h b/Source/Core/Core/HLE/HLE_VarArgs.h index c8bab8c8a0..45eee262ff 100644 --- a/Source/Core/Core/HLE/HLE_VarArgs.h +++ b/Source/Core/Core/HLE/HLE_VarArgs.h @@ -7,7 +7,7 @@ #include "Common/Align.h" #include "Common/CommonTypes.h" -#include "Core/HW/Memmap.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" #include diff --git a/Source/Core/Core/HW/Memmap.h b/Source/Core/Core/HW/Memmap.h index 329912f01f..d928f8c69f 100644 --- a/Source/Core/Core/HW/Memmap.h +++ b/Source/Core/Core/HW/Memmap.h @@ -10,7 +10,7 @@ #include "Common/CommonTypes.h" #include "Common/MathUtil.h" #include "Common/Swap.h" -#include "Core/PowerPC/PowerPC.h" +#include "Core/PowerPC/MMU.h" // Global declarations class PointerWrap; diff --git a/Source/Core/Core/PatchEngine.cpp b/Source/Core/Core/PatchEngine.cpp index f1ab5432bd..4e12701ffd 100644 --- a/Source/Core/Core/PatchEngine.cpp +++ b/Source/Core/Core/PatchEngine.cpp @@ -24,6 +24,7 @@ #include "Core/ConfigManager.h" #include "Core/GeckoCode.h" #include "Core/GeckoCodeConfig.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" namespace PatchEngine diff --git a/Source/Core/Core/PowerPC/BreakPoints.cpp b/Source/Core/Core/PowerPC/BreakPoints.cpp index 7e1071a04a..6be523537a 100644 --- a/Source/Core/Core/PowerPC/BreakPoints.cpp +++ b/Source/Core/Core/PowerPC/BreakPoints.cpp @@ -15,7 +15,7 @@ #include "Common/Logging/Log.h" #include "Core/Core.h" #include "Core/PowerPC/JitInterface.h" -#include "Core/PowerPC/PowerPC.h" +#include "Core/PowerPC/MMU.h" bool BreakPoints::IsAddressBreakPoint(u32 address) const { diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index f88936654f..4436d46fc2 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -20,6 +20,7 @@ #include "Core/HLE/HLE.h" #include "Core/HW/CPU.h" #include "Core/Host.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCTables.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp index 1cc5d3c9c4..a9bbbe7bf4 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp @@ -8,6 +8,7 @@ #include "Core/CoreTiming.h" #include "Core/HLE/HLE.h" #include "Core/PowerPC/Interpreter/Interpreter.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" void Interpreter::bx(UGeckoInstruction inst) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp index d790cd3b47..901d9feb00 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp @@ -12,6 +12,7 @@ #include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" #include "Core/PowerPC/JitInterface.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" bool Interpreter::m_reserve; diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp index b205ebd64f..02c0468a97 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp @@ -12,6 +12,7 @@ #include "Common/MathUtil.h" #include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" // dequantize table diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp index d3f1c8d3fa..2c060f42bb 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp @@ -13,6 +13,7 @@ #include "Core/HW/GPFifo.h" #include "Core/HW/SystemTimers.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" /* diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 9f45027415..65387f9d3d 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -32,6 +32,7 @@ #include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h" #include "Core/PowerPC/Jit64Common/TrampolineCache.h" #include "Core/PowerPC/JitInterface.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/Profiler.h" #if defined(_DEBUG) || defined(DEBUGFAST) diff --git a/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp b/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp index 7036fba0f6..e00f3ada1a 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp +++ b/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp @@ -11,11 +11,13 @@ #include "Common/CPUDetect.h" #include "Common/FloatUtils.h" #include "Common/Intrinsics.h" +#include "Common/Swap.h" #include "Core/HW/MMIO.h" #include "Core/HW/Memmap.h" #include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/Jit64Common/Jit64Base.h" #include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" using namespace Gen; diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_BackPatch.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_BackPatch.cpp index 8b6993eceb..ebfd207115 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_BackPatch.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_BackPatch.cpp @@ -15,6 +15,7 @@ #include "Core/HW/Memmap.h" #include "Core/PowerPC/JitArm64/Jit.h" #include "Core/PowerPC/JitArmCommon/BackPatch.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" using namespace Arm64Gen; diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp index 2311056ab6..827fadd07f 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp @@ -16,6 +16,7 @@ #include "Core/PowerPC/JitArm64/JitArm64_RegCache.h" #include "Core/PowerPC/JitArm64/Jit_Util.h" #include "Core/PowerPC/JitInterface.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCTables.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStoreFloating.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStoreFloating.cpp index 1c307e889f..78e7168f72 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStoreFloating.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStoreFloating.cpp @@ -12,6 +12,7 @@ #include "Core/CoreTiming.h" #include "Core/PowerPC/JitArm64/Jit.h" #include "Core/PowerPC/JitArm64/JitArm64_RegCache.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCTables.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp b/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp index 09342e5543..208d5b323f 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp @@ -12,6 +12,7 @@ #include "Core/PowerPC/JitArm64/Jit.h" #include "Core/PowerPC/JitCommon/JitAsmCommon.h" #include "Core/PowerPC/JitCommon/JitCache.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" using namespace Arm64Gen; diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index 4b1635b987..ffca236553 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -22,6 +22,7 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/PowerPC/JitCommon/JitBase.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/Core/PowerPC/JitInterface.cpp b/Source/Core/Core/PowerPC/JitInterface.cpp index ff6271aab9..3a6aa29979 100644 --- a/Source/Core/Core/PowerPC/JitInterface.cpp +++ b/Source/Core/Core/PowerPC/JitInterface.cpp @@ -25,6 +25,7 @@ #include "Core/PowerPC/CPUCoreBase.h" #include "Core/PowerPC/CachedInterpreter/CachedInterpreter.h" #include "Core/PowerPC/JitCommon/JitBase.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/Profiler.h" diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index 52f0eb07af..cd8ca73396 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -2,11 +2,12 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Core/PowerPC/MMU.h" + #include #include #include -#include "Common/Atomic.h" #include "Common/BitUtils.h" #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/PowerPC/MMU.h b/Source/Core/Core/PowerPC/MMU.h new file mode 100644 index 0000000000..f0f5ec506f --- /dev/null +++ b/Source/Core/Core/PowerPC/MMU.h @@ -0,0 +1,121 @@ +// Copyright 2018 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include + +#include "Common/CommonTypes.h" + +namespace PowerPC +{ +// Routines for debugger UI, cheats, etc. to access emulated memory from the +// perspective of the CPU. Not for use by core emulation routines. +// Use "Host_" prefix. +u8 HostRead_U8(u32 address); +u16 HostRead_U16(u32 address); +u32 HostRead_U32(u32 address); +u64 HostRead_U64(u32 address); +float HostRead_F32(u32 address); +double HostRead_F64(u32 address); +u32 HostRead_Instruction(u32 address); + +void HostWrite_U8(u8 var, u32 address); +void HostWrite_U16(u16 var, u32 address); +void HostWrite_U32(u32 var, u32 address); +void HostWrite_U64(u64 var, u32 address); +void HostWrite_F32(float var, u32 address); +void HostWrite_F64(double var, u32 address); + +std::string HostGetString(u32 address, size_t size = 0); + +// Returns whether a read or write to the given address will resolve to a RAM +// access given the current CPU state. +bool HostIsRAMAddress(u32 address); + +// Same as HostIsRAMAddress, but uses IBAT instead of DBAT. +bool HostIsInstructionRAMAddress(u32 address); + +// Routines for the CPU core to access memory. + +// Used by interpreter to read instructions, uses iCache +u32 Read_Opcode(u32 address); +struct TryReadInstResult +{ + bool valid; + bool from_bat; + u32 hex; + u32 physical_address; +}; +TryReadInstResult TryReadInstruction(u32 address); + +u8 Read_U8(u32 address); +u16 Read_U16(u32 address); +u32 Read_U32(u32 address); +u64 Read_U64(u32 address); + +// Useful helper functions, used by ARM JIT +float Read_F32(u32 address); +double Read_F64(u32 address); + +// used by JIT. Return zero-extended 32bit values +u32 Read_U8_ZX(u32 address); +u32 Read_U16_ZX(u32 address); + +void Write_U8(u8 var, u32 address); +void Write_U16(u16 var, u32 address); +void Write_U32(u32 var, u32 address); +void Write_U64(u64 var, u32 address); + +void Write_U16_Swap(u16 var, u32 address); +void Write_U32_Swap(u32 var, u32 address); +void Write_U64_Swap(u64 var, u32 address); + +// Useful helper functions, used by ARM JIT +void Write_F64(double var, u32 address); + +void DMA_LCToMemory(u32 mem_address, u32 cache_address, u32 num_blocks); +void DMA_MemoryToLC(u32 cache_address, u32 mem_address, u32 num_blocks); +void ClearCacheLine(u32 address); // Zeroes 32 bytes; address should be 32-byte-aligned + +// TLB functions +void SDRUpdated(); +void InvalidateTLBEntry(u32 address); +void DBATUpdated(); +void IBATUpdated(); + +// Result changes based on the BAT registers and MSR.DR. Returns whether +// it's safe to optimize a read or write to this address to an unguarded +// memory access. Does not consider page tables. +bool IsOptimizableRAMAddress(u32 address); +u32 IsOptimizableMMIOAccess(u32 address, u32 access_size); +bool IsOptimizableGatherPipeWrite(u32 address); + +struct TranslateResult +{ + bool valid; + bool from_bat; + u32 address; +}; +TranslateResult JitCache_TranslateAddress(u32 address); + +constexpr int BAT_INDEX_SHIFT = 17; +constexpr u32 BAT_PAGE_SIZE = 1 << BAT_INDEX_SHIFT; +constexpr u32 BAT_MAPPED_BIT = 0x1; +constexpr u32 BAT_PHYSICAL_BIT = 0x2; +constexpr u32 BAT_RESULT_MASK = UINT32_C(~0x3); +using BatTable = std::array; // 128 KB +extern BatTable ibat_table; +extern BatTable dbat_table; +inline bool TranslateBatAddess(const BatTable& bat_table, u32* address) +{ + u32 bat_result = bat_table[*address >> BAT_INDEX_SHIFT]; + if ((bat_result & BAT_MAPPED_BIT) == 0) + return false; + *address = (bat_result & BAT_RESULT_MASK) | (*address & (BAT_PAGE_SIZE - 1)); + return true; +} +} // namespace PowerPC diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index b59b54d26b..372ea5a279 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -15,6 +15,7 @@ #include "Common/Logging/Log.h" #include "Common/StringUtil.h" #include "Core/ConfigManager.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PPCTables.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index 28dfa121bd..1e9ffc093a 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -13,8 +13,8 @@ #include "Common/CommonTypes.h" #include "Common/File.h" #include "Common/Logging/Log.h" -#include "Common/MsgHandler.h" #include "Common/StringUtil.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/SignatureDB/SignatureDB.h" diff --git a/Source/Core/Core/PowerPC/PowerPC.cpp b/Source/Core/Core/PowerPC/PowerPC.cpp index a6fa8b31af..9ae77fe58b 100644 --- a/Source/Core/Core/PowerPC/PowerPC.cpp +++ b/Source/Core/Core/PowerPC/PowerPC.cpp @@ -17,12 +17,12 @@ #include "Core/ConfigManager.h" #include "Core/CoreTiming.h" #include "Core/HW/CPU.h" -#include "Core/HW/Memmap.h" #include "Core/HW/SystemTimers.h" #include "Core/Host.h" #include "Core/PowerPC/CPUCoreBase.h" #include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/JitInterface.h" +#include "Core/PowerPC/MMU.h" namespace PowerPC { diff --git a/Source/Core/Core/PowerPC/PowerPC.h b/Source/Core/Core/PowerPC/PowerPC.h index 76afbb5032..b55a150f2c 100644 --- a/Source/Core/Core/PowerPC/PowerPC.h +++ b/Source/Core/Core/PowerPC/PowerPC.h @@ -210,112 +210,6 @@ void UpdatePerformanceMonitor(u32 cycles, u32 num_load_stores, u32 num_fp_inst); #define riPS0(i) (*(u64*)(&PowerPC::ppcState.ps[i][0])) #define riPS1(i) (*(u64*)(&PowerPC::ppcState.ps[i][1])) -// Routines for debugger UI, cheats, etc. to access emulated memory from the -// perspective of the CPU. Not for use by core emulation routines. -// Use "Host_" prefix. -u8 HostRead_U8(u32 address); -u16 HostRead_U16(u32 address); -u32 HostRead_U32(u32 address); -u64 HostRead_U64(u32 address); -float HostRead_F32(u32 address); -double HostRead_F64(u32 address); -u32 HostRead_Instruction(u32 address); - -void HostWrite_U8(u8 var, u32 address); -void HostWrite_U16(u16 var, u32 address); -void HostWrite_U32(u32 var, u32 address); -void HostWrite_U64(u64 var, u32 address); -void HostWrite_F32(float var, u32 address); -void HostWrite_F64(double var, u32 address); - -// Returns whether a read or write to the given address will resolve to a RAM -// access given the current CPU state. -bool HostIsRAMAddress(u32 address); -// Same as HostIsRAMAddress, but uses IBAT instead of DBAT. -bool HostIsInstructionRAMAddress(u32 address); - -std::string HostGetString(u32 em_address, size_t size = 0); - -// Routines for the CPU core to access memory. - -// Used by interpreter to read instructions, uses iCache -u32 Read_Opcode(u32 address); -struct TryReadInstResult -{ - bool valid; - bool from_bat; - u32 hex; - u32 physical_address; -}; -TryReadInstResult TryReadInstruction(u32 address); - -u8 Read_U8(u32 address); -u16 Read_U16(u32 address); -u32 Read_U32(u32 address); -u64 Read_U64(u32 address); - -// Useful helper functions, used by ARM JIT -float Read_F32(u32 address); -double Read_F64(u32 address); - -// used by JIT. Return zero-extended 32bit values -u32 Read_U8_ZX(u32 address); -u32 Read_U16_ZX(u32 address); - -void Write_U8(u8 var, u32 address); -void Write_U16(u16 var, u32 address); -void Write_U32(u32 var, u32 address); -void Write_U64(u64 var, u32 address); - -void Write_U16_Swap(u16 var, u32 address); -void Write_U32_Swap(u32 var, u32 address); -void Write_U64_Swap(u64 var, u32 address); - -// Useful helper functions, used by ARM JIT -void Write_F64(double var, u32 address); - -void DMA_LCToMemory(u32 memAddr, u32 cacheAddr, u32 numBlocks); -void DMA_MemoryToLC(u32 cacheAddr, u32 memAddr, u32 numBlocks); -void ClearCacheLine(u32 address); // Zeroes 32 bytes; address should be 32-byte-aligned - -// TLB functions -void SDRUpdated(); -void InvalidateTLBEntry(u32 address); -void DBATUpdated(); -void IBATUpdated(); - -// Result changes based on the BAT registers and MSR.DR. Returns whether -// it's safe to optimize a read or write to this address to an unguarded -// memory access. Does not consider page tables. -bool IsOptimizableRAMAddress(u32 address); -u32 IsOptimizableMMIOAccess(u32 address, u32 accessSize); -bool IsOptimizableGatherPipeWrite(u32 address); - -struct TranslateResult -{ - bool valid; - bool from_bat; - u32 address; -}; -TranslateResult JitCache_TranslateAddress(u32 address); - -constexpr int BAT_INDEX_SHIFT = 17; -constexpr u32 BAT_PAGE_SIZE = 1 << BAT_INDEX_SHIFT; -constexpr u32 BAT_MAPPED_BIT = 0x1; -constexpr u32 BAT_PHYSICAL_BIT = 0x2; -constexpr u32 BAT_RESULT_MASK = UINT32_C(~0x3); -using BatTable = std::array; // 128 KB -extern BatTable ibat_table; -extern BatTable dbat_table; -inline bool TranslateBatAddess(const BatTable& bat_table, u32* address) -{ - u32 bat_result = bat_table[*address >> BAT_INDEX_SHIFT]; - if ((bat_result & BAT_MAPPED_BIT) == 0) - return false; - *address = (bat_result & BAT_RESULT_MASK) | (*address & (BAT_PAGE_SIZE - 1)); - return true; -} - enum CRBits { CR_SO = 1, diff --git a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp index 1076a0dcdc..27885fb50b 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp @@ -16,8 +16,8 @@ #include "Common/Logging/Log.h" #include "Common/StringUtil.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" -#include "Core/PowerPC/PowerPC.h" namespace { diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp index ccd0338c5c..8c0b096d27 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp @@ -10,8 +10,8 @@ #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" -#include "Core/PowerPC/PowerPC.h" // Format Handlers #include "Core/PowerPC/SignatureDB/CSVSignatureDB.h" diff --git a/Source/Core/DolphinQt2/CheatsManager.cpp b/Source/Core/DolphinQt2/CheatsManager.cpp index 82cdc7118b..59ca0f5c06 100644 --- a/Source/Core/DolphinQt2/CheatsManager.cpp +++ b/Source/Core/DolphinQt2/CheatsManager.cpp @@ -25,6 +25,7 @@ #include "Core/Core.h" #include "Core/Debugger/PPCDebugInterface.h" #include "Core/HW/Memmap.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" #include "UICommon/GameFile.h" diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp index f3dfad215a..01e9f726c9 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp @@ -22,6 +22,7 @@ #include "Common/StringUtil.h" #include "Core/Core.h" #include "Core/Debugger/PPCDebugInterface.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/DolphinQt2/Debugger/CodeWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeWidget.cpp index e95fa87690..d91a321aed 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeWidget.cpp @@ -19,6 +19,7 @@ #include "Core/Core.h" #include "Core/Debugger/Debugger_SymbolMap.h" #include "Core/HW/CPU.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" #include "DolphinQt2/Host.h" diff --git a/Source/Core/DolphinQt2/Debugger/MemoryViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/MemoryViewWidget.cpp index 52aff33e4f..688ff9003d 100644 --- a/Source/Core/DolphinQt2/Debugger/MemoryViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/MemoryViewWidget.cpp @@ -10,10 +10,13 @@ #include #include #include + +#include #include #include "Core/Core.h" #include "Core/PowerPC/BreakPoints.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" #include "DolphinQt2/QtUtils/ActionHelper.h" diff --git a/Source/Core/DolphinQt2/Debugger/WatchWidget.cpp b/Source/Core/DolphinQt2/Debugger/WatchWidget.cpp index 9f0a1afdad..0daa58a5ae 100644 --- a/Source/Core/DolphinQt2/Debugger/WatchWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/WatchWidget.cpp @@ -8,6 +8,7 @@ #include "Common/IniFile.h" #include "Core/ConfigManager.h" #include "Core/Core.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" #include "DolphinQt2/QtUtils/ActionHelper.h" diff --git a/Source/Core/DolphinQt2/MenuBar.cpp b/Source/Core/DolphinQt2/MenuBar.cpp index 398ce15455..41e818ebf0 100644 --- a/Source/Core/DolphinQt2/MenuBar.cpp +++ b/Source/Core/DolphinQt2/MenuBar.cpp @@ -28,12 +28,12 @@ #include "Core/HLE/HLE.h" #include "Core/HW/WiiSave.h" #include "Core/HW/Wiimote.h" -#include "Core/Host.h" #include "Core/IOS/ES/ES.h" #include "Core/IOS/IOS.h" #include "Core/IOS/USB/Bluetooth/BTEmu.h" #include "Core/Movie.h" #include "Core/PowerPC/JitInterface.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/DolphinWX/Debugger/CodeView.cpp b/Source/Core/DolphinWX/Debugger/CodeView.cpp index 635312ffef..da6f29abb7 100644 --- a/Source/Core/DolphinWX/Debugger/CodeView.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeView.cpp @@ -26,8 +26,8 @@ #include "Common/SymbolDB.h" #include "Core/Core.h" #include "Core/Host.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCAnalyst.h" -#include "Core/PowerPC/PowerPC.h" #include "DolphinWX/Debugger/AssemblerEntryDialog.h" #include "DolphinWX/Debugger/CodeView.h" #include "DolphinWX/Debugger/DebuggerUIUtil.h" diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp index 5530a7cff2..669bfb8a78 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp @@ -37,6 +37,7 @@ #include "Core/PowerPC/BreakPoints.h" #include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/JitInterface.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PPCTables.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/DolphinWX/Debugger/MemoryView.cpp b/Source/Core/DolphinWX/Debugger/MemoryView.cpp index 0e21c14473..b05e001a6c 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryView.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryView.cpp @@ -24,8 +24,8 @@ #include "Common/StringUtil.h" #include "Core/Core.h" #include "Core/HW/Memmap.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" -#include "Core/PowerPC/PowerPC.h" #include "DolphinWX/Debugger/CodeWindow.h" #include "DolphinWX/Debugger/DebuggerUIUtil.h" #include "DolphinWX/Debugger/WatchWindow.h" diff --git a/Source/Core/DolphinWX/Debugger/WatchView.cpp b/Source/Core/DolphinWX/Debugger/WatchView.cpp index 7b33d9aaa4..51f318426b 100644 --- a/Source/Core/DolphinWX/Debugger/WatchView.cpp +++ b/Source/Core/DolphinWX/Debugger/WatchView.cpp @@ -2,20 +2,19 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include +#include "DolphinWX/Debugger/WatchView.h" + #include #include #include "Common/GekkoDisassembler.h" #include "Core/Core.h" -#include "Core/HW/Memmap.h" +#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" #include "DolphinWX/Debugger/BreakpointWindow.h" #include "DolphinWX/Debugger/CodeWindow.h" #include "DolphinWX/Debugger/DebuggerUIUtil.h" #include "DolphinWX/Debugger/MemoryWindow.h" -#include "DolphinWX/Debugger/RegisterView.h" -#include "DolphinWX/Debugger/WatchView.h" #include "DolphinWX/Debugger/WatchWindow.h" #include "DolphinWX/Frame.h" #include "DolphinWX/Main.h"