summaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2019-11-26 18:34:30 -0500
committerGravatar Lioncash2019-11-26 21:55:39 -0500
commite7e939104bb167babec7b5f7d5d8390c85f3cbf4 (patch)
tree47b61e77bf8e0e6798b58716d38679a285e3604b /src/core/memory.cpp
parentcore/memory: Migrate over GetPointerFromVMA() to the Memory class (diff)
downloadyuzu-e7e939104bb167babec7b5f7d5d8390c85f3cbf4.tar.gz
yuzu-e7e939104bb167babec7b5f7d5d8390c85f3cbf4.tar.xz
yuzu-e7e939104bb167babec7b5f7d5d8390c85f3cbf4.zip
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.
Diffstat (limited to 'src/core/memory.cpp')
-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 @@
20#include "video_core/gpu.h" 20#include "video_core/gpu.h"
21 21
22namespace Memory { 22namespace Memory {
23namespace {
24Common::PageTable* current_page_table = nullptr;
25} // Anonymous namespace
26 23
27// Implementation class used to keep the specifics of the memory subsystem hidden 24// Implementation class used to keep the specifics of the memory subsystem hidden
28// from outside classes. This also allows modification to the internals of the memory 25// from outside classes. This also allows modification to the internals of the memory
@@ -30,6 +27,17 @@ Common::PageTable* current_page_table = nullptr;
30struct Memory::Impl { 27struct Memory::Impl {
31 explicit Impl(Core::System& system_) : system{system_} {} 28 explicit Impl(Core::System& system_) : system{system_} {}
32 29
30 void SetCurrentPageTable(Kernel::Process& process) {
31 current_page_table = &process.VMManager().page_table;
32
33 const std::size_t address_space_width = process.VMManager().GetAddressSpaceWidth();
34
35 system.ArmInterface(0).PageTableChanged(*current_page_table, address_space_width);
36 system.ArmInterface(1).PageTableChanged(*current_page_table, address_space_width);
37 system.ArmInterface(2).PageTableChanged(*current_page_table, address_space_width);
38 system.ArmInterface(3).PageTableChanged(*current_page_table, address_space_width);
39 }
40
33 void MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target) { 41 void MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target) {
34 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size); 42 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size);
35 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base); 43 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base);
@@ -575,12 +583,17 @@ struct Memory::Impl {
575 } 583 }
576 } 584 }
577 585
586 Common::PageTable* current_page_table = nullptr;
578 Core::System& system; 587 Core::System& system;
579}; 588};
580 589
581Memory::Memory(Core::System& system) : impl{std::make_unique<Impl>(system)} {} 590Memory::Memory(Core::System& system) : impl{std::make_unique<Impl>(system)} {}
582Memory::~Memory() = default; 591Memory::~Memory() = default;
583 592
593void Memory::SetCurrentPageTable(Kernel::Process& process) {
594 impl->SetCurrentPageTable(process);
595}
596
584void Memory::MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target) { 597void Memory::MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target) {
585 impl->MapMemoryRegion(page_table, base, size, target); 598 impl->MapMemoryRegion(page_table, base, size, target);
586} 599}
@@ -695,18 +708,6 @@ void Memory::RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached) {
695 impl->RasterizerMarkRegionCached(vaddr, size, cached); 708 impl->RasterizerMarkRegionCached(vaddr, size, cached);
696} 709}
697 710
698void SetCurrentPageTable(Kernel::Process& process) {
699 current_page_table = &process.VMManager().page_table;
700
701 const std::size_t address_space_width = process.VMManager().GetAddressSpaceWidth();
702
703 auto& system = Core::System::GetInstance();
704 system.ArmInterface(0).PageTableChanged(*current_page_table, address_space_width);
705 system.ArmInterface(1).PageTableChanged(*current_page_table, address_space_width);
706 system.ArmInterface(2).PageTableChanged(*current_page_table, address_space_width);
707 system.ArmInterface(3).PageTableChanged(*current_page_table, address_space_width);
708}
709
710bool IsKernelVirtualAddress(const VAddr vaddr) { 711bool IsKernelVirtualAddress(const VAddr vaddr) {
711 return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END; 712 return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END;
712} 713}