diff options
author | MerryMage <MerryMage@users.noreply.github.com> | 2016-04-16 09:46:11 +0200 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2016-05-21 18:12:35 +0200 |
commit | c084fc824cf4e076bb83e41af64f5cfaa9204dcb (patch) | |
tree | 056ee19984854e14b62d7fb6f14ff9c4d11c97b0 /src/core/memory.cpp | |
parent | Appveyor: Restore working directory after test_script (#1835) (diff) | |
download | yuzu-c084fc824cf4e076bb83e41af64f5cfaa9204dcb.tar yuzu-c084fc824cf4e076bb83e41af64f5cfaa9204dcb.tar.gz yuzu-c084fc824cf4e076bb83e41af64f5cfaa9204dcb.tar.bz2 yuzu-c084fc824cf4e076bb83e41af64f5cfaa9204dcb.tar.lz yuzu-c084fc824cf4e076bb83e41af64f5cfaa9204dcb.tar.xz yuzu-c084fc824cf4e076bb83e41af64f5cfaa9204dcb.tar.zst yuzu-c084fc824cf4e076bb83e41af64f5cfaa9204dcb.zip |
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r-- | src/core/memory.cpp | 21 |
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) { } } +bool IsValidVirtualAddress(const VAddr vaddr) { + const u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS]; + if (page_pointer) + return true; + + if (current_page_table->attributes[vaddr >> PAGE_BITS] != PageType::Special) + return false; + + MMIORegionPointer mmio_region = GetMMIOHandler(vaddr); + if (mmio_region) { + return mmio_region->IsValidAddress(vaddr); + } + + return false; +} + +bool IsValidPhysicalAddress(const PAddr paddr) { + return IsValidVirtualAddress(PhysicalToVirtualAddress(paddr)); +} + u8* GetPointer(const VAddr vaddr) { u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS]; if (page_pointer) { @@ -261,6 +281,7 @@ u8* GetPointer(const VAddr vaddr) { } u8* GetPhysicalPointer(PAddr address) { + // TODO(Subv): This call should not go through the application's memory mapping. return GetPointer(PhysicalToVirtualAddress(address)); } |