Memory: move PageTable functions into class

This commit is contained in:
Weiyi Wang 2018-11-20 23:50:00 -05:00
parent b199b7ada9
commit 8c618c3fc3
8 changed files with 19 additions and 16 deletions

View file

@ -20,7 +20,7 @@ KernelSystem::KernelSystem(Memory::MemorySystem& memory, u32 system_mode) : memo
MemoryInit(system_mode);
resource_limits = std::make_unique<ResourceLimitList>(*this);
thread_manager = std::make_unique<ThreadManager>();
thread_manager = std::make_unique<ThreadManager>(*this);
timer_manager = std::make_unique<TimerManager>();
}

View file

@ -104,7 +104,7 @@ void ThreadManager::SwitchContext(Thread* new_thread) {
// Cancel any outstanding wakeup events for this thread
timing.UnscheduleEvent(ThreadWakeupEventType, new_thread->thread_id);
auto previous_process = Core::System::GetInstance().Kernel().GetCurrentProcess();
auto previous_process = kernel.GetCurrentProcess();
current_thread = new_thread;
@ -112,8 +112,9 @@ void ThreadManager::SwitchContext(Thread* new_thread) {
new_thread->status = ThreadStatus::Running;
if (previous_process != current_thread->owner_process) {
Core::System::GetInstance().Kernel().SetCurrentProcess(current_thread->owner_process);
SetCurrentPageTable(&current_thread->owner_process->vm_manager.page_table);
kernel.SetCurrentProcess(current_thread->owner_process);
kernel.memory.SetCurrentPageTable(
&current_thread->owner_process->vm_manager.page_table);
}
Core::CPU().LoadContext(new_thread->context);
@ -460,7 +461,7 @@ VAddr Thread::GetCommandBufferAddress() const {
return GetTLSAddress() + CommandHeaderOffset;
}
ThreadManager::ThreadManager() {
ThreadManager::ThreadManager(Kernel::KernelSystem& kernel) : kernel(kernel) {
ThreadWakeupEventType = Core::System::GetInstance().CoreTiming().RegisterEvent(
"ThreadWakeupCallback",
[this](u64 thread_id, s64 cycle_late) { ThreadWakeupCallback(thread_id, cycle_late); });

View file

@ -57,7 +57,7 @@ enum class ThreadWakeupReason {
class ThreadManager {
public:
ThreadManager();
explicit ThreadManager(Kernel::KernelSystem& kernel);
~ThreadManager();
/**
@ -121,6 +121,8 @@ private:
*/
void ThreadWakeupCallback(u64 thread_id, s64 cycles_late);
Kernel::KernelSystem& kernel;
u32 next_thread_id = 1;
SharedPtr<Thread> current_thread;
Common::ThreadQueueList<Thread*, ThreadPrioLowest + 1> ready_queue;