summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <ericbunnie@gmail.com>2014-04-01 03:05:51 +0200
committerbunnei <ericbunnie@gmail.com>2014-04-01 03:05:51 +0200
commita36f9492cca6ae44eb6ca33d29900f78b5b372bf (patch)
treea4a23f796c4b38049beb567e08449b18315f711c
parentgrabbed ppsspp's MemArena (diff)
downloadyuzu-a36f9492cca6ae44eb6ca33d29900f78b5b372bf.tar
yuzu-a36f9492cca6ae44eb6ca33d29900f78b5b372bf.tar.gz
yuzu-a36f9492cca6ae44eb6ca33d29900f78b5b372bf.tar.bz2
yuzu-a36f9492cca6ae44eb6ca33d29900f78b5b372bf.tar.lz
yuzu-a36f9492cca6ae44eb6ca33d29900f78b5b372bf.tar.xz
yuzu-a36f9492cca6ae44eb6ca33d29900f78b5b372bf.tar.zst
yuzu-a36f9492cca6ae44eb6ca33d29900f78b5b372bf.zip
-rw-r--r--src/core/src/mem_map.cpp34
-rw-r--r--src/core/src/mem_map.h12
-rw-r--r--src/core/src/mem_map_funcs.cpp11
3 files changed, 40 insertions, 17 deletions
diff --git a/src/core/src/mem_map.cpp b/src/core/src/mem_map.cpp
index 6d57b550a..975a0cf08 100644
--- a/src/core/src/mem_map.cpp
+++ b/src/core/src/mem_map.cpp
@@ -37,26 +37,32 @@ u8* g_base = NULL; ///< The base pointer to the auto-mirrored arena.
MemArena g_arena; ///< The MemArena class
-u8* g_bootrom = NULL; ///< Bootrom memory (super secret code/data @ 0x8000) pointer
-u8* g_fcram = NULL; ///< Main memory (FCRAM) pointer
-u8* g_vram = NULL; ///< Video memory (VRAM) pointer
+u8* g_bootrom = NULL; ///< Bootrom memory (super secret code/data @ 0x8000) pointer
+u8* g_fcram = NULL; ///< Main memory (FCRAM) 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_uncached_bootrom = NULL;
+u8* g_physical_bootrom = NULL; ///< Bootrom physical memory (super secret code/data @ 0x8000)
+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.
static MemoryView g_views[] =
{
- {&g_bootrom, &g_physical_bootrom, 0x00000000, MEM_BOOTROM_SIZE, 0},
- {NULL, &g_uncached_bootrom, 0x00010000, MEM_BOOTROM_SIZE, MV_MIRROR_PREVIOUS},
-// //{NULL, NULL, 0x17E00000, MEM_MPCORE_PRIV_SIZE, 0},
- {&g_vram, &g_physical_vram, 0x18000000, MEM_VRAM_SIZE, 0},
-// //{NULL, NULL, 0x1FF00000, MEM_DSP_SIZE, 0},
-// //{NULL, NULL, 0x1FF80000, MEM_AXI_WRAM_SIZE, 0},
- {&g_fcram, &g_physical_fcram, 0x20000000, MEM_FCRAM_SIZE, MV_IS_PRIMARY_RAM},
+ {&g_scratchpad, &g_physical_scratchpad, 0x00000000, MEM_SCRATCHPAD_SIZE, 0 },
+// {&g_bootrom, &g_physical_bootrom, 0x00000000, MEM_BOOTROM_SIZE, 0},
+// {NULL, &g_uncached_bootrom, 0x00010000, MEM_BOOTROM_SIZE, MV_MIRROR_PREVIOUS},
+// {NULL, NULL, 0x17E00000, MEM_MPCORE_PRIV_SIZE, 0},
+ {&g_vram, &g_physical_vram, MEM_VRAM_VADDR, MEM_VRAM_SIZE, MV_IS_PRIMARY_RAM},
+// {NULL, NULL, 0x1FF00000, MEM_DSP_SIZE, 0},
+// {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[] =
diff --git a/src/core/src/mem_map.h b/src/core/src/mem_map.h
index 55f02e285..c72e722df 100644
--- a/src/core/src/mem_map.h
+++ b/src/core/src/mem_map.h
@@ -37,10 +37,17 @@
#define MEM_VRAM_SIZE 0x00600000 ///< VRAM size
#define MEM_DSP_SIZE 0x00080000 ///< DSP memory 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_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.
extern u8* g_fcram; ///< Main memory
extern u8* g_vram; ///< Video memory (VRAM)
+extern u8* g_scratchpad; ///< Stack memory
void Init();
void Shutdown();
diff --git a/src/core/src/mem_map_funcs.cpp b/src/core/src/mem_map_funcs.cpp
index f00d10f87..c8436b2a4 100644
--- a/src/core/src/mem_map_funcs.cpp
+++ b/src/core/src/mem_map_funcs.cpp
@@ -38,7 +38,11 @@ inline void ReadFromHardware(T &var, const u32 addr)
if ((addr & 0x3E000000) == 0x08000000) {
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) {
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.
*(T*)&g_fcram[addr & MEM_FCRAM_MASK] = data;
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:
} else if ((addr & 0x3E000000) == 0x08000000) {
// TODO(ShizZy): Writes to this virtual address should be put in physical memory at FCRAM + GSP