summaryrefslogtreecommitdiffstats
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 7d849d55f..42ca69e00 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -670,7 +670,7 @@ void WriteMMIO<u64>(MMIORegionPointer mmio_handler, VAddr addr, const u64 data)
mmio_handler->Write64(addr, data);
}
-PAddr VirtualToPhysicalAddress(const VAddr addr) {
+boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) {
if (addr == 0) {
return 0;
} else if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) {
@@ -687,9 +687,17 @@ PAddr VirtualToPhysicalAddress(const VAddr addr) {
return addr - N3DS_EXTRA_RAM_VADDR + N3DS_EXTRA_RAM_PADDR;
}
- LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%08X", addr);
- // To help with debugging, set bit on address so that it's obviously invalid.
- return addr | 0x80000000;
+ return boost::none;
+}
+
+PAddr VirtualToPhysicalAddress(const VAddr addr) {
+ auto paddr = TryVirtualToPhysicalAddress(addr);
+ if (!paddr) {
+ LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%08X", addr);
+ // To help with debugging, set bit on address so that it's obviously invalid.
+ return addr | 0x80000000;
+ }
+ return *paddr;
}
boost::optional<VAddr> PhysicalToVirtualAddress(const PAddr addr) {