added helper functions to mem_map to convert physical addresses to virtual addresses

This commit is contained in:
bunnei 2014-04-27 12:40:31 -04:00
parent f0525a1eb4
commit b2a6ad52f4
2 changed files with 15 additions and 1 deletions

View File

@ -53,7 +53,9 @@ enum {
HARDWARE_IO_PADDR_END = (HARDWARE_IO_PADDR + HARDWARE_IO_SIZE), HARDWARE_IO_PADDR_END = (HARDWARE_IO_PADDR + HARDWARE_IO_SIZE),
HARDWARE_IO_VADDR_END = (HARDWARE_IO_VADDR + HARDWARE_IO_SIZE), HARDWARE_IO_VADDR_END = (HARDWARE_IO_VADDR + HARDWARE_IO_SIZE),
VRAM_PADDR = 0x18000000,
VRAM_VADDR = 0x1F000000, VRAM_VADDR = 0x1F000000,
VRAM_PADDR_END = (VRAM_PADDR + VRAM_SIZE),
VRAM_VADDR_END = (VRAM_VADDR + VRAM_SIZE), VRAM_VADDR_END = (VRAM_VADDR + VRAM_SIZE),
SCRATCHPAD_VADDR_END = 0x10000000, SCRATCHPAD_VADDR_END = 0x10000000,
@ -141,4 +143,16 @@ inline const char* GetCharPointer(const u32 address) {
return (const char *)GetPointer(address); return (const char *)GetPointer(address);
} }
inline const u32 VirtualAddressFromPhysical_FCRAM(const u32 address) {
return ((address & FCRAM_MASK) | FCRAM_VADDR);
}
inline const u32 VirtualAddressFromPhysical_IO(const u32 address) {
return (address + 0x0EB00000);
}
inline const u32 VirtualAddressFromPhysical_VRAM(const u32 address) {
return (address + 0x07000000);
}
} // namespace } // namespace

View File

@ -22,7 +22,7 @@ u32 _AddressPhysicalToVirtual(const u32 addr) {
// to virtual address translations here. This is obviously quite hacky... But we're not doing // to virtual address translations here. This is obviously quite hacky... But we're not doing
// any MMU emulation yet or anything // any MMU emulation yet or anything
if ((addr >= FCRAM_PADDR) && (addr < FCRAM_PADDR_END)) { if ((addr >= FCRAM_PADDR) && (addr < FCRAM_PADDR_END)) {
return (addr & FCRAM_MASK) | FCRAM_VADDR; return VirtualAddressFromPhysical_FCRAM(addr);
// Hardware IO // Hardware IO
// TODO(bunnei): FixMe // TODO(bunnei): FixMe