summaryrefslogtreecommitdiffstats
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-11-27 00:34:30 +0100
committerLioncash <mathew1800@gmail.com>2019-11-27 03:55:39 +0100
commite7e939104bb167babec7b5f7d5d8390c85f3cbf4 (patch)
tree47b61e77bf8e0e6798b58716d38679a285e3604b /src/core/memory.cpp
parentcore/memory: Migrate over GetPointerFromVMA() to the Memory class (diff)
downloadyuzu-e7e939104bb167babec7b5f7d5d8390c85f3cbf4.tar
yuzu-e7e939104bb167babec7b5f7d5d8390c85f3cbf4.tar.gz
yuzu-e7e939104bb167babec7b5f7d5d8390c85f3cbf4.tar.bz2
yuzu-e7e939104bb167babec7b5f7d5d8390c85f3cbf4.tar.lz
yuzu-e7e939104bb167babec7b5f7d5d8390c85f3cbf4.tar.xz
yuzu-e7e939104bb167babec7b5f7d5d8390c85f3cbf4.tar.zst
yuzu-e7e939104bb167babec7b5f7d5d8390c85f3cbf4.zip
Diffstat (limited to '')
-rw-r--r--src/core/memory.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index a49e971aa..91bf07a92 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -20,9 +20,6 @@
#include "video_core/gpu.h"
namespace Memory {
-namespace {
-Common::PageTable* current_page_table = nullptr;
-} // Anonymous namespace
// 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
@@ -30,6 +27,17 @@ Common::PageTable* current_page_table = nullptr;
struct Memory::Impl {
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) {
ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size);
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;
};
Memory::Memory(Core::System& system) : impl{std::make_unique<Impl>(system)} {}
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) {
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);
}
-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) {
return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END;
}