mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-08 16:49:59 +00:00
core/memory; Migrate over SetCurrentPageTable() to the Memory class
Now that literally every other API function is converted over to the Memory class, we can just move the file-local page table into the Memory implementation class, finally getting rid of global state within the memory code.
This commit is contained in:
parent
50a518be69
commit
e7e939104b
3 changed files with 34 additions and 26 deletions
|
@ -154,6 +154,16 @@ struct KernelCore::Impl {
|
||||||
system.CoreTiming().ScheduleEvent(time_interval, preemption_event);
|
system.CoreTiming().ScheduleEvent(time_interval, preemption_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MakeCurrentProcess(Process* process) {
|
||||||
|
current_process = process;
|
||||||
|
|
||||||
|
if (process == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
system.Memory().SetCurrentPageTable(*process);
|
||||||
|
}
|
||||||
|
|
||||||
std::atomic<u32> next_object_id{0};
|
std::atomic<u32> next_object_id{0};
|
||||||
std::atomic<u64> next_kernel_process_id{Process::InitialKIPIDMin};
|
std::atomic<u64> next_kernel_process_id{Process::InitialKIPIDMin};
|
||||||
std::atomic<u64> next_user_process_id{Process::ProcessIDMin};
|
std::atomic<u64> next_user_process_id{Process::ProcessIDMin};
|
||||||
|
@ -208,13 +218,7 @@ void KernelCore::AppendNewProcess(std::shared_ptr<Process> process) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void KernelCore::MakeCurrentProcess(Process* process) {
|
void KernelCore::MakeCurrentProcess(Process* process) {
|
||||||
impl->current_process = process;
|
impl->MakeCurrentProcess(process);
|
||||||
|
|
||||||
if (process == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Memory::SetCurrentPageTable(*process);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Process* KernelCore::CurrentProcess() {
|
Process* KernelCore::CurrentProcess() {
|
||||||
|
|
|
@ -20,9 +20,6 @@
|
||||||
#include "video_core/gpu.h"
|
#include "video_core/gpu.h"
|
||||||
|
|
||||||
namespace Memory {
|
namespace Memory {
|
||||||
namespace {
|
|
||||||
Common::PageTable* current_page_table = nullptr;
|
|
||||||
} // Anonymous namespace
|
|
||||||
|
|
||||||
// Implementation class used to keep the specifics of the memory subsystem hidden
|
// Implementation class used to keep the specifics of the memory subsystem hidden
|
||||||
// from outside classes. This also allows modification to the internals of the memory
|
// from outside classes. This also allows modification to the internals of the memory
|
||||||
|
@ -30,6 +27,17 @@ Common::PageTable* current_page_table = nullptr;
|
||||||
struct Memory::Impl {
|
struct Memory::Impl {
|
||||||
explicit Impl(Core::System& system_) : system{system_} {}
|
explicit Impl(Core::System& system_) : system{system_} {}
|
||||||
|
|
||||||
|
void SetCurrentPageTable(Kernel::Process& process) {
|
||||||
|
current_page_table = &process.VMManager().page_table;
|
||||||
|
|
||||||
|
const std::size_t address_space_width = process.VMManager().GetAddressSpaceWidth();
|
||||||
|
|
||||||
|
system.ArmInterface(0).PageTableChanged(*current_page_table, address_space_width);
|
||||||
|
system.ArmInterface(1).PageTableChanged(*current_page_table, address_space_width);
|
||||||
|
system.ArmInterface(2).PageTableChanged(*current_page_table, address_space_width);
|
||||||
|
system.ArmInterface(3).PageTableChanged(*current_page_table, address_space_width);
|
||||||
|
}
|
||||||
|
|
||||||
void MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target) {
|
void MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target) {
|
||||||
ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size);
|
ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size);
|
||||||
ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base);
|
ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base);
|
||||||
|
@ -575,12 +583,17 @@ struct Memory::Impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Common::PageTable* current_page_table = nullptr;
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
||||||
Memory::Memory(Core::System& system) : impl{std::make_unique<Impl>(system)} {}
|
Memory::Memory(Core::System& system) : impl{std::make_unique<Impl>(system)} {}
|
||||||
Memory::~Memory() = default;
|
Memory::~Memory() = default;
|
||||||
|
|
||||||
|
void Memory::SetCurrentPageTable(Kernel::Process& process) {
|
||||||
|
impl->SetCurrentPageTable(process);
|
||||||
|
}
|
||||||
|
|
||||||
void Memory::MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target) {
|
void Memory::MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target) {
|
||||||
impl->MapMemoryRegion(page_table, base, size, target);
|
impl->MapMemoryRegion(page_table, base, size, target);
|
||||||
}
|
}
|
||||||
|
@ -695,18 +708,6 @@ void Memory::RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached) {
|
||||||
impl->RasterizerMarkRegionCached(vaddr, size, cached);
|
impl->RasterizerMarkRegionCached(vaddr, size, cached);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCurrentPageTable(Kernel::Process& process) {
|
|
||||||
current_page_table = &process.VMManager().page_table;
|
|
||||||
|
|
||||||
const std::size_t address_space_width = process.VMManager().GetAddressSpaceWidth();
|
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
|
||||||
system.ArmInterface(0).PageTableChanged(*current_page_table, address_space_width);
|
|
||||||
system.ArmInterface(1).PageTableChanged(*current_page_table, address_space_width);
|
|
||||||
system.ArmInterface(2).PageTableChanged(*current_page_table, address_space_width);
|
|
||||||
system.ArmInterface(3).PageTableChanged(*current_page_table, address_space_width);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsKernelVirtualAddress(const VAddr vaddr) {
|
bool IsKernelVirtualAddress(const VAddr vaddr) {
|
||||||
return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END;
|
return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,13 @@ public:
|
||||||
Memory(Memory&&) = default;
|
Memory(Memory&&) = default;
|
||||||
Memory& operator=(Memory&&) = default;
|
Memory& operator=(Memory&&) = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the currently active page table to that of the given process instance.
|
||||||
|
*
|
||||||
|
* @param process The process to use the page table of.
|
||||||
|
*/
|
||||||
|
void SetCurrentPageTable(Kernel::Process& process);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps an allocated buffer onto a region of the emulated process address space.
|
* Maps an allocated buffer onto a region of the emulated process address space.
|
||||||
*
|
*
|
||||||
|
@ -401,10 +408,6 @@ private:
|
||||||
std::unique_ptr<Impl> impl;
|
std::unique_ptr<Impl> impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Changes the currently active page table to that of
|
|
||||||
/// the given process instance.
|
|
||||||
void SetCurrentPageTable(Kernel::Process& process);
|
|
||||||
|
|
||||||
/// Determines if the given VAddr is a kernel address
|
/// Determines if the given VAddr is a kernel address
|
||||||
bool IsKernelVirtualAddress(VAddr vaddr);
|
bool IsKernelVirtualAddress(VAddr vaddr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue