Merge pull request #4799 from bamsbamx/pr-separate-cpu-mem
kernel: handle all page table changes internally when switching processes
This commit is contained in:
commit
508fa94e5d
8 changed files with 27 additions and 22 deletions
|
@ -47,7 +47,20 @@ std::shared_ptr<Process> KernelSystem::GetCurrentProcess() const {
|
|||
}
|
||||
|
||||
void KernelSystem::SetCurrentProcess(std::shared_ptr<Process> process) {
|
||||
current_process = std::move(process);
|
||||
current_process = process;
|
||||
SetCurrentMemoryPageTable(&process->vm_manager.page_table);
|
||||
}
|
||||
|
||||
void KernelSystem::SetCurrentMemoryPageTable(Memory::PageTable* page_table) {
|
||||
memory.SetCurrentPageTable(page_table);
|
||||
if (current_cpu != nullptr) {
|
||||
current_cpu->PageTableChanged(); // notify the CPU the page table in memory has changed
|
||||
}
|
||||
}
|
||||
|
||||
void KernelSystem::SetCPU(std::shared_ptr<ARM_Interface> cpu) {
|
||||
current_cpu = cpu;
|
||||
thread_manager->SetCPU(*cpu);
|
||||
}
|
||||
|
||||
ThreadManager& KernelSystem::GetThreadManager() {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "common/common_types.h"
|
||||
#include "core/hle/kernel/memory.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
namespace ConfigMem {
|
||||
class Handler;
|
||||
|
@ -206,6 +207,10 @@ public:
|
|||
std::shared_ptr<Process> GetCurrentProcess() const;
|
||||
void SetCurrentProcess(std::shared_ptr<Process> process);
|
||||
|
||||
void SetCurrentMemoryPageTable(Memory::PageTable* page_table);
|
||||
|
||||
void SetCPU(std::shared_ptr<ARM_Interface> cpu);
|
||||
|
||||
ThreadManager& GetThreadManager();
|
||||
const ThreadManager& GetThreadManager() const;
|
||||
|
||||
|
@ -233,6 +238,8 @@ public:
|
|||
/// Map of named ports managed by the kernel, which can be retrieved using the ConnectToPort
|
||||
std::unordered_map<std::string, std::shared_ptr<ClientPort>> named_ports;
|
||||
|
||||
std::shared_ptr<ARM_Interface> current_cpu;
|
||||
|
||||
Memory::MemorySystem& memory;
|
||||
|
||||
Core::Timing& timing;
|
||||
|
|
|
@ -112,8 +112,6 @@ void ThreadManager::SwitchContext(Thread* new_thread) {
|
|||
|
||||
if (previous_process.get() != current_thread->owner_process) {
|
||||
kernel.SetCurrentProcess(SharedFrom(current_thread->owner_process));
|
||||
kernel.memory.SetCurrentPageTable(
|
||||
¤t_thread->owner_process->vm_manager.page_table);
|
||||
}
|
||||
|
||||
cpu->LoadContext(new_thread->context);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue