Memory: Support more regions in the VAddr-PAddr translation functions
Also adds better documentation and removes the one-off reimplementation of the function in pica.h.
This commit is contained in:
parent
e7b6ed7578
commit
28a9e4c1d5
7 changed files with 45 additions and 51 deletions
|
@ -18,40 +18,40 @@ namespace Memory {
|
|||
static std::map<u32, MemoryBlock> heap_map;
|
||||
static std::map<u32, MemoryBlock> heap_linear_map;
|
||||
|
||||
/// Convert a physical address to virtual address
|
||||
VAddr PhysicalToVirtualAddress(const PAddr addr) {
|
||||
// Our memory interface read/write functions assume virtual addresses. Put any physical address
|
||||
// to virtual address translations here. This is quite hacky, but necessary until we implement
|
||||
// proper MMU emulation.
|
||||
// TODO: Screw it, I'll let bunnei figure out how to do this properly.
|
||||
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;
|
||||
}
|
||||
|
||||
LOG_ERROR(HW_Memory, "Unknown physical address @ 0x%08x", addr);
|
||||
return addr;
|
||||
}
|
||||
|
||||
/// Convert a physical address to virtual address
|
||||
PAddr VirtualToPhysicalAddress(const VAddr addr) {
|
||||
// Our memory interface read/write functions assume virtual addresses. Put any physical address
|
||||
// to virtual address translations here. This is quite hacky, but necessary until we implement
|
||||
// proper MMU emulation.
|
||||
// TODO: Screw it, I'll let bunnei figure out how to do this properly.
|
||||
if (addr == 0) {
|
||||
return 0;
|
||||
} else if ((addr >= VRAM_VADDR) && (addr < VRAM_VADDR_END)) {
|
||||
} 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)) {
|
||||
} 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);
|
||||
return 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;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue