|
|
@ -15,8 +15,8 @@ u32 _AddressPhysicalToVirtual(const u32 addr) {
|
|
|
|
// Our memory interface read/write functions assume virtual addresses. Put any physical address
|
|
|
|
// Our memory interface read/write functions assume virtual addresses. Put any physical address
|
|
|
|
// 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 & 0xF0000000) == MEM_FCRAM_PADDR) && (addr < (MEM_FCRAM_PADDR_END))) {
|
|
|
|
if ((addr >= FCRAM_PADDR) && (addr < (FCRAM_PADDR_END))) {
|
|
|
|
return (addr & MEM_FCRAM_MASK) | MEM_FCRAM_VADDR;
|
|
|
|
return (addr & FCRAM_MASK) | FCRAM_VADDR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return addr;
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -40,15 +40,15 @@ inline void _Read(T &var, const u32 addr) {
|
|
|
|
} else if ((vaddr & 0xFF000000) == 0x10000000 || (vaddr & 0xFF000000) == 0x1E000000) {
|
|
|
|
} else if ((vaddr & 0xFF000000) == 0x10000000 || (vaddr & 0xFF000000) == 0x1E000000) {
|
|
|
|
HW::Read<T>(var, vaddr);
|
|
|
|
HW::Read<T>(var, vaddr);
|
|
|
|
|
|
|
|
|
|
|
|
// FCRAM
|
|
|
|
// FCRAM - application heap
|
|
|
|
} else if ((vaddr > MEM_FCRAM_VADDR) && (vaddr < MEM_FCRAM_VADDR_END)) {
|
|
|
|
} else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
|
|
|
|
var = *((const T*)&g_fcram[vaddr & MEM_FCRAM_MASK]);
|
|
|
|
var = *((const T*)&g_heap[vaddr & HEAP_MASK]);
|
|
|
|
|
|
|
|
|
|
|
|
/*else if ((vaddr & 0x3F800000) == 0x04000000) {
|
|
|
|
/*else if ((vaddr & 0x3F800000) == 0x04000000) {
|
|
|
|
var = *((const T*)&m_pVRAM[vaddr & VRAM_MASK]);*/
|
|
|
|
var = *((const T*)&m_pVRAM[vaddr & VRAM_MASK]);*/
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
_assert_msg_(MEMMAP, false, "unknown Read%d @ 0x%08X", sizeof(var) * 8, vaddr);
|
|
|
|
//_assert_msg_(MEMMAP, false, "unknown Read%d @ 0x%08X", sizeof(var) * 8, vaddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -67,19 +67,13 @@ inline void _Write(u32 addr, const T data) {
|
|
|
|
} else if ((vaddr & 0xFF000000) == 0x10000000 || (vaddr & 0xFF000000) == 0x1E000000) {
|
|
|
|
} else if ((vaddr & 0xFF000000) == 0x10000000 || (vaddr & 0xFF000000) == 0x1E000000) {
|
|
|
|
HW::Write<T>(vaddr, data);
|
|
|
|
HW::Write<T>(vaddr, data);
|
|
|
|
|
|
|
|
|
|
|
|
// ExeFS:/.code is loaded here:
|
|
|
|
// FCRAM - GSP heap
|
|
|
|
} else if ((vaddr & 0xFFF00000) == 0x00100000) {
|
|
|
|
//} else if ((vaddr > HEAP_GSP_VADDR) && (vaddr < HEAP_VADDR_GSP_END)) {
|
|
|
|
// TODO(ShizZy): This is dumb... handle correctly. From 3DBrew:
|
|
|
|
// *(T*)&g_heap_gsp[vaddr & FCRAM_MASK] = data;
|
|
|
|
// http://3dbrew.org/wiki/Memory_layout#ARM11_User-land_memory_regions
|
|
|
|
|
|
|
|
// The ExeFS:/.code is loaded here, executables must be loaded to the 0x00100000 region when
|
|
|
|
|
|
|
|
// the exheader "special memory" flag is clear. The 0x03F00000-byte size restriction only
|
|
|
|
|
|
|
|
// applies when this flag is clear. Executables are usually loaded to 0x14000000 when the
|
|
|
|
|
|
|
|
// exheader "special memory" flag is set, however this address can be arbitrary.
|
|
|
|
|
|
|
|
*(T*)&g_fcram[vaddr & MEM_FCRAM_MASK] = data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FCRAM
|
|
|
|
// FCRAM - application heap
|
|
|
|
} else if ((vaddr > MEM_FCRAM_VADDR) && (vaddr < MEM_FCRAM_VADDR_END)) {
|
|
|
|
} else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
|
|
|
|
*(T*)&g_fcram[vaddr & MEM_FCRAM_MASK] = data;
|
|
|
|
*(T*)&g_heap[vaddr & HEAP_MASK] = data;
|
|
|
|
|
|
|
|
|
|
|
|
} else if ((vaddr & 0xFF000000) == 0x14000000) {
|
|
|
|
} else if ((vaddr & 0xFF000000) == 0x14000000) {
|
|
|
|
_assert_msg_(MEMMAP, false, "umimplemented write to GSP heap");
|
|
|
|
_assert_msg_(MEMMAP, false, "umimplemented write to GSP heap");
|
|
|
@ -104,9 +98,9 @@ inline void _Write(u32 addr, const T data) {
|
|
|
|
u8 *GetPointer(const u32 addr) {
|
|
|
|
u8 *GetPointer(const u32 addr) {
|
|
|
|
const u32 vaddr = _AddressPhysicalToVirtual(addr);
|
|
|
|
const u32 vaddr = _AddressPhysicalToVirtual(addr);
|
|
|
|
|
|
|
|
|
|
|
|
// FCRAM
|
|
|
|
// FCRAM - application heap
|
|
|
|
if ((vaddr > MEM_FCRAM_VADDR) && (vaddr < MEM_FCRAM_VADDR_END)) {
|
|
|
|
if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
|
|
|
|
return g_fcram + (vaddr & MEM_FCRAM_MASK);
|
|
|
|
return g_heap + (vaddr & HEAP_MASK);
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ERROR_LOG(MEMMAP, "Unknown GetPointer @ 0x%08x", vaddr);
|
|
|
|
ERROR_LOG(MEMMAP, "Unknown GetPointer @ 0x%08x", vaddr);
|
|
|
|