summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-11-27 00:28:44 +0100
committerLioncash <mathew1800@gmail.com>2019-11-27 03:55:39 +0100
commit50a518be69ef871a674afd91caebdf31cbda4485 (patch)
tree97fe75c5b6602595e375f5bc9eecdaa811cea306
parentcore/memory: Migrate over Write{8, 16, 32, 64, Block} to the Memory class (diff)
downloadyuzu-50a518be69ef871a674afd91caebdf31cbda4485.tar
yuzu-50a518be69ef871a674afd91caebdf31cbda4485.tar.gz
yuzu-50a518be69ef871a674afd91caebdf31cbda4485.tar.bz2
yuzu-50a518be69ef871a674afd91caebdf31cbda4485.tar.lz
yuzu-50a518be69ef871a674afd91caebdf31cbda4485.tar.xz
yuzu-50a518be69ef871a674afd91caebdf31cbda4485.tar.zst
yuzu-50a518be69ef871a674afd91caebdf31cbda4485.zip
-rw-r--r--src/core/memory.cpp72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 5c940a82e..a49e971aa 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -22,42 +22,6 @@
namespace Memory {
namespace {
Common::PageTable* current_page_table = nullptr;
-
-/**
- * Gets a pointer to the exact memory at the virtual address (i.e. not page aligned)
- * using a VMA from the current process
- */
-u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) {
- const auto& vm_manager = process.VMManager();
-
- const auto it = vm_manager.FindVMA(vaddr);
- DEBUG_ASSERT(vm_manager.IsValidHandle(it));
-
- u8* direct_pointer = nullptr;
- const auto& vma = it->second;
- switch (vma.type) {
- case Kernel::VMAType::AllocatedMemoryBlock:
- direct_pointer = vma.backing_block->data() + vma.offset;
- break;
- case Kernel::VMAType::BackingMemory:
- direct_pointer = vma.backing_memory;
- break;
- case Kernel::VMAType::Free:
- return nullptr;
- default:
- UNREACHABLE();
- }
-
- return direct_pointer + (vaddr - vma.base);
-}
-
-/**
- * Gets a pointer to the exact memory at the virtual address (i.e. not page aligned)
- * using a VMA from the current process.
- */
-u8* GetPointerFromVMA(VAddr vaddr) {
- return ::Memory::GetPointerFromVMA(*Core::System::GetInstance().CurrentProcess(), vaddr);
-}
} // Anonymous namespace
// Implementation class used to keep the specifics of the memory subsystem hidden
@@ -135,6 +99,42 @@ struct Memory::Impl {
return IsValidVirtualAddress(*system.CurrentProcess(), vaddr);
}
+ /**
+ * Gets a pointer to the exact memory at the virtual address (i.e. not page aligned)
+ * using a VMA from the current process
+ */
+ u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) {
+ const auto& vm_manager = process.VMManager();
+
+ const auto it = vm_manager.FindVMA(vaddr);
+ DEBUG_ASSERT(vm_manager.IsValidHandle(it));
+
+ u8* direct_pointer = nullptr;
+ const auto& vma = it->second;
+ switch (vma.type) {
+ case Kernel::VMAType::AllocatedMemoryBlock:
+ direct_pointer = vma.backing_block->data() + vma.offset;
+ break;
+ case Kernel::VMAType::BackingMemory:
+ direct_pointer = vma.backing_memory;
+ break;
+ case Kernel::VMAType::Free:
+ return nullptr;
+ default:
+ UNREACHABLE();
+ }
+
+ return direct_pointer + (vaddr - vma.base);
+ }
+
+ /**
+ * Gets a pointer to the exact memory at the virtual address (i.e. not page aligned)
+ * using a VMA from the current process.
+ */
+ u8* GetPointerFromVMA(VAddr vaddr) {
+ return GetPointerFromVMA(*system.CurrentProcess(), vaddr);
+ }
+
u8* GetPointer(const VAddr vaddr) {
u8* const page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS];
if (page_pointer != nullptr) {