citra-emu
/
citra-canary
Archived
1
0
Fork 0

kernel/thread: replace usage of Core::CPU()

This commit is contained in:
Weiyi Wang 2019-02-01 11:23:39 -05:00
parent b9f6bd9278
commit 276ca88c9e
3 changed files with 15 additions and 4 deletions

View File

@ -187,6 +187,8 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) {
cpu_core = std::make_unique<ARM_DynCom>(*this, USER32MODE); cpu_core = std::make_unique<ARM_DynCom>(*this, USER32MODE);
} }
kernel->GetThreadManager().SetCPU(*cpu_core);
if (Settings::values.enable_dsp_lle) { if (Settings::values.enable_dsp_lle) {
dsp_core = std::make_unique<AudioCore::DspLle>(*memory, dsp_core = std::make_unique<AudioCore::DspLle>(*memory,
Settings::values.enable_dsp_lle_multithread); Settings::values.enable_dsp_lle_multithread);

View File

@ -38,7 +38,7 @@ u32 ThreadManager::NewThreadId() {
} }
Thread::Thread(KernelSystem& kernel) Thread::Thread(KernelSystem& kernel)
: WaitObject(kernel), context(Core::CPU().NewContext()), : WaitObject(kernel), context(kernel.GetThreadManager().NewContext()),
thread_manager(kernel.GetThreadManager()) {} thread_manager(kernel.GetThreadManager()) {}
Thread::~Thread() {} Thread::~Thread() {}
@ -86,7 +86,7 @@ void ThreadManager::SwitchContext(Thread* new_thread) {
// Save context for previous thread // Save context for previous thread
if (previous_thread) { if (previous_thread) {
previous_thread->last_running_ticks = timing.GetTicks(); previous_thread->last_running_ticks = timing.GetTicks();
Core::CPU().SaveContext(previous_thread->context); cpu->SaveContext(previous_thread->context);
if (previous_thread->status == ThreadStatus::Running) { if (previous_thread->status == ThreadStatus::Running) {
// This is only the case when a reschedule is triggered without the current thread // This is only the case when a reschedule is triggered without the current thread
@ -117,8 +117,8 @@ void ThreadManager::SwitchContext(Thread* new_thread) {
&current_thread->owner_process->vm_manager.page_table); &current_thread->owner_process->vm_manager.page_table);
} }
Core::CPU().LoadContext(new_thread->context); cpu->LoadContext(new_thread->context);
Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress()); cpu->SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress());
} else { } else {
current_thread = nullptr; current_thread = nullptr;
// Note: We do not reset the current process and current page table when idling because // Note: We do not reset the current process and current page table when idling because

View File

@ -101,6 +101,14 @@ public:
*/ */
const std::vector<SharedPtr<Thread>>& GetThreadList(); const std::vector<SharedPtr<Thread>>& GetThreadList();
void SetCPU(ARM_Interface& cpu) {
this->cpu = &cpu;
}
std::unique_ptr<ARM_Interface::ThreadContext> NewContext() {
return cpu->NewContext();
}
private: private:
/** /**
* Switches the CPU's active thread context to that of the specified thread * Switches the CPU's active thread context to that of the specified thread
@ -122,6 +130,7 @@ private:
void ThreadWakeupCallback(u64 thread_id, s64 cycles_late); void ThreadWakeupCallback(u64 thread_id, s64 cycles_late);
Kernel::KernelSystem& kernel; Kernel::KernelSystem& kernel;
ARM_Interface* cpu;
u32 next_thread_id = 1; u32 next_thread_id = 1;
SharedPtr<Thread> current_thread; SharedPtr<Thread> current_thread;