mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-11-04 07:38:47 +00:00 
			
		
		
		
	Memory: move PageTable functions into class
This commit is contained in:
		
							parent
							
								
									b199b7ada9
								
							
						
					
					
						commit
						8c618c3fc3
					
				
					 8 changed files with 19 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -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>();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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(¤t_thread->owner_process->vm_manager.page_table);
 | 
			
		||||
            kernel.SetCurrentProcess(current_thread->owner_process);
 | 
			
		||||
            kernel.memory.SetCurrentPageTable(
 | 
			
		||||
                ¤t_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); });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue