summaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorGravatar MerryMage2016-04-16 08:46:11 +0100
committerGravatar Subv2016-05-21 11:12:35 -0500
commitc084fc824cf4e076bb83e41af64f5cfaa9204dcb (patch)
tree056ee19984854e14b62d7fb6f14ff9c4d11c97b0 /src/core/memory.cpp
parentAppveyor: Restore working directory after test_script (#1835) (diff)
downloadyuzu-c084fc824cf4e076bb83e41af64f5cfaa9204dcb.tar.gz
yuzu-c084fc824cf4e076bb83e41af64f5cfaa9204dcb.tar.xz
yuzu-c084fc824cf4e076bb83e41af64f5cfaa9204dcb.zip
Memory: IsValidVirtualAddress/IsValidPhysicalAddress
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index ee9b69f81..68a29b154 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -246,6 +246,26 @@ void Write(const VAddr vaddr, const T data) {
246 } 246 }
247} 247}
248 248
249bool IsValidVirtualAddress(const VAddr vaddr) {
250 const u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS];
251 if (page_pointer)
252 return true;
253
254 if (current_page_table->attributes[vaddr >> PAGE_BITS] != PageType::Special)
255 return false;
256
257 MMIORegionPointer mmio_region = GetMMIOHandler(vaddr);
258 if (mmio_region) {
259 return mmio_region->IsValidAddress(vaddr);
260 }
261
262 return false;
263}
264
265bool IsValidPhysicalAddress(const PAddr paddr) {
266 return IsValidVirtualAddress(PhysicalToVirtualAddress(paddr));
267}
268
249u8* GetPointer(const VAddr vaddr) { 269u8* GetPointer(const VAddr vaddr) {
250 u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS]; 270 u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS];
251 if (page_pointer) { 271 if (page_pointer) {
@@ -261,6 +281,7 @@ u8* GetPointer(const VAddr vaddr) {
261} 281}
262 282
263u8* GetPhysicalPointer(PAddr address) { 283u8* GetPhysicalPointer(PAddr address) {
284 // TODO(Subv): This call should not go through the application's memory mapping.
264 return GetPointer(PhysicalToVirtualAddress(address)); 285 return GetPointer(PhysicalToVirtualAddress(address));
265} 286}
266 287