core: refactor emulated cpu core activation

This commit is contained in:
Liam 2023-11-28 14:30:39 -05:00
parent 90e87c40e8
commit 45c87c7e6e
47 changed files with 2984 additions and 3332 deletions

View file

@ -494,12 +494,7 @@ void KScheduler::ScheduleImplFiber() {
}
void KScheduler::Unload(KThread* thread) {
auto& cpu_core = m_kernel.System().ArmInterface(m_core_id);
cpu_core.SaveContext(thread->GetContext32());
cpu_core.SaveContext(thread->GetContext64());
// Save the TPIDR_EL0 system register in case it was modified.
thread->SetTpidrEl0(cpu_core.GetTPIDR_EL0());
cpu_core.ClearExclusiveState();
m_kernel.PhysicalCore(m_core_id).SaveContext(thread);
// Check if the thread is terminated by checking the DPC flags.
if ((thread->GetStackParameters().dpc_flags & static_cast<u32>(DpcFlag::Terminated)) == 0) {
@ -509,14 +504,7 @@ void KScheduler::Unload(KThread* thread) {
}
void KScheduler::Reload(KThread* thread) {
auto& cpu_core = m_kernel.System().ArmInterface(m_core_id);
auto* process = thread->GetOwnerProcess();
cpu_core.LoadContext(thread->GetContext32());
cpu_core.LoadContext(thread->GetContext64());
cpu_core.SetTlsAddress(GetInteger(thread->GetTlsAddress()));
cpu_core.SetTPIDR_EL0(thread->GetTpidrEl0());
cpu_core.LoadWatchpointArray(process ? &process->GetWatchpoints() : nullptr);
cpu_core.ClearExclusiveState();
m_kernel.PhysicalCore(m_core_id).LoadContext(thread);
}
void KScheduler::ClearPreviousThread(KernelCore& kernel, KThread* thread) {