diff options
Diffstat (limited to 'src/core/memory.cpp')
| -rw-r--r-- | src/core/memory.cpp | 31 |
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 | ||
| 22 | namespace Memory { | 22 | namespace Memory { |
| 23 | namespace { | ||
| 24 | Common::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; | |||
| 30 | struct Memory::Impl { | 27 | struct 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 | ||
| 581 | Memory::Memory(Core::System& system) : impl{std::make_unique<Impl>(system)} {} | 590 | Memory::Memory(Core::System& system) : impl{std::make_unique<Impl>(system)} {} |
| 582 | Memory::~Memory() = default; | 591 | Memory::~Memory() = default; |
| 583 | 592 | ||
| 593 | void Memory::SetCurrentPageTable(Kernel::Process& process) { | ||
| 594 | impl->SetCurrentPageTable(process); | ||
| 595 | } | ||
| 596 | |||
| 584 | void Memory::MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target) { | 597 | void 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 | ||
| 698 | void 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 | |||
| 710 | bool IsKernelVirtualAddress(const VAddr vaddr) { | 711 | bool 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 | } |