@@ -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();
@@ -112,7 +112,7 @@ Common::Flags<GPIO> 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<u32>(0), MMIO::Nop<u32>());
}

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

@@ -19,6 +19,10 @@ namespace DVDInterface
{
enum class DIInterruptType : int;
}
namespace Core
{
class System;
}
namespace CoreTiming
{
struct EventType;
@@ -128,7 +132,7 @@ class DIDevice : public Device
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;
@@ -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()
@@ -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);
@@ -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())
@@ -68,7 +68,7 @@ void PairedSingle::SetPS1(double value)
ps1 = Common::BitCast<u64>(value);
}

static void InvalidateCacheThreadSafe(u64 userdata, s64 cyclesLate)
static void InvalidateCacheThreadSafe(Core::System& system, u64 userdata, s64 cyclesLate)
{
ppcState.iCache.Invalidate(static_cast<u32>(userdata));
}
@@ -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);
}
@@ -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);
}
@@ -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<std::mutex> lk(s_token_finish_mutex);
s_event_raised = false;
@@ -25,7 +25,7 @@ static u64 s_expected_callback = 0;
static s64 s_lateness = 0;

template <unsigned int IDX>
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 <unsigned int ID>
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);