3
0
Fork 0
forked from suyu/suyu

added support for reading/writing to stack mem

This commit is contained in:
bunnei 2014-03-31 21:05:51 -04:00
parent 07ea22de5c
commit a36f9492cc
3 changed files with 40 additions and 17 deletions

View file

@ -37,26 +37,32 @@ u8* g_base = NULL; ///< The base pointer to the auto-mirrored arena.
MemArena g_arena; ///< The MemArena class MemArena g_arena; ///< The MemArena class
u8* g_bootrom = NULL; ///< Bootrom memory (super secret code/data @ 0x8000) pointer u8* g_bootrom = NULL; ///< Bootrom memory (super secret code/data @ 0x8000) pointer
u8* g_fcram = NULL; ///< Main memory (FCRAM) pointer u8* g_fcram = NULL; ///< Main memory (FCRAM) pointer
u8* g_vram = NULL; ///< Video memory (VRAM) pointer u8* g_vram = NULL; ///< Video memory (VRAM) pointer
u8* g_scratchpad = NULL; ///< [Hack] Seperate mem for stack space because I don't know where this goes
u8* g_physical_bootrom = NULL; ///< Bootrom physical memory (super secret code/data @ 0x8000) u8* g_physical_bootrom = NULL; ///< Bootrom physical memory (super secret code/data @ 0x8000)
u8* g_uncached_bootrom = NULL; u8* g_uncached_bootrom = NULL;
u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM)
u8* g_physical_vram = NULL; ///< Video physical memory (VRAM)
u8* g_physical_scratchpad = NULL; ///< Scratchpad memory used for main thread stack
u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM)
u8* g_physical_vram = NULL; ///< Video physical memory (VRAM)
// We don't declare the IO region in here since its handled by other means. // We don't declare the IO region in here since its handled by other means.
static MemoryView g_views[] = static MemoryView g_views[] =
{ {
{&g_bootrom, &g_physical_bootrom, 0x00000000, MEM_BOOTROM_SIZE, 0}, {&g_scratchpad, &g_physical_scratchpad, 0x00000000, MEM_SCRATCHPAD_SIZE, 0 },
{NULL, &g_uncached_bootrom, 0x00010000, MEM_BOOTROM_SIZE, MV_MIRROR_PREVIOUS}, // {&g_bootrom, &g_physical_bootrom, 0x00000000, MEM_BOOTROM_SIZE, 0},
// //{NULL, NULL, 0x17E00000, MEM_MPCORE_PRIV_SIZE, 0}, // {NULL, &g_uncached_bootrom, 0x00010000, MEM_BOOTROM_SIZE, MV_MIRROR_PREVIOUS},
{&g_vram, &g_physical_vram, 0x18000000, MEM_VRAM_SIZE, 0}, // {NULL, NULL, 0x17E00000, MEM_MPCORE_PRIV_SIZE, 0},
// //{NULL, NULL, 0x1FF00000, MEM_DSP_SIZE, 0}, {&g_vram, &g_physical_vram, MEM_VRAM_VADDR, MEM_VRAM_SIZE, MV_IS_PRIMARY_RAM},
// //{NULL, NULL, 0x1FF80000, MEM_AXI_WRAM_SIZE, 0}, // {NULL, NULL, 0x1FF00000, MEM_DSP_SIZE, 0},
{&g_fcram, &g_physical_fcram, 0x20000000, MEM_FCRAM_SIZE, MV_IS_PRIMARY_RAM}, // {NULL, NULL, 0x1FF80000, MEM_AXI_WRAM_SIZE, 0},
{&g_fcram, &g_physical_fcram, MEM_FCRAM_VADDR, MEM_FCRAM_SIZE, MV_IS_PRIMARY_RAM},
}; };
/*static MemoryView views[] = /*static MemoryView views[] =

View file

@ -37,10 +37,17 @@
#define MEM_VRAM_SIZE 0x00600000 ///< VRAM size #define MEM_VRAM_SIZE 0x00600000 ///< VRAM size
#define MEM_DSP_SIZE 0x00080000 ///< DSP memory size #define MEM_DSP_SIZE 0x00080000 ///< DSP memory size
#define MEM_AXI_WRAM_SIZE 0x00080000 ///< AXI WRAM size #define MEM_AXI_WRAM_SIZE 0x00080000 ///< AXI WRAM size
#define MEM_FCRAM_SIZE 0x08000000 ///< FCRAM size #define MEM_FCRAM_SIZE 0x08000000 ///< FCRAM size... Really 0x07E00000, but power of 2
// works much better
#define MEM_SCRATCHPAD_SIZE 0x00004000 ///< Typical stack size - TODO: Read from exheader
#define MEM_VRAM_MASK 0x007FFFFF #define MEM_VRAM_MASK 0x007FFFFF
#define MEM_FCRAM_MASK (MEM_FCRAM_SIZE - 1) ///< FCRAm mask #define MEM_FCRAM_MASK (MEM_FCRAM_SIZE - 1) ///< FCRAM mask
#define MEM_SCRATCHPAD_MASK (MEM_SCRATCHPAD_SIZE - 1) ///< Scratchpad memory mask
#define MEM_FCRAM_VADDR 0x08000000
#define MEM_VRAM_VADDR 0x1F000000
#define MEM_SCRATCHPAD_VADDR (0x10000000 - MEM_SCRATCHPAD_SIZE) ///< Scratchpad virtual address
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
@ -60,6 +67,7 @@ extern u8 *g_base;
// 32-bit: Same as the corresponding physical/virtual pointers. // 32-bit: Same as the corresponding physical/virtual pointers.
extern u8* g_fcram; ///< Main memory extern u8* g_fcram; ///< Main memory
extern u8* g_vram; ///< Video memory (VRAM) extern u8* g_vram; ///< Video memory (VRAM)
extern u8* g_scratchpad; ///< Stack memory
void Init(); void Init();
void Shutdown(); void Shutdown();

View file

@ -38,7 +38,11 @@ inline void ReadFromHardware(T &var, const u32 addr)
if ((addr & 0x3E000000) == 0x08000000) { if ((addr & 0x3E000000) == 0x08000000) {
var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]);
}
// Scratchpad memory
} else if (addr > MEM_SCRATCHPAD_VADDR && addr <= (MEM_SCRATCHPAD_VADDR + MEM_SCRATCHPAD_SIZE)) {
var = *((const T*)&g_scratchpad[addr & MEM_SCRATCHPAD_MASK]);
}
/*else if ((addr & 0x3F800000) == 0x04000000) { /*else if ((addr & 0x3F800000) == 0x04000000) {
var = *((const T*)&m_pVRAM[addr & VRAM_MASK]); var = *((const T*)&m_pVRAM[addr & VRAM_MASK]);
}*/ }*/
@ -61,6 +65,11 @@ inline void WriteToHardware(u32 addr, const T data) {
// exheader "special memory" flag is set, however this address can be arbitrary. // exheader "special memory" flag is set, however this address can be arbitrary.
*(T*)&g_fcram[addr & MEM_FCRAM_MASK] = data; *(T*)&g_fcram[addr & MEM_FCRAM_MASK] = data;
NOTICE_LOG(MEMMAP, "Test2"); NOTICE_LOG(MEMMAP, "Test2");
// Scratchpad memory
} else if (addr > MEM_SCRATCHPAD_VADDR && addr <= (MEM_SCRATCHPAD_VADDR + MEM_SCRATCHPAD_SIZE)) {
*(T*)&g_scratchpad[addr & MEM_SCRATCHPAD_MASK] = data;
// Heap mapped by ControlMemory: // Heap mapped by ControlMemory:
} else if ((addr & 0x3E000000) == 0x08000000) { } else if ((addr & 0x3E000000) == 0x08000000) {
// TODO(ShizZy): Writes to this virtual address should be put in physical memory at FCRAM + GSP // TODO(ShizZy): Writes to this virtual address should be put in physical memory at FCRAM + GSP