hw/gpu: pass in memory reference

This commit is contained in:
Weiyi Wang 2018-11-21 11:53:10 -05:00
parent ec01975549
commit cfee59c6db
5 changed files with 17 additions and 7 deletions

View File

@ -189,7 +189,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) {
cpu_core = std::make_unique<ARM_DynCom>(USER32MODE);
}
dsp_core = std::make_unique<AudioCore::DspHle>();
dsp_core = std::make_unique<AudioCore::DspHle>(*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<Service::SM::ServiceManager>(*this);
archive_manager = std::make_unique<Service::FS::ArchiveManager>(*this);
HW::Init();
HW::Init(*memory);
Service::Init(*this);
GDBStub::Init();

View File

@ -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<u64>(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];

View File

@ -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 <typename T>
void Write(u32 addr, const T data);
/// Initialize hardware
void Init();
void Init(Memory::MemorySystem& memory);
/// Shutdown hardware
void Shutdown();

View File

@ -86,9 +86,9 @@ template void Write<u8>(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");
}

View File

@ -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();