aboutsummaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-11-26 15:19:15 -0500
committerLioncash <mathew1800@gmail.com>2019-11-26 21:55:38 -0500
commit3f08e8d8d4ef16cf2468620fbfbdac46e43dcaef (patch)
tree0e13cc5e2595d7019f8e9e80fe0279dc6a2b1d4c /src/core/memory.cpp
parent536fc7f0ea77e08d68c760f387c307d258804e3b (diff)
core/memory: Migrate over GetPointer()
With all of the interfaces ready for migration, it's trivial to migrate over GetPointer().
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 0170336139..93cd67e39a 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -195,6 +195,21 @@ struct Memory::Impl {
return IsValidVirtualAddress(*system.CurrentProcess(), vaddr);
}
+ u8* GetPointer(const VAddr vaddr) {
+ u8* const page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS];
+ if (page_pointer != nullptr) {
+ return page_pointer + (vaddr & PAGE_MASK);
+ }
+
+ if (current_page_table->attributes[vaddr >> PAGE_BITS] ==
+ Common::PageType::RasterizerCachedMemory) {
+ return GetPointerFromVMA(vaddr);
+ }
+
+ LOG_ERROR(HW_Memory, "Unknown GetPointer @ 0x{:016X}", vaddr);
+ return nullptr;
+ }
+
/**
* Maps a region of pages as a specific type.
*
@@ -276,6 +291,14 @@ bool Memory::IsValidVirtualAddress(const VAddr vaddr) const {
return impl->IsValidVirtualAddress(vaddr);
}
+u8* Memory::GetPointer(VAddr vaddr) {
+ return impl->GetPointer(vaddr);
+}
+
+const u8* Memory::GetPointer(VAddr vaddr) const {
+ return impl->GetPointer(vaddr);
+}
+
void SetCurrentPageTable(Kernel::Process& process) {
current_page_table = &process.VMManager().page_table;
@@ -292,21 +315,6 @@ bool IsKernelVirtualAddress(const VAddr vaddr) {
return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END;
}
-u8* GetPointer(const VAddr vaddr) {
- u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS];
- if (page_pointer) {
- return page_pointer + (vaddr & PAGE_MASK);
- }
-
- if (current_page_table->attributes[vaddr >> PAGE_BITS] ==
- Common::PageType::RasterizerCachedMemory) {
- return GetPointerFromVMA(vaddr);
- }
-
- LOG_ERROR(HW_Memory, "Unknown GetPointer @ 0x{:016X}", vaddr);
- return nullptr;
-}
-
std::string ReadCString(VAddr vaddr, std::size_t max_length) {
std::string string;
string.reserve(max_length);