1
0
Fork 0
forked from suyu/suyu

added memory read/write to GSP heap

This commit is contained in:
bunnei 2014-04-17 21:15:40 -04:00
parent 09ffe87360
commit a9dba388eb
3 changed files with 16 additions and 7 deletions

View file

@ -16,9 +16,8 @@ u8* g_base = NULL; ///< The base pointer to the aut
MemArena g_arena; ///< The MemArena class MemArena g_arena; ///< The MemArena class
u8* g_bootrom = NULL; ///< Bootrom physical memory u8* g_heap_gsp = NULL; ///< GSP heap (main memory)
u8* g_heap_gsp = NULL; u8* g_heap = NULL; ///< Application heap (main memory)
u8* g_heap = NULL;
u8* g_vram = NULL; ///< Video memory (VRAM) pointer u8* g_vram = NULL; ///< Video memory (VRAM) pointer
u8* g_physical_bootrom = NULL; ///< Bootrom physical memory u8* g_physical_bootrom = NULL; ///< Bootrom physical memory

View file

@ -34,6 +34,7 @@ enum {
VRAM_MASK = 0x007FFFFF, VRAM_MASK = 0x007FFFFF,
FCRAM_MASK = (FCRAM_SIZE - 1), ///< FCRAM mask FCRAM_MASK = (FCRAM_SIZE - 1), ///< FCRAM mask
SCRATCHPAD_MASK = (SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask SCRATCHPAD_MASK = (SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask
HEAP_GSP_MASK = (HEAP_GSP_SIZE - 1),
HEAP_MASK = (HEAP_SIZE - 1), HEAP_MASK = (HEAP_SIZE - 1),
FCRAM_PADDR = 0x20000000, ///< FCRAM physical address FCRAM_PADDR = 0x20000000, ///< FCRAM physical address
@ -62,7 +63,8 @@ extern u8 *g_base;
// These are guaranteed to point to "low memory" addresses (sub-32-bit). // These are guaranteed to point to "low memory" addresses (sub-32-bit).
// 64-bit: Pointers to low-mem (sub-0x10000000) mirror // 64-bit: Pointers to low-mem (sub-0x10000000) mirror
// 32-bit: Same as the corresponding physical/virtual pointers. // 32-bit: Same as the corresponding physical/virtual pointers.
extern u8* g_heap; ///< Main memory extern u8* g_heap_gsp; ///< GSP heap (main memory)
extern u8* g_heap; ///< Application heap (main memory)
extern u8* g_vram; ///< Video memory (VRAM) extern u8* g_vram; ///< Video memory (VRAM)
void Init(); void Init();

View file

@ -40,6 +40,10 @@ 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 - GSP heap
} else if ((vaddr > HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) {
var = *((const T*)&g_heap_gsp[vaddr & HEAP_GSP_MASK]);
// FCRAM - application heap // FCRAM - application heap
} else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { } else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
var = *((const T*)&g_heap[vaddr & HEAP_MASK]); var = *((const T*)&g_heap[vaddr & HEAP_MASK]);
@ -68,8 +72,8 @@ inline void _Write(u32 addr, const T data) {
HW::Write<T>(vaddr, data); HW::Write<T>(vaddr, data);
// FCRAM - GSP heap // FCRAM - GSP heap
//} else if ((vaddr > HEAP_GSP_VADDR) && (vaddr < HEAP_VADDR_GSP_END)) { } else if ((vaddr > HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) {
// *(T*)&g_heap_gsp[vaddr & FCRAM_MASK] = data; *(T*)&g_heap_gsp[vaddr & HEAP_GSP_MASK] = data;
// FCRAM - application heap // FCRAM - application heap
} else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { } else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
@ -98,8 +102,12 @@ 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 - GSP heap
if ((vaddr > HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) {
return g_heap_gsp + (vaddr & HEAP_GSP_MASK);
// FCRAM - application heap // FCRAM - application heap
if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { } else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
return g_heap + (vaddr & HEAP_MASK); return g_heap + (vaddr & HEAP_MASK);
} else { } else {