mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-04-26 14:32:25 +00:00
Fix executable booting not functioning, move dirty page initialization to emu thread initialization to fix MMU bug, general code cleanliness improvements
This commit is contained in:
parent
d062310de0
commit
a277d66c50
@ -383,7 +383,6 @@ static void CpuThread(Core::System& system, const std::optional<std::string>& sa
|
|||||||
if (exception_handler)
|
if (exception_handler)
|
||||||
{
|
{
|
||||||
EMM::InstallExceptionHandler();
|
EMM::InstallExceptionHandler();
|
||||||
system.GetMemory().InitDirtyPages();
|
|
||||||
}
|
}
|
||||||
#ifdef USE_MEMORYWATCHER
|
#ifdef USE_MEMORYWATCHER
|
||||||
s_memory_watcher = std::make_unique<MemoryWatcher>();
|
s_memory_watcher = std::make_unique<MemoryWatcher>();
|
||||||
@ -689,6 +688,9 @@ static void EmuThread(Core::System& system, std::unique_ptr<BootParameters> boot
|
|||||||
cpuThreadFunc(system, savestate_path, delete_savestate);
|
cpuThreadFunc(system, savestate_path, delete_savestate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cpuThreadFunc == CpuThread)
|
||||||
|
system.GetMemory().InitDirtyPages();
|
||||||
|
|
||||||
INFO_LOG_FMT(CONSOLE, "{}", StopMessage(true, "Stopping GDB ..."));
|
INFO_LOG_FMT(CONSOLE, "{}", StopMessage(true, "Stopping GDB ..."));
|
||||||
GDBStub::Deinit();
|
GDBStub::Deinit();
|
||||||
INFO_LOG_FMT(CONSOLE, "{}", StopMessage(true, "GDB stopped."));
|
INFO_LOG_FMT(CONSOLE, "{}", StopMessage(true, "GDB stopped."));
|
||||||
|
|||||||
@ -90,7 +90,8 @@ void MemoryManager::WriteProtectPhysicalMemoryRegions()
|
|||||||
reinterpret_cast<u64>(*region.out_pointer));
|
reinterpret_cast<u64>(*region.out_pointer));
|
||||||
}
|
}
|
||||||
const size_t page_size = Common::PageSize();
|
const size_t page_size = Common::PageSize();
|
||||||
for (size_t i = reinterpret_cast<intptr_t>(*region.out_pointer); i < region.size; i += page_size)
|
const intptr_t out_pointer = reinterpret_cast<intptr_t>(*region.out_pointer);
|
||||||
|
for (size_t i = out_pointer; i < region.size; i += page_size)
|
||||||
{
|
{
|
||||||
m_dirty_pages[i] = false;
|
m_dirty_pages[i] = false;
|
||||||
}
|
}
|
||||||
@ -154,7 +155,8 @@ void MemoryManager::Init()
|
|||||||
m_physical_regions[1] = PhysicalMemoryRegion{
|
m_physical_regions[1] = PhysicalMemoryRegion{
|
||||||
&m_l1_cache, 0xE0000000, GetL1CacheSize(), PhysicalMemoryRegion::ALWAYS, 0, false, false};
|
&m_l1_cache, 0xE0000000, GetL1CacheSize(), PhysicalMemoryRegion::ALWAYS, 0, false, false};
|
||||||
m_physical_regions[2] = PhysicalMemoryRegion{
|
m_physical_regions[2] = PhysicalMemoryRegion{
|
||||||
&m_fake_vmem, 0x7E000000, GetFakeVMemSize(), PhysicalMemoryRegion::FAKE_VMEM, 0, false, false};
|
&m_fake_vmem, 0x7E000000, GetFakeVMemSize(), PhysicalMemoryRegion::FAKE_VMEM, 0,
|
||||||
|
false, false};
|
||||||
m_physical_regions[3] = PhysicalMemoryRegion{
|
m_physical_regions[3] = PhysicalMemoryRegion{
|
||||||
&m_exram, 0x10000000, GetExRamSize(), PhysicalMemoryRegion::WII_ONLY, 0, false, true};
|
&m_exram, 0x10000000, GetExRamSize(), PhysicalMemoryRegion::WII_ONLY, 0, false, true};
|
||||||
|
|
||||||
@ -408,23 +410,11 @@ void MemoryManager::DoState(PointerWrap& p, bool delta)
|
|||||||
p.DoArray(m_ram + i, page_size);
|
p.DoArray(m_ram + i, page_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < current_l1_cache_size; i += page_size)
|
p.DoArray(m_l1_cache, current_l1_cache_size);
|
||||||
{
|
|
||||||
if (IsPageDirty(reinterpret_cast<uintptr_t>(&m_l1_cache[i])))
|
|
||||||
{
|
|
||||||
p.DoArray(m_l1_cache + i, page_size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.DoMarker("Memory RAM");
|
p.DoMarker("Memory RAM");
|
||||||
if (current_have_fake_vmem)
|
if (current_have_fake_vmem)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < current_fake_vmem_size; i += page_size)
|
p.DoArray(m_fake_vmem, current_fake_vmem_size);
|
||||||
{
|
|
||||||
if (IsPageDirty(reinterpret_cast<uintptr_t>(&m_fake_vmem[i])))
|
|
||||||
{
|
|
||||||
p.DoArray(m_fake_vmem + i, page_size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p.DoMarker("Memory FakeVMEM");
|
p.DoMarker("Memory FakeVMEM");
|
||||||
if (current_have_exram)
|
if (current_have_exram)
|
||||||
@ -456,13 +446,13 @@ void MemoryManager::DoState(PointerWrap& p, bool delta)
|
|||||||
void MemoryManager::Shutdown()
|
void MemoryManager::Shutdown()
|
||||||
{
|
{
|
||||||
ShutdownFastmemArena();
|
ShutdownFastmemArena();
|
||||||
|
m_dirty_pages.clear();
|
||||||
|
|
||||||
m_is_initialized = false;
|
m_is_initialized = false;
|
||||||
for (const PhysicalMemoryRegion& region : m_physical_regions)
|
for (const PhysicalMemoryRegion& region : m_physical_regions)
|
||||||
{
|
{
|
||||||
if (!region.active)
|
if (!region.active)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_arena.ReleaseView(*region.out_pointer, region.size);
|
m_arena.ReleaseView(*region.out_pointer, region.size);
|
||||||
*region.out_pointer = nullptr;
|
*region.out_pointer = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -137,7 +137,6 @@ public:
|
|||||||
bool IsPageDirty(uintptr_t address);
|
bool IsPageDirty(uintptr_t address);
|
||||||
void SetPageDirtyBit(uintptr_t address, size_t size, bool dirty);
|
void SetPageDirtyBit(uintptr_t address, size_t size, bool dirty);
|
||||||
void ResetDirtyPages();
|
void ResetDirtyPages();
|
||||||
bool VirtualProtectMemory(u8* data, size_t size, u64 flag);
|
|
||||||
bool HandleFault(uintptr_t fault_address);
|
bool HandleFault(uintptr_t fault_address);
|
||||||
|
|
||||||
std::map<u64, u8>& GetDirtyPages() { return m_dirty_pages; }
|
std::map<u64, u8>& GetDirtyPages() { return m_dirty_pages; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user