HW/ProcessorInterface: Store reference to System in class.

This commit is contained in:
Admiral H. Curtiss 2023-03-12 18:13:43 +01:00
parent ba852a7812
commit 31d33d0efd
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
3 changed files with 27 additions and 13 deletions

View File

@ -18,6 +18,7 @@
#include "Core/IOS/IOS.h"
#include "Core/IOS/STM/STM.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/System.h"
#include "VideoCommon/AsyncRequests.h"
#include "VideoCommon/Fifo.h"
@ -27,6 +28,12 @@ constexpr u32 FLIPPER_REV_A = 0x046500B0;
constexpr u32 FLIPPER_REV_B = 0x146500B1;
constexpr u32 FLIPPER_REV_C = 0x246500B1;
ProcessorInterfaceManager::ProcessorInterfaceManager(Core::System& system) : m_system(system)
{
}
ProcessorInterfaceManager::~ProcessorInterfaceManager() = default;
void ProcessorInterfaceManager::DoState(PointerWrap& p)
{
p.Do(m_interrupt_mask);
@ -49,8 +56,7 @@ void ProcessorInterfaceManager::Init()
m_reset_code = 0; // Cold reset
m_interrupt_cause = INT_CAUSE_RST_BUTTON | INT_CAUSE_VI;
auto& system = Core::System::GetInstance();
auto& core_timing = system.GetCoreTiming();
auto& core_timing = m_system.GetCoreTiming();
m_event_type_toggle_reset_button =
core_timing.RegisterEvent("ToggleResetButton", ToggleResetButtonCallback);
m_event_type_ios_notify_reset_button =
@ -65,14 +71,14 @@ void ProcessorInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
MMIO::ComplexWrite<u32>([](Core::System& system, u32, u32 val) {
auto& processor_interface = system.GetProcessorInterface();
processor_interface.m_interrupt_cause &= ~val;
processor_interface.UpdateException(system);
processor_interface.UpdateException();
}));
mmio->Register(base | PI_INTERRUPT_MASK, MMIO::DirectRead<u32>(&m_interrupt_mask),
MMIO::ComplexWrite<u32>([](Core::System& system, u32, u32 val) {
auto& processor_interface = system.GetProcessorInterface();
processor_interface.m_interrupt_mask = val;
processor_interface.UpdateException(system);
processor_interface.UpdateException();
}));
mmio->Register(base | PI_FIFO_BASE, MMIO::DirectRead<u32>(&m_fifo_cpu_base),
@ -137,9 +143,9 @@ void ProcessorInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
}
}
void ProcessorInterfaceManager::UpdateException(Core::System& system)
void ProcessorInterfaceManager::UpdateException()
{
auto& ppc_state = system.GetPPCState();
auto& ppc_state = m_system.GetPPCState();
if ((m_interrupt_cause & m_interrupt_mask) != 0)
ppc_state.Exceptions |= EXCEPTION_EXTERNAL_INT;
else
@ -209,7 +215,7 @@ void ProcessorInterfaceManager::SetInterrupt(u32 cause_mask, bool set)
m_interrupt_cause &= ~cause_mask; // is there any reason to have this possibility?
// F|RES: i think the hw devices reset the interrupt in the PI to 0
// if the interrupt cause is eliminated. that isn't done by software (afaik)
UpdateException(Core::System::GetInstance());
UpdateException();
}
void ProcessorInterfaceManager::SetResetButton(bool set)
@ -252,8 +258,7 @@ void ProcessorInterfaceManager::ResetButton_Tap()
if (!Core::IsRunning())
return;
auto& system = Core::System::GetInstance();
auto& core_timing = system.GetCoreTiming();
auto& core_timing = m_system.GetCoreTiming();
core_timing.ScheduleEvent(0, m_event_type_toggle_reset_button, true, CoreTiming::FromThread::ANY);
core_timing.ScheduleEvent(0, m_event_type_ios_notify_reset_button, 0,
CoreTiming::FromThread::ANY);
@ -266,8 +271,7 @@ void ProcessorInterfaceManager::PowerButton_Tap()
if (!Core::IsRunning())
return;
auto& system = Core::System::GetInstance();
auto& core_timing = system.GetCoreTiming();
auto& core_timing = m_system.GetCoreTiming();
core_timing.ScheduleEvent(0, m_event_type_ios_notify_power_button, 0,
CoreTiming::FromThread::ANY);
}

View File

@ -63,6 +63,13 @@ enum
class ProcessorInterfaceManager
{
public:
explicit ProcessorInterfaceManager(Core::System& system);
ProcessorInterfaceManager(const ProcessorInterfaceManager& other) = delete;
ProcessorInterfaceManager(ProcessorInterfaceManager&& other) = delete;
ProcessorInterfaceManager& operator=(const ProcessorInterfaceManager& other) = delete;
ProcessorInterfaceManager& operator=(ProcessorInterfaceManager&& other) = delete;
~ProcessorInterfaceManager();
void Init();
void DoState(PointerWrap& p);
@ -87,7 +94,7 @@ public:
private:
// Let the PPC know that an external exception is set/cleared
void UpdateException(Core::System& system);
void UpdateException();
void SetResetButton(bool set);
@ -101,5 +108,7 @@ private:
CoreTiming::EventType* m_event_type_ios_notify_power_button = nullptr;
u32 m_reset_code = 0;
Core::System& m_system;
};
} // namespace ProcessorInterface

View File

@ -38,7 +38,8 @@ struct System::Impl
explicit Impl(System& system)
: m_audio_interface(system), m_core_timing(system), m_dsp(system), m_dvd_interface(system),
m_dvd_thread(system), m_expansion_interface(system), m_gp_fifo(system), m_memory(system),
m_ppc_state(PowerPC::ppcState), m_serial_interface(system), m_video_interface(system)
m_ppc_state(PowerPC::ppcState), m_processor_interface(system), m_serial_interface(system),
m_video_interface(system)
{
}