From 76e0a4ece7297bfa5368961d9714b0dd81c82c56 Mon Sep 17 00:00:00 2001
From: Weiyi Wang <wwylele@gmail.com>
Date: Wed, 21 Nov 2018 13:51:12 -0500
Subject: [PATCH] Memory: move GetPointer into class

---
 src/core/hle/service/service.cpp | 3 ++-
 src/core/hw/y2r.cpp              | 5 +++--
 src/core/memory.cpp              | 2 +-
 src/core/memory.h                | 4 ++--
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 795f720e3..b065208d3 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -180,7 +180,8 @@ void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_ses
     Kernel::KernelSystem& kernel = Core::System::GetInstance().Kernel();
     auto thread = kernel.GetThreadManager().GetCurrentThread();
     // TODO(wwylele): avoid GetPointer
-    u32* cmd_buf = reinterpret_cast<u32*>(Memory::GetPointer(thread->GetCommandBufferAddress()));
+    u32* cmd_buf = reinterpret_cast<u32*>(
+        Core::System::GetInstance().Memory().GetPointer(thread->GetCommandBufferAddress()));
 
     u32 header_code = cmd_buf[0];
     auto itr = handlers.find(header_code);
diff --git a/src/core/hw/y2r.cpp b/src/core/hw/y2r.cpp
index c1f99b571..a613bbed5 100644
--- a/src/core/hw/y2r.cpp
+++ b/src/core/hw/y2r.cpp
@@ -10,6 +10,7 @@
 #include "common/color.h"
 #include "common/common_types.h"
 #include "common/vector_math.h"
+#include "core/core.h"
 #include "core/hle/service/y2r_u.h"
 #include "core/hw/y2r.h"
 #include "core/memory.h"
@@ -80,7 +81,7 @@ static void ConvertYUVToRGB(InputFormat input_format, const u8* input_Y, const u
 /// formats to 8-bit.
 template <std::size_t N>
 static void ReceiveData(u8* output, ConversionBuffer& buf, std::size_t amount_of_data) {
-    const u8* input = Memory::GetPointer(buf.address);
+    const u8* input = Core::System::GetInstance().Memory().GetPointer(buf.address);
 
     std::size_t output_unit = buf.transfer_unit / N;
     ASSERT(amount_of_data % output_unit == 0);
@@ -104,7 +105,7 @@ static void ReceiveData(u8* output, ConversionBuffer& buf, std::size_t amount_of
 static void SendData(const u32* input, ConversionBuffer& buf, int amount_of_data,
                      OutputFormat output_format, u8 alpha) {
 
-    u8* output = Memory::GetPointer(buf.address);
+    u8* output = Core::System::GetInstance().Memory().GetPointer(buf.address);
 
     while (amount_of_data > 0) {
         u8* unit_end = output + buf.transfer_unit;
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 27d6109c4..8c260c1f7 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -210,7 +210,7 @@ bool MemorySystem::IsValidPhysicalAddress(const PAddr paddr) {
     return GetPhysicalPointer(paddr) != nullptr;
 }
 
-u8* GetPointer(const VAddr vaddr) {
+u8* MemorySystem::GetPointer(const VAddr vaddr) {
     u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS];
     if (page_pointer) {
         return page_pointer + (vaddr & PAGE_MASK);
diff --git a/src/core/memory.h b/src/core/memory.h
index 97645c0b9..ffafc4c1c 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -198,8 +198,6 @@ void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr,
 void CopyBlock(const Kernel::Process& src_process, const Kernel::Process& dest_process,
                VAddr src_addr, VAddr dest_addr, std::size_t size);
 
-u8* GetPointer(VAddr vaddr);
-
 std::string ReadCString(VAddr vaddr, std::size_t max_length);
 
 /**
@@ -251,6 +249,8 @@ public:
      */
     u8* GetPhysicalPointer(PAddr address);
 
+    u8* GetPointer(VAddr vaddr);
+
     bool IsValidPhysicalAddress(PAddr paddr);
 
     /// Gets offset in FCRAM from a pointer inside FCRAM range