diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index 74247e442c..fe06a3329d 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -19,6 +19,7 @@ #include "Core/Config/MainSettings.h" #include "Core/Core.h" #include "Core/PowerPC/PowerPC.h" +#include "Core/System.h" #include "VideoCommon/Fifo.h" #include "VideoCommon/VideoBackendBase.h" @@ -82,7 +83,7 @@ static float s_config_OC_factor; static float s_config_OC_inv_factor; static bool s_config_sync_on_skip_idle; -static void EmptyTimedCallback(u64 userdata, s64 cyclesLate) +static void EmptyTimedCallback(Core::System& system, u64 userdata, s64 cyclesLate) { } @@ -345,7 +346,7 @@ void Advance() Event evt = std::move(s_event_queue.front()); std::pop_heap(s_event_queue.begin(), s_event_queue.end(), std::greater()); s_event_queue.pop_back(); - evt.type->callback(evt.userdata, g.global_timer - evt.time); + evt.type->callback(Core::System::GetInstance(), evt.userdata, g.global_timer - evt.time); } s_is_global_timer_sane = false; diff --git a/Source/Core/Core/CoreTiming.h b/Source/Core/Core/CoreTiming.h index 255aa612ca..64a5e81a74 100644 --- a/Source/Core/Core/CoreTiming.h +++ b/Source/Core/Core/CoreTiming.h @@ -21,6 +21,11 @@ class PointerWrap; +namespace Core +{ +class System; +} + namespace CoreTiming { // These really shouldn't be global, but jit64 accesses them directly @@ -39,7 +44,7 @@ extern Globals g; void Init(); void Shutdown(); -typedef void (*TimedCallback)(u64 userdata, s64 cyclesLate); +typedef void (*TimedCallback)(Core::System& system, u64 userdata, s64 cyclesLate); // This should only be called from the CPU thread, if you are calling it any other thread, you are // doing something evil diff --git a/Source/Core/Core/HW/AudioInterface.cpp b/Source/Core/Core/HW/AudioInterface.cpp index eddb9016b1..4a3f4cd254 100644 --- a/Source/Core/Core/HW/AudioInterface.cpp +++ b/Source/Core/Core/HW/AudioInterface.cpp @@ -198,12 +198,12 @@ int GetAIPeriod() return static_cast(std::min(period, s_period)); } -void Update(u64 userdata, s64 cycles_late) +static void Update(Core::System& system, u64 userdata, s64 cycles_late) { if (!IsPlaying()) return; - auto& state = Core::System::GetInstance().GetAudioInterfaceState().GetData(); + auto& state = system.GetAudioInterfaceState().GetData(); const u64 diff = CoreTiming::GetTicks() - state.last_cpu_time; if (diff > state.cpu_cycles_per_sample) diff --git a/Source/Core/Core/HW/DSP.cpp b/Source/Core/Core/HW/DSP.cpp index 5ebe4a6680..f9d6cd7604 100644 --- a/Source/Core/Core/HW/DSP.cpp +++ b/Source/Core/Core/HW/DSP.cpp @@ -177,13 +177,13 @@ void DoState(PointerWrap& p) static void UpdateInterrupts(); static void Do_ARAM_DMA(); -static void GenerateDSPInterrupt(u64 DSPIntType, s64 cyclesLate = 0); +static void GenerateDSPInterrupt(Core::System& system, u64 DSPIntType, s64 cyclesLate = 0); -static void CompleteARAM(u64 userdata, s64 cyclesLate) +static void CompleteARAM(Core::System& system, u64 userdata, s64 cyclesLate) { - auto& state = Core::System::GetInstance().GetDSPState().GetData(); + auto& state = system.GetDSPState().GetData(); state.dsp_control.DMAState = 0; - GenerateDSPInterrupt(INT_ARAM); + GenerateDSPInterrupt(system, INT_ARAM); } DSPEmulator* GetDSPEmulator() @@ -471,9 +471,9 @@ static void UpdateInterrupts() ProcessorInterface::SetInterrupt(ProcessorInterface::INT_CAUSE_DSP, ints_set); } -static void GenerateDSPInterrupt(u64 DSPIntType, s64 cyclesLate) +static void GenerateDSPInterrupt(Core::System& system, u64 DSPIntType, s64 cyclesLate) { - auto& state = Core::System::GetInstance().GetDSPState().GetData(); + auto& state = system.GetDSPState().GetData(); // The INT_* enumeration members have values that reflect their bit positions in // DSP_CONTROL - we mask by (INT_DSP | INT_ARAM | INT_AID) just to ensure people @@ -512,7 +512,8 @@ void UpdateDSPSlice(int cycles) // This happens at 4 khz, since 32 bytes at 4khz = 4 bytes at 32 khz (16bit stereo pcm) void UpdateAudioDMA() { - auto& state = Core::System::GetInstance().GetDSPState().GetData(); + auto& system = Core::System::GetInstance(); + auto& state = system.GetDSPState().GetData(); static short zero_samples[8 * 2] = {0}; if (state.audio_dma.AudioDMAControl.Enable) @@ -534,7 +535,7 @@ void UpdateAudioDMA() state.audio_dma.current_source_address = state.audio_dma.SourceAddress; state.audio_dma.remaining_blocks_count = state.audio_dma.AudioDMAControl.NumBlocks; - GenerateDSPInterrupt(DSP::INT_AID); + GenerateDSPInterrupt(system, DSP::INT_AID); } } else diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp index d7d328ee22..ac90fd4d76 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp @@ -188,10 +188,10 @@ DVDInterfaceState::DVDInterfaceState() : m_data(std::make_unique()) DVDInterfaceState::~DVDInterfaceState() = default; -static void AutoChangeDiscCallback(u64 userdata, s64 cyclesLate); -static void EjectDiscCallback(u64 userdata, s64 cyclesLate); -static void InsertDiscCallback(u64 userdata, s64 cyclesLate); -static void FinishExecutingCommandCallback(u64 userdata, s64 cycles_late); +static void AutoChangeDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate); +static void EjectDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate); +static void InsertDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate); +static void FinishExecutingCommandCallback(Core::System& system, u64 userdata, s64 cycles_late); static void SetLidOpen(); @@ -531,19 +531,19 @@ bool IsDiscInside() return DVDThread::HasDisc(); } -static void AutoChangeDiscCallback(u64 userdata, s64 cyclesLate) +static void AutoChangeDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate) { AutoChangeDisc(); } -static void EjectDiscCallback(u64 userdata, s64 cyclesLate) +static void EjectDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate) { SetDisc(nullptr, {}); } -static void InsertDiscCallback(u64 userdata, s64 cyclesLate) +static void InsertDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate) { - auto& state = Core::System::GetInstance().GetDVDInterfaceState().GetData(); + auto& state = system.GetDVDInterfaceState().GetData(); std::unique_ptr new_disc = DiscIO::CreateDisc(state.disc_path_to_insert); if (new_disc) @@ -1370,7 +1370,7 @@ static u64 PackFinishExecutingCommandUserdata(ReplyType reply_type, DIInterruptT return (static_cast(reply_type) << 32) + static_cast(interrupt_type); } -void FinishExecutingCommandCallback(u64 userdata, s64 cycles_late) +void FinishExecutingCommandCallback(Core::System& system, u64 userdata, s64 cycles_late) { ReplyType reply_type = static_cast(userdata >> 32); DIInterruptType interrupt_type = static_cast(userdata & 0xFFFFFFFF); diff --git a/Source/Core/Core/HW/DVD/DVDThread.cpp b/Source/Core/Core/HW/DVD/DVDThread.cpp index 2cd0e35246..ea7f31f783 100644 --- a/Source/Core/Core/HW/DVD/DVDThread.cpp +++ b/Source/Core/Core/HW/DVD/DVDThread.cpp @@ -72,7 +72,7 @@ static void StartReadInternal(bool copy_to_ram, u32 output_address, u64 dvd_offs const DiscIO::Partition& partition, DVDInterface::ReplyType reply_type, s64 ticks_until_completion); -static void FinishRead(u64 id, s64 cycles_late); +static void FinishRead(Core::System& system, u64 id, s64 cycles_late); struct DVDThreadState::Data { @@ -328,9 +328,9 @@ static void StartReadInternal(bool copy_to_ram, u32 output_address, u64 dvd_offs CoreTiming::ScheduleEvent(ticks_until_completion, state.finish_read, id); } -static void FinishRead(u64 id, s64 cycles_late) +static void FinishRead(Core::System& system, u64 id, s64 cycles_late) { - auto& state = Core::System::GetInstance().GetDVDThreadState().GetData(); + auto& state = system.GetDVDThreadState().GetData(); // We can't simply pop result_queue and always get the ReadResult // we want, because the DVD thread may add ReadResults to the queue diff --git a/Source/Core/Core/HW/EXI/EXI.cpp b/Source/Core/Core/HW/EXI/EXI.cpp index 461524a689..350ed22203 100644 --- a/Source/Core/Core/HW/EXI/EXI.cpp +++ b/Source/Core/Core/HW/EXI/EXI.cpp @@ -43,8 +43,8 @@ ExpansionInterfaceState::ExpansionInterfaceState() : m_data(std::make_unique> 32); u8 type = (u8)(userdata >> 16); u8 num = (u8)userdata; - auto& state = Core::System::GetInstance().GetExpansionInterfaceState().GetData(); + auto& state = system.GetExpansionInterfaceState().GetData(); state.channels.at(channel)->AddDevice(static_cast(type), num); } @@ -270,7 +270,7 @@ void UpdateInterrupts() ProcessorInterface::SetInterrupt(ProcessorInterface::INT_CAUSE_EXI, causeInt); } -static void UpdateInterruptsCallback(u64 userdata, s64 cycles_late) +static void UpdateInterruptsCallback(Core::System& system, u64 userdata, s64 cycles_late) { UpdateInterrupts(); } diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp index c054c47404..2e97cc67e6 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp @@ -71,12 +71,12 @@ void CEXIMemoryCard::EventCompleteFindInstance(u64 userdata, } } -void CEXIMemoryCard::CmdDoneCallback(u64 userdata, s64) +void CEXIMemoryCard::CmdDoneCallback(Core::System& system, u64 userdata, s64) { EventCompleteFindInstance(userdata, [](CEXIMemoryCard* instance) { instance->CmdDone(); }); } -void CEXIMemoryCard::TransferCompleteCallback(u64 userdata, s64) +void CEXIMemoryCard::TransferCompleteCallback(Core::System& system, u64 userdata, s64) { EventCompleteFindInstance(userdata, [](CEXIMemoryCard* instance) { instance->TransferComplete(); }); diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.h b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.h index c472448d09..402518892d 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.h @@ -14,6 +14,10 @@ class MemoryCardBase; class PointerWrap; +namespace Core +{ +class System; +} namespace Memcard { struct HeaderData; @@ -58,10 +62,10 @@ private: std::function callback); // Scheduled when a command that required delayed end signaling is done. - static void CmdDoneCallback(u64 userdata, s64 cyclesLate); + static void CmdDoneCallback(Core::System& system, u64 userdata, s64 cyclesLate); // Scheduled when memory card is done transferring data - static void TransferCompleteCallback(u64 userdata, s64 cyclesLate); + static void TransferCompleteCallback(Core::System& system, u64 userdata, s64 cyclesLate); // Signals that the command that was previously executed is now done. void CmdDone(); diff --git a/Source/Core/Core/HW/ProcessorInterface.cpp b/Source/Core/Core/HW/ProcessorInterface.cpp index 37c10580bd..698069a261 100644 --- a/Source/Core/Core/HW/ProcessorInterface.cpp +++ b/Source/Core/Core/HW/ProcessorInterface.cpp @@ -39,13 +39,13 @@ static u32 m_ResetCode; // ID and callback for scheduling reset button presses/releases static CoreTiming::EventType* toggleResetButton; -static void ToggleResetButtonCallback(u64 userdata, s64 cyclesLate); +static void ToggleResetButtonCallback(Core::System& system, u64 userdata, s64 cyclesLate); static CoreTiming::EventType* iosNotifyResetButton; -static void IOSNotifyResetButtonCallback(u64 userdata, s64 cyclesLate); +static void IOSNotifyResetButtonCallback(Core::System& system, u64 userdata, s64 cyclesLate); static CoreTiming::EventType* iosNotifyPowerButton; -static void IOSNotifyPowerButtonCallback(u64 userdata, s64 cyclesLate); +static void IOSNotifyPowerButtonCallback(Core::System& system, u64 userdata, s64 cyclesLate); // Let the PPC know that an external exception is set/cleared void UpdateException(); @@ -230,12 +230,12 @@ static void SetResetButton(bool set) SetInterrupt(INT_CAUSE_RST_BUTTON, !set); } -static void ToggleResetButtonCallback(u64 userdata, s64 cyclesLate) +static void ToggleResetButtonCallback(Core::System& system, u64 userdata, s64 cyclesLate) { SetResetButton(!!userdata); } -static void IOSNotifyResetButtonCallback(u64 userdata, s64 cyclesLate) +static void IOSNotifyResetButtonCallback(Core::System& system, u64 userdata, s64 cyclesLate) { const auto ios = IOS::HLE::GetIOS(); if (!ios) @@ -246,7 +246,7 @@ static void IOSNotifyResetButtonCallback(u64 userdata, s64 cyclesLate) std::static_pointer_cast(stm)->ResetButton(); } -static void IOSNotifyPowerButtonCallback(u64 userdata, s64 cyclesLate) +static void IOSNotifyPowerButtonCallback(Core::System& system, u64 userdata, s64 cyclesLate) { const auto ios = IOS::HLE::GetIOS(); if (!ios) diff --git a/Source/Core/Core/HW/SI/SI.cpp b/Source/Core/Core/HW/SI/SI.cpp index 1a199e1fa6..ef0be4f19c 100644 --- a/Source/Core/Core/HW/SI/SI.cpp +++ b/Source/Core/Core/HW/SI/SI.cpp @@ -243,10 +243,10 @@ static void SetNoResponse(u32 channel) } } -static void ChangeDeviceCallback(u64 user_data, s64 cycles_late) +static void ChangeDeviceCallback(Core::System& system, u64 user_data, s64 cycles_late) { // The purpose of this callback is to simply re-enable device changes. - auto& state = Core::System::GetInstance().GetSerialInterfaceState().GetData(); + auto& state = system.GetSerialInterfaceState().GetData(); state.channel[user_data].has_recent_device_change = false; } @@ -295,9 +295,9 @@ constexpr s32 ConvertSILengthField(u32 field) return ((field - 1) & SI_XFER_LENGTH_MASK) + 1; } -static void RunSIBuffer(u64 user_data, s64 cycles_late) +static void RunSIBuffer(Core::System& system, u64 user_data, s64 cycles_late) { - auto& state = Core::System::GetInstance().GetSerialInterfaceState().GetData(); + auto& state = system.GetSerialInterfaceState().GetData(); if (state.com_csr.TSTART) { const s32 request_length = ConvertSILengthField(state.com_csr.OUTLNGTH); @@ -380,9 +380,9 @@ void DoState(PointerWrap& p) } template -static void DeviceEventCallback(u64 userdata, s64 cyclesLate) +static void DeviceEventCallback(Core::System& system, u64 userdata, s64 cyclesLate) { - auto& state = Core::System::GetInstance().GetSerialInterfaceState().GetData(); + auto& state = system.GetSerialInterfaceState().GetData(); state.channel[device_number].device->OnEvent(userdata, cyclesLate); } @@ -555,7 +555,8 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base) mmio->Register(base | SI_COM_CSR, MMIO::DirectRead(&state.com_csr.hex), MMIO::ComplexWrite([](u32, u32 val) { - auto& state = Core::System::GetInstance().GetSerialInterfaceState().GetData(); + auto& system = Core::System::GetInstance(); + auto& state = system.GetSerialInterfaceState().GetData(); const USIComCSR tmp_com_csr(val); state.com_csr.CHANNEL = tmp_com_csr.CHANNEL.Value(); @@ -575,7 +576,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base) if (state.com_csr.TSTART) CoreTiming::RemoveEvent(state.event_type_tranfer_pending); state.com_csr.TSTART = 1; - RunSIBuffer(0, 0); + RunSIBuffer(system, 0, 0); } if (!state.com_csr.TSTART) diff --git a/Source/Core/Core/HW/SystemTimers.cpp b/Source/Core/Core/HW/SystemTimers.cpp index 6a41362b82..eab06b28d7 100644 --- a/Source/Core/Core/HW/SystemTimers.cpp +++ b/Source/Core/Core/HW/SystemTimers.cpp @@ -100,7 +100,7 @@ std::mutex s_emu_to_real_time_mutex; u64 s_time_spent_sleeping; // DSP/CPU timeslicing. -void DSPCallback(u64 userdata, s64 cyclesLate) +void DSPCallback(Core::System& system, u64 userdata, s64 cyclesLate) { // splits up the cycle budget in case lle is used // for hle, just gives all of the slice to hle @@ -115,13 +115,13 @@ int GetAudioDMACallbackPeriod() (Mixer::FIXED_SAMPLE_RATE_DIVIDEND * 4 / 32); } -void AudioDMACallback(u64 userdata, s64 cyclesLate) +void AudioDMACallback(Core::System& system, u64 userdata, s64 cyclesLate) { DSP::UpdateAudioDMA(); // Push audio to speakers. CoreTiming::ScheduleEvent(GetAudioDMACallbackPeriod() - cyclesLate, et_AudioDMA); } -void IPC_HLE_UpdateCallback(u64 userdata, s64 cyclesLate) +void IPC_HLE_UpdateCallback(Core::System& system, u64 userdata, s64 cyclesLate) { if (SConfig::GetInstance().bWii) { @@ -130,19 +130,19 @@ void IPC_HLE_UpdateCallback(u64 userdata, s64 cyclesLate) } } -void VICallback(u64 userdata, s64 cyclesLate) +void VICallback(Core::System& system, u64 userdata, s64 cyclesLate) { VideoInterface::Update(CoreTiming::GetTicks() - cyclesLate); CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerHalfLine() - cyclesLate, et_VI); } -void DecrementerCallback(u64 userdata, s64 cyclesLate) +void DecrementerCallback(Core::System& system, u64 userdata, s64 cyclesLate) { PowerPC::ppcState.spr[SPR_DEC] = 0xFFFFFFFF; PowerPC::ppcState.Exceptions |= EXCEPTION_DECREMENTER; } -void PatchEngineCallback(u64 userdata, s64 cycles_late) +void PatchEngineCallback(Core::System& system, u64 userdata, s64 cycles_late) { // We have 2 periods, a 1000 cycle error period and the VI period. // We have to carefully combine these together so that we stay on the VI period without drifting. @@ -167,7 +167,7 @@ void PatchEngineCallback(u64 userdata, s64 cycles_late) CoreTiming::ScheduleEvent(next_schedule, et_PatchEngine, cycles_pruned); } -void ThrottleCallback(u64 deadline, s64 cyclesLate) +void ThrottleCallback(Core::System& system, u64 deadline, s64 cyclesLate) { // Allow the GPU thread to sleep. Setting this flag here limits the wakeups to 1 kHz. Fifo::GpuMaySleep(); diff --git a/Source/Core/Core/HW/WII_IPC.cpp b/Source/Core/Core/HW/WII_IPC.cpp index 46bb74a5d4..aac45c68a1 100644 --- a/Source/Core/Core/HW/WII_IPC.cpp +++ b/Source/Core/Core/HW/WII_IPC.cpp @@ -112,7 +112,7 @@ Common::Flags g_gpio_out; static u32 resets; static CoreTiming::EventType* updateInterrupts; -static void UpdateInterrupts(u64 = 0, s64 cyclesLate = 0); +static void UpdateInterrupts(Core::System& system, u64 userdata, s64 cyclesLate); void DoState(PointerWrap& p) { @@ -283,7 +283,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base) mmio->Register(base | UNK_1D0, MMIO::Constant(0), MMIO::Nop()); } -static void UpdateInterrupts(u64 userdata, s64 cyclesLate) +static void UpdateInterrupts(Core::System& system, u64 userdata, s64 cyclesLate) { if ((ctrl.Y1 & ctrl.IY1) || (ctrl.Y2 & ctrl.IY2)) { diff --git a/Source/Core/Core/IOS/DI/DI.cpp b/Source/Core/Core/IOS/DI/DI.cpp index 5632cc4bee..c15a015ee8 100644 --- a/Source/Core/Core/IOS/DI/DI.cpp +++ b/Source/Core/Core/IOS/DI/DI.cpp @@ -624,7 +624,7 @@ void DIDevice::InterruptFromDVDInterface(DVDInterface::DIInterruptType interrupt } } -void DIDevice::FinishDICommandCallback(u64 userdata, s64 ticksbehind) +void DIDevice::FinishDICommandCallback(Core::System& system, u64 userdata, s64 ticksbehind) { const DIResult result = static_cast(userdata); diff --git a/Source/Core/Core/IOS/DI/DI.h b/Source/Core/Core/IOS/DI/DI.h index 43645be356..f2d5307f68 100644 --- a/Source/Core/Core/IOS/DI/DI.h +++ b/Source/Core/Core/IOS/DI/DI.h @@ -19,6 +19,10 @@ namespace DVDInterface { enum class DIInterruptType : int; } +namespace Core +{ +class System; +} namespace CoreTiming { struct EventType; @@ -128,7 +132,7 @@ private: void ChangePartition(const DiscIO::Partition partition); void InitializeIfFirstTime(); void ResetDIRegisters(); - static void FinishDICommandCallback(u64 userdata, s64 ticksbehind); + static void FinishDICommandCallback(Core::System& system, u64 userdata, s64 ticksbehind); void FinishDICommand(DIResult result); static CoreTiming::EventType* s_finish_executing_di_command; diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index b8c2a4a115..2424a8c87d 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -115,13 +115,15 @@ ESDevice::ESDevice(Kernel& ios, const std::string& device_name) : Device(ios, de void ESDevice::InitializeEmulationState() { s_finish_init_event = CoreTiming::RegisterEvent( - "IOS-ESFinishInit", [](u64, s64) { GetIOS()->GetES()->FinishInit(); }); - s_reload_ios_for_ppc_launch_event = - CoreTiming::RegisterEvent("IOS-ESReloadIOSForPPCLaunch", [](u64 ios_id, s64) { + "IOS-ESFinishInit", [](Core::System& system, u64, s64) { GetIOS()->GetES()->FinishInit(); }); + s_reload_ios_for_ppc_launch_event = CoreTiming::RegisterEvent( + "IOS-ESReloadIOSForPPCLaunch", [](Core::System& system, u64 ios_id, s64) { GetIOS()->GetES()->LaunchTitle(ios_id, HangPPC::Yes); }); - s_bootstrap_ppc_for_launch_event = CoreTiming::RegisterEvent( - "IOS-ESBootstrapPPCForLaunch", [](u64, s64) { GetIOS()->GetES()->BootstrapPPC(); }); + s_bootstrap_ppc_for_launch_event = + CoreTiming::RegisterEvent("IOS-ESBootstrapPPCForLaunch", [](Core::System& system, u64, s64) { + GetIOS()->GetES()->BootstrapPPC(); + }); } void ESDevice::FinalizeEmulationState() diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index 25808585f0..9d57228394 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -876,7 +876,7 @@ IOSC& Kernel::GetIOSC() return m_iosc; } -static void FinishPPCBootstrap(u64 userdata, s64 cycles_late) +static void FinishPPCBootstrap(Core::System& system, u64 userdata, s64 cycles_late) { // See Kernel::BootstrapPPC const bool is_ancast = userdata == 1; @@ -891,18 +891,20 @@ static void FinishPPCBootstrap(u64 userdata, s64 cycles_late) void Init() { - s_event_enqueue = CoreTiming::RegisterEvent("IPCEvent", [](u64 userdata, s64) { - if (s_ios) - s_ios->HandleIPCEvent(userdata); - }); + s_event_enqueue = + CoreTiming::RegisterEvent("IPCEvent", [](Core::System& system, u64 userdata, s64) { + if (s_ios) + s_ios->HandleIPCEvent(userdata); + }); ESDevice::InitializeEmulationState(); s_event_finish_ppc_bootstrap = CoreTiming::RegisterEvent("IOSFinishPPCBootstrap", FinishPPCBootstrap); - s_event_finish_ios_boot = CoreTiming::RegisterEvent( - "IOSFinishIOSBoot", [](u64 ios_title_id, s64) { FinishIOSBoot(ios_title_id); }); + s_event_finish_ios_boot = + CoreTiming::RegisterEvent("IOSFinishIOSBoot", [](Core::System& system, u64 ios_title_id, + s64) { FinishIOSBoot(ios_title_id); }); DIDevice::s_finish_executing_di_command = CoreTiming::RegisterEvent("FinishDICommand", DIDevice::FinishDICommandCallback); diff --git a/Source/Core/Core/PowerPC/GDBStub.cpp b/Source/Core/Core/PowerPC/GDBStub.cpp index 2fe39b75fd..775f189bb0 100644 --- a/Source/Core/Core/PowerPC/GDBStub.cpp +++ b/Source/Core/Core/PowerPC/GDBStub.cpp @@ -124,7 +124,7 @@ static void Hex2mem(u8* dst, u8* src, u32 len) } } -static void UpdateCallback(u64 userdata, s64 cycles_late) +static void UpdateCallback(Core::System& system, u64 userdata, s64 cycles_late) { ProcessCommands(false); if (IsActive()) diff --git a/Source/Core/Core/PowerPC/PowerPC.cpp b/Source/Core/Core/PowerPC/PowerPC.cpp index d25deca939..10de0f9c77 100644 --- a/Source/Core/Core/PowerPC/PowerPC.cpp +++ b/Source/Core/Core/PowerPC/PowerPC.cpp @@ -68,7 +68,7 @@ void PairedSingle::SetPS1(double value) ps1 = Common::BitCast(value); } -static void InvalidateCacheThreadSafe(u64 userdata, s64 cyclesLate) +static void InvalidateCacheThreadSafe(Core::System& system, u64 userdata, s64 cyclesLate) { ppcState.iCache.Invalidate(static_cast(userdata)); } diff --git a/Source/Core/VideoCommon/CommandProcessor.cpp b/Source/Core/VideoCommon/CommandProcessor.cpp index 0ab1eb7aee..a5e5591276 100644 --- a/Source/Core/VideoCommon/CommandProcessor.cpp +++ b/Source/Core/VideoCommon/CommandProcessor.cpp @@ -49,7 +49,7 @@ static bool IsOnThread() return Core::System::GetInstance().IsDualCoreMode(); } -static void UpdateInterrupts_Wrapper(u64 userdata, s64 cyclesLate) +static void UpdateInterrupts_Wrapper(Core::System& system, u64 userdata, s64 cyclesLate) { UpdateInterrupts(userdata); } diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index faea454147..a69a83b00f 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -595,12 +595,12 @@ static int WaitForGpuThread(int ticks) return GPU_TIME_SLOT_SIZE; } -static void SyncGPUCallback(u64 ticks, s64 cyclesLate) +static void SyncGPUCallback(Core::System& system, u64 ticks, s64 cyclesLate) { ticks += cyclesLate; int next = -1; - if (!Core::System::GetInstance().IsDualCoreMode() || s_use_deterministic_gpu_thread) + if (!system.IsDualCoreMode() || s_use_deterministic_gpu_thread) { next = RunGpuOnCpu((int)ticks); } diff --git a/Source/Core/VideoCommon/PixelEngine.cpp b/Source/Core/VideoCommon/PixelEngine.cpp index d2cd5ef332..c110ffa284 100644 --- a/Source/Core/VideoCommon/PixelEngine.cpp +++ b/Source/Core/VideoCommon/PixelEngine.cpp @@ -182,7 +182,7 @@ void DoState(PointerWrap& p) } static void UpdateInterrupts(); -static void SetTokenFinish_OnMainThread(u64 userdata, s64 cyclesLate); +static void SetTokenFinish_OnMainThread(Core::System& system, u64 userdata, s64 cyclesLate); void Init() { @@ -297,7 +297,7 @@ static void UpdateInterrupts() s_signal_finish_interrupt && m_Control.pe_finish_enable); } -static void SetTokenFinish_OnMainThread(u64 userdata, s64 cyclesLate) +static void SetTokenFinish_OnMainThread(Core::System& system, u64 userdata, s64 cyclesLate) { std::unique_lock lk(s_token_finish_mutex); s_event_raised = false; diff --git a/Source/UnitTests/Core/CoreTimingTest.cpp b/Source/UnitTests/Core/CoreTimingTest.cpp index b08919679d..b8ca8cc01b 100644 --- a/Source/UnitTests/Core/CoreTimingTest.cpp +++ b/Source/UnitTests/Core/CoreTimingTest.cpp @@ -25,7 +25,7 @@ static u64 s_expected_callback = 0; static s64 s_lateness = 0; template -void CallbackTemplate(u64 userdata, s64 lateness) +void CallbackTemplate(Core::System& system, u64 userdata, s64 lateness) { static_assert(IDX < CB_IDS.size(), "IDX out of range"); s_callbacks_ran_flags.set(IDX); @@ -121,7 +121,7 @@ namespace SharedSlotTest static unsigned int s_counter = 0; template -void FifoCallback(u64 userdata, s64 lateness) +void FifoCallback(Core::System& system, u64 userdata, s64 lateness) { static_assert(ID < CB_IDS.size(), "ID out of range"); s_callbacks_ran_flags.set(ID); @@ -186,7 +186,7 @@ namespace ChainSchedulingTest { static int s_reschedules = 0; -static void RescheduleCallback(u64 userdata, s64 lateness) +static void RescheduleCallback(Core::System& system, u64 userdata, s64 lateness) { --s_reschedules; EXPECT_TRUE(s_reschedules >= 0); @@ -241,7 +241,7 @@ namespace ScheduleIntoPastTest { static CoreTiming::EventType* s_cb_next = nullptr; -static void ChainCallback(u64 userdata, s64 lateness) +static void ChainCallback(Core::System& system, u64 userdata, s64 lateness) { EXPECT_EQ(CB_IDS[0] + 1, userdata); EXPECT_EQ(0, lateness);