From cfee59c6dba35a38b04e89794347029a78a440ab Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Wed, 21 Nov 2018 11:53:10 -0500 Subject: [PATCH] hw/gpu: pass in memory reference --- src/core/core.cpp | 4 ++-- src/core/hw/gpu.cpp | 4 +++- src/core/hw/gpu.h | 6 +++++- src/core/hw/hw.cpp | 4 ++-- src/core/hw/hw.h | 6 +++++- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 37c3d1ac3..dc5c6236f 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -189,7 +189,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) { cpu_core = std::make_unique(USER32MODE); } - dsp_core = std::make_unique(); + dsp_core = std::make_unique(*memory); dsp_core->SetSink(Settings::values.sink_id, Settings::values.audio_device_id); dsp_core->EnableStretching(Settings::values.enable_audio_stretching); @@ -202,7 +202,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) { service_manager = std::make_shared(*this); archive_manager = std::make_unique(*this); - HW::Init(); + HW::Init(*memory); Service::Init(*this); GDBStub::Init(); diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 47bb852f8..34ecc08a5 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -27,6 +27,7 @@ namespace GPU { Regs g_regs; +Memory::MemorySystem* g_memory; /// 268MHz CPU clocks / 60Hz frames per second const u64 frame_ticks = static_cast(BASE_CLOCK_RATE_ARM11 / SCREEN_REFRESH_RATE); @@ -526,7 +527,8 @@ static void VBlankCallback(u64 userdata, s64 cycles_late) { } /// Initialize hardware -void Init() { +void Init(Memory::MemorySystem& memory) { + g_memory = &memory; memset(&g_regs, 0, sizeof(g_regs)); auto& framebuffer_top = g_regs.framebuffer_config[0]; diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index 8184066da..606ab9504 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -11,6 +11,10 @@ #include "common/common_funcs.h" #include "common/common_types.h" +namespace Memory { +class MemorySystem; +} + namespace GPU { constexpr float SCREEN_REFRESH_RATE = 60; @@ -326,7 +330,7 @@ template void Write(u32 addr, const T data); /// Initialize hardware -void Init(); +void Init(Memory::MemorySystem& memory); /// Shutdown hardware void Shutdown(); diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp index 4d31b3c80..e7d80a5c7 100644 --- a/src/core/hw/hw.cpp +++ b/src/core/hw/hw.cpp @@ -86,9 +86,9 @@ template void Write(u32 addr, const u8 data); void Update() {} /// Initialize hardware -void Init() { +void Init(Memory::MemorySystem& memory) { AES::InitKeys(); - GPU::Init(); + GPU::Init(memory); LCD::Init(); LOG_DEBUG(HW, "initialized OK"); } diff --git a/src/core/hw/hw.h b/src/core/hw/hw.h index 5890d2b5c..cc7b04294 100644 --- a/src/core/hw/hw.h +++ b/src/core/hw/hw.h @@ -6,6 +6,10 @@ #include "common/common_types.h" +namespace Memory { +class MemorySystem; +} + namespace HW { /// Beginnings of IO register regions, in the user VA space. @@ -42,7 +46,7 @@ void Write(u32 addr, const T data); void Update(); /// Initialize hardware -void Init(); +void Init(Memory::MemorySystem& memory); /// Shutdown hardware void Shutdown();