mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-09-15 00:55:33 +00:00
memory: Add GetCurrentPageTable/SetCurrentPageTable
Don't expose Memory::current_page_table as a global.
This commit is contained in:
parent
93930a966f
commit
c02bbb7030
@ -178,16 +178,13 @@ static void SwitchContext(Thread* new_thread) {
|
|||||||
ready_queue.remove(new_thread->current_priority, new_thread);
|
ready_queue.remove(new_thread->current_priority, new_thread);
|
||||||
new_thread->status = THREADSTATUS_RUNNING;
|
new_thread->status = THREADSTATUS_RUNNING;
|
||||||
|
|
||||||
Core::CPU().LoadContext(new_thread->context);
|
|
||||||
Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress());
|
|
||||||
|
|
||||||
if (previous_process != current_thread->owner_process) {
|
if (previous_process != current_thread->owner_process) {
|
||||||
Kernel::g_current_process = current_thread->owner_process;
|
Kernel::g_current_process = current_thread->owner_process;
|
||||||
Memory::current_page_table = &Kernel::g_current_process->vm_manager.page_table;
|
SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table);
|
||||||
// We have switched processes and thus, page tables, clear the instruction cache so we
|
|
||||||
// don't keep stale data from the previous process.
|
|
||||||
Core::CPU().ClearInstructionCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Core::CPU().LoadContext(new_thread->context);
|
||||||
|
Core::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
|
||||||
|
@ -270,7 +270,7 @@ ResultStatus AppLoader_THREEDSX::Load() {
|
|||||||
Kernel::g_current_process = Kernel::Process::Create(std::move(codeset));
|
Kernel::g_current_process = Kernel::Process::Create(std::move(codeset));
|
||||||
Kernel::g_current_process->svc_access_mask.set();
|
Kernel::g_current_process->svc_access_mask.set();
|
||||||
Kernel::g_current_process->address_mappings = default_address_mappings;
|
Kernel::g_current_process->address_mappings = default_address_mappings;
|
||||||
Memory::current_page_table = &Kernel::g_current_process->vm_manager.page_table;
|
Memory::SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table);
|
||||||
|
|
||||||
// Attach the default resource limit (APPLICATION) to the process
|
// Attach the default resource limit (APPLICATION) to the process
|
||||||
Kernel::g_current_process->resource_limit =
|
Kernel::g_current_process->resource_limit =
|
||||||
|
@ -397,7 +397,7 @@ ResultStatus AppLoader_ELF::Load() {
|
|||||||
Kernel::g_current_process = Kernel::Process::Create(std::move(codeset));
|
Kernel::g_current_process = Kernel::Process::Create(std::move(codeset));
|
||||||
Kernel::g_current_process->svc_access_mask.set();
|
Kernel::g_current_process->svc_access_mask.set();
|
||||||
Kernel::g_current_process->address_mappings = default_address_mappings;
|
Kernel::g_current_process->address_mappings = default_address_mappings;
|
||||||
Memory::current_page_table = &Kernel::g_current_process->vm_manager.page_table;
|
Memory::SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table);
|
||||||
|
|
||||||
// Attach the default resource limit (APPLICATION) to the process
|
// Attach the default resource limit (APPLICATION) to the process
|
||||||
Kernel::g_current_process->resource_limit =
|
Kernel::g_current_process->resource_limit =
|
||||||
|
@ -172,7 +172,7 @@ ResultStatus AppLoader_NCCH::LoadExec() {
|
|||||||
codeset->memory = std::make_shared<std::vector<u8>>(std::move(code));
|
codeset->memory = std::make_shared<std::vector<u8>>(std::move(code));
|
||||||
|
|
||||||
Kernel::g_current_process = Kernel::Process::Create(std::move(codeset));
|
Kernel::g_current_process = Kernel::Process::Create(std::move(codeset));
|
||||||
Memory::current_page_table = &Kernel::g_current_process->vm_manager.page_table;
|
Memory::SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table);
|
||||||
|
|
||||||
// Attach a resource limit to the process based on the resource limit category
|
// Attach a resource limit to the process based on the resource limit category
|
||||||
Kernel::g_current_process->resource_limit =
|
Kernel::g_current_process->resource_limit =
|
||||||
|
@ -22,12 +22,20 @@ namespace Memory {
|
|||||||
static std::array<u8, Memory::VRAM_SIZE> vram;
|
static std::array<u8, Memory::VRAM_SIZE> vram;
|
||||||
static std::array<u8, Memory::N3DS_EXTRA_RAM_SIZE> n3ds_extra_ram;
|
static std::array<u8, Memory::N3DS_EXTRA_RAM_SIZE> n3ds_extra_ram;
|
||||||
|
|
||||||
PageTable* current_page_table = nullptr;
|
static PageTable* current_page_table = nullptr;
|
||||||
|
|
||||||
std::array<u8*, PAGE_TABLE_NUM_ENTRIES>* GetCurrentPageTablePointers() {
|
std::array<u8*, PAGE_TABLE_NUM_ENTRIES>* GetCurrentPageTablePointers() {
|
||||||
return ¤t_page_table->pointers;
|
return ¤t_page_table->pointers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetCurrentPageTable(PageTable* page_table) {
|
||||||
|
current_page_table = page_table;
|
||||||
|
}
|
||||||
|
|
||||||
|
PageTable* GetCurrentPageTable() {
|
||||||
|
return current_page_table;
|
||||||
|
}
|
||||||
|
|
||||||
static void MapPages(PageTable& page_table, u32 base, u32 size, u8* memory, PageType type) {
|
static void MapPages(PageTable& page_table, u32 base, u32 size, u8* memory, PageType type) {
|
||||||
LOG_DEBUG(HW_Memory, "Mapping %p onto %08X-%08X", memory, base * PAGE_SIZE,
|
LOG_DEBUG(HW_Memory, "Mapping %p onto %08X-%08X", memory, base * PAGE_SIZE,
|
||||||
(base + size) * PAGE_SIZE);
|
(base + size) * PAGE_SIZE);
|
||||||
|
@ -182,7 +182,8 @@ enum : VAddr {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Currently active page table
|
/// Currently active page table
|
||||||
extern PageTable* current_page_table;
|
void SetCurrentPageTable(PageTable* page_table);
|
||||||
|
PageTable* GetCurrentPageTable();
|
||||||
|
|
||||||
bool IsValidVirtualAddress(const VAddr addr);
|
bool IsValidVirtualAddress(const VAddr addr);
|
||||||
bool IsValidPhysicalAddress(const PAddr addr);
|
bool IsValidPhysicalAddress(const PAddr addr);
|
||||||
|
@ -21,7 +21,7 @@ TestEnvironment::TestEnvironment(bool mutable_memory_)
|
|||||||
Memory::MapIoRegion(page_table, 0x00000000, 0x80000000, test_memory);
|
Memory::MapIoRegion(page_table, 0x00000000, 0x80000000, test_memory);
|
||||||
Memory::MapIoRegion(page_table, 0x80000000, 0x80000000, test_memory);
|
Memory::MapIoRegion(page_table, 0x80000000, 0x80000000, test_memory);
|
||||||
|
|
||||||
Memory::current_page_table = &page_table;
|
Memory::SetCurrentPageTable(&page_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestEnvironment::~TestEnvironment() {
|
TestEnvironment::~TestEnvironment() {
|
||||||
|
Loading…
Reference in New Issue
Block a user