summaryrefslogtreecommitdiffstats
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2015-07-29 16:54:44 +0200
committerYuri Kunde Schlesner <yuriks@yuriks.net>2015-08-16 06:03:46 +0200
commite2c7954be5ccabc7c5f87000db01cef040ca4b47 (patch)
tree5b3288c66f6941a9d6be0f2907c3526bb3b7e6ac /src/core/memory.cpp
parentProcess: Store kernel compatibility version during loading (diff)
downloadyuzu-e2c7954be5ccabc7c5f87000db01cef040ca4b47.tar
yuzu-e2c7954be5ccabc7c5f87000db01cef040ca4b47.tar.gz
yuzu-e2c7954be5ccabc7c5f87000db01cef040ca4b47.tar.bz2
yuzu-e2c7954be5ccabc7c5f87000db01cef040ca4b47.tar.lz
yuzu-e2c7954be5ccabc7c5f87000db01cef040ca4b47.tar.xz
yuzu-e2c7954be5ccabc7c5f87000db01cef040ca4b47.tar.zst
yuzu-e2c7954be5ccabc7c5f87000db01cef040ca4b47.zip
Diffstat (limited to '')
-rw-r--r--src/core/memory.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 1f66bb27d..935dac90f 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -9,7 +9,6 @@
#include "common/logging/log.h"
#include "common/swap.h"
-#include "core/mem_map.h"
#include "core/memory.h"
#include "core/memory_setup.h"
@@ -198,4 +197,40 @@ void WriteBlock(const VAddr addr, const u8* data, const size_t size) {
Write8(addr + offset, data[offset]);
}
+PAddr VirtualToPhysicalAddress(const VAddr addr) {
+ if (addr == 0) {
+ return 0;
+ } else if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) {
+ return addr - VRAM_VADDR + VRAM_PADDR;
+ } else if (addr >= LINEAR_HEAP_VADDR && addr < LINEAR_HEAP_VADDR_END) {
+ return addr - LINEAR_HEAP_VADDR + FCRAM_PADDR;
+ } else if (addr >= DSP_RAM_VADDR && addr < DSP_RAM_VADDR_END) {
+ return addr - DSP_RAM_VADDR + DSP_RAM_PADDR;
+ } else if (addr >= IO_AREA_VADDR && addr < IO_AREA_VADDR_END) {
+ return addr - IO_AREA_VADDR + IO_AREA_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;
+}
+
+VAddr PhysicalToVirtualAddress(const PAddr addr) {
+ if (addr == 0) {
+ return 0;
+ } else if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) {
+ return addr - VRAM_PADDR + VRAM_VADDR;
+ } else if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) {
+ return addr - FCRAM_PADDR + LINEAR_HEAP_VADDR;
+ } else if (addr >= DSP_RAM_PADDR && addr < DSP_RAM_PADDR_END) {
+ return addr - DSP_RAM_PADDR + DSP_RAM_VADDR;
+ } else if (addr >= IO_AREA_PADDR && addr < IO_AREA_PADDR_END) {
+ return addr - IO_AREA_PADDR + IO_AREA_VADDR;
+ }
+
+ LOG_ERROR(HW_Memory, "Unknown physical address @ 0x%08X", addr);
+ // To help with debugging, set bit on address so that it's obviously invalid.
+ return addr | 0x80000000;
+}
+
} // namespace