mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Common: namespace MemoryUtil
This commit is contained in:
@ -162,7 +162,7 @@ void FrameUpdateOnCPUThread()
|
||||
std::string StopMessage(bool main_thread, const std::string& message)
|
||||
{
|
||||
return StringFromFormat("Stop [%s %i]\t%s\t%s", main_thread ? "Main Thread" : "Video Thread",
|
||||
Common::CurrentThreadId(), MemUsage().c_str(), message.c_str());
|
||||
Common::CurrentThreadId(), Common::MemUsage().c_str(), message.c_str());
|
||||
}
|
||||
|
||||
void DisplayMessage(const std::string& message, int time_in_ms)
|
||||
|
@ -90,10 +90,10 @@ static bool VerifyRoms()
|
||||
|
||||
static void DSPCore_FreeMemoryPages()
|
||||
{
|
||||
FreeMemoryPages(g_dsp.irom, DSP_IROM_BYTE_SIZE);
|
||||
FreeMemoryPages(g_dsp.iram, DSP_IRAM_BYTE_SIZE);
|
||||
FreeMemoryPages(g_dsp.dram, DSP_DRAM_BYTE_SIZE);
|
||||
FreeMemoryPages(g_dsp.coef, DSP_COEF_BYTE_SIZE);
|
||||
Common::FreeMemoryPages(g_dsp.irom, DSP_IROM_BYTE_SIZE);
|
||||
Common::FreeMemoryPages(g_dsp.iram, DSP_IRAM_BYTE_SIZE);
|
||||
Common::FreeMemoryPages(g_dsp.dram, DSP_DRAM_BYTE_SIZE);
|
||||
Common::FreeMemoryPages(g_dsp.coef, DSP_COEF_BYTE_SIZE);
|
||||
g_dsp.irom = g_dsp.iram = g_dsp.dram = g_dsp.coef = nullptr;
|
||||
}
|
||||
|
||||
@ -103,10 +103,10 @@ bool DSPCore_Init(const DSPInitOptions& opts)
|
||||
g_cycles_left = 0;
|
||||
g_init_hax = false;
|
||||
|
||||
g_dsp.irom = (u16*)AllocateMemoryPages(DSP_IROM_BYTE_SIZE);
|
||||
g_dsp.iram = (u16*)AllocateMemoryPages(DSP_IRAM_BYTE_SIZE);
|
||||
g_dsp.dram = (u16*)AllocateMemoryPages(DSP_DRAM_BYTE_SIZE);
|
||||
g_dsp.coef = (u16*)AllocateMemoryPages(DSP_COEF_BYTE_SIZE);
|
||||
g_dsp.irom = static_cast<u16*>(Common::AllocateMemoryPages(DSP_IROM_BYTE_SIZE));
|
||||
g_dsp.iram = static_cast<u16*>(Common::AllocateMemoryPages(DSP_IRAM_BYTE_SIZE));
|
||||
g_dsp.dram = static_cast<u16*>(Common::AllocateMemoryPages(DSP_DRAM_BYTE_SIZE));
|
||||
g_dsp.coef = static_cast<u16*>(Common::AllocateMemoryPages(DSP_COEF_BYTE_SIZE));
|
||||
|
||||
memcpy(g_dsp.irom, opts.irom_contents.data(), DSP_IROM_BYTE_SIZE);
|
||||
memcpy(g_dsp.coef, opts.coef_contents.data(), DSP_COEF_BYTE_SIZE);
|
||||
@ -142,7 +142,7 @@ bool DSPCore_Init(const DSPInitOptions& opts)
|
||||
gdsp_ifx_init();
|
||||
// Mostly keep IRAM write protected. We unprotect only when DMA-ing
|
||||
// in new ucodes.
|
||||
WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
Common::WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
|
||||
// Initialize JIT, if necessary
|
||||
if (opts.core_type == DSPInitOptions::CORE_JIT)
|
||||
|
@ -225,7 +225,7 @@ u16 gdsp_ifx_read(u16 addr)
|
||||
|
||||
static const u8* gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size)
|
||||
{
|
||||
UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
Common::UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
|
||||
u8* dst = ((u8*)g_dsp.iram);
|
||||
for (u32 i = 0; i < size; i += 2)
|
||||
@ -233,7 +233,7 @@ static const u8* gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size)
|
||||
*(u16*)&dst[dsp_addr + i] =
|
||||
Common::swap16(*(const u16*)&g_dsp.cpu_ram[(addr + i) & 0x0fffffff]);
|
||||
}
|
||||
WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
Common::WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
|
||||
DSPHost::CodeLoaded((const u8*)g_dsp.iram + dsp_addr, size);
|
||||
|
||||
|
@ -244,7 +244,7 @@ void Init(bool hle)
|
||||
g_ARAM.wii_mode = false;
|
||||
g_ARAM.size = ARAM_SIZE;
|
||||
g_ARAM.mask = ARAM_MASK;
|
||||
g_ARAM.ptr = (u8*)AllocateMemoryPages(g_ARAM.size);
|
||||
g_ARAM.ptr = static_cast<u8*>(Common::AllocateMemoryPages(g_ARAM.size));
|
||||
}
|
||||
|
||||
memset(&g_audioDMA, 0, sizeof(g_audioDMA));
|
||||
@ -270,7 +270,7 @@ void Shutdown()
|
||||
{
|
||||
if (!g_ARAM.wii_mode)
|
||||
{
|
||||
FreeMemoryPages(g_ARAM.ptr, g_ARAM.size);
|
||||
Common::FreeMemoryPages(g_ARAM.ptr, g_ARAM.size);
|
||||
g_ARAM.ptr = nullptr;
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,9 @@ void DSPLLE::DoState(PointerWrap& p)
|
||||
p.DoArray(g_dsp.ifx_regs);
|
||||
p.Do(g_dsp.mbox[0]);
|
||||
p.Do(g_dsp.mbox[1]);
|
||||
UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
Common::UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
p.DoArray(g_dsp.iram, DSP_IRAM_SIZE);
|
||||
WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
Common::WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
if (p.GetMode() == PointerWrap::MODE_READ)
|
||||
DSPHost::CodeLoaded((const u8*)g_dsp.iram, DSP_IRAM_BYTE_SIZE);
|
||||
p.DoArray(g_dsp.dram, DSP_DRAM_SIZE);
|
||||
|
@ -93,7 +93,7 @@ CEXIIPL::CEXIIPL() : m_uPosition(0), m_uAddress(0), m_uRWOffset(0), m_FontsLoade
|
||||
m_bNTSC = SConfig::GetInstance().bNTSC;
|
||||
|
||||
// Create the IPL
|
||||
m_pIPL = (u8*)AllocateMemoryPages(ROM_SIZE);
|
||||
m_pIPL = static_cast<u8*>(Common::AllocateMemoryPages(ROM_SIZE));
|
||||
|
||||
if (SConfig::GetInstance().bHLE_BS2)
|
||||
{
|
||||
@ -122,13 +122,13 @@ CEXIIPL::CEXIIPL() : m_uPosition(0), m_uAddress(0), m_uRWOffset(0), m_FontsLoade
|
||||
g_SRAM.lang = SConfig::GetInstance().SelectedLanguage;
|
||||
FixSRAMChecksums();
|
||||
|
||||
WriteProtectMemory(m_pIPL, ROM_SIZE);
|
||||
Common::WriteProtectMemory(m_pIPL, ROM_SIZE);
|
||||
m_uAddress = 0;
|
||||
}
|
||||
|
||||
CEXIIPL::~CEXIIPL()
|
||||
{
|
||||
FreeMemoryPages(m_pIPL, ROM_SIZE);
|
||||
Common::FreeMemoryPages(m_pIPL, ROM_SIZE);
|
||||
m_pIPL = nullptr;
|
||||
|
||||
// SRAM
|
||||
|
@ -151,9 +151,9 @@ enum
|
||||
void Jit64::AllocStack()
|
||||
{
|
||||
#ifndef _WIN32
|
||||
m_stack = (u8*)AllocateMemoryPages(STACK_SIZE);
|
||||
ReadProtectMemory(m_stack, GUARD_SIZE);
|
||||
ReadProtectMemory(m_stack + GUARD_OFFSET, GUARD_SIZE);
|
||||
m_stack = static_cast<u8*>(Common::AllocateMemoryPages(STACK_SIZE));
|
||||
Common::ReadProtectMemory(m_stack, GUARD_SIZE);
|
||||
Common::ReadProtectMemory(m_stack + GUARD_OFFSET, GUARD_SIZE);
|
||||
#else
|
||||
// For windows we just keep using the system stack and reserve a large amount of memory at the end
|
||||
// of the stack.
|
||||
@ -167,7 +167,7 @@ void Jit64::FreeStack()
|
||||
#ifndef _WIN32
|
||||
if (m_stack)
|
||||
{
|
||||
FreeMemoryPages(m_stack, STACK_SIZE);
|
||||
Common::FreeMemoryPages(m_stack, STACK_SIZE);
|
||||
m_stack = nullptr;
|
||||
}
|
||||
#endif
|
||||
@ -186,7 +186,7 @@ bool Jit64::HandleStackFault()
|
||||
m_enable_blr_optimization = false;
|
||||
#ifndef _WIN32
|
||||
// Windows does this automatically.
|
||||
UnWriteProtectMemory(m_stack + GUARD_OFFSET, GUARD_SIZE);
|
||||
Common::UnWriteProtectMemory(m_stack + GUARD_OFFSET, GUARD_SIZE);
|
||||
#endif
|
||||
// We're going to need to clear the whole cache to get rid of the bad
|
||||
// CALLs, but we can't yet. Fake the downcount so we're forced to the
|
||||
|
Reference in New Issue
Block a user