summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorbunnei <ericbunnie@gmail.com>2014-04-18 03:05:34 +0200
committerbunnei <ericbunnie@gmail.com>2014-04-18 03:05:34 +0200
commit09ffe87360f39a76b084fe1c9bac2330d6f6f790 (patch)
treee6e670628ad7f49eaa32008f10ea4abe89584be0 /src/core
parentcleaned up memory interfaces a lot, removed some hackish stuff (diff)
downloadyuzu-09ffe87360f39a76b084fe1c9bac2330d6f6f790.tar
yuzu-09ffe87360f39a76b084fe1c9bac2330d6f6f790.tar.gz
yuzu-09ffe87360f39a76b084fe1c9bac2330d6f6f790.tar.bz2
yuzu-09ffe87360f39a76b084fe1c9bac2330d6f6f790.tar.lz
yuzu-09ffe87360f39a76b084fe1c9bac2330d6f6f790.tar.xz
yuzu-09ffe87360f39a76b084fe1c9bac2330d6f6f790.tar.zst
yuzu-09ffe87360f39a76b084fe1c9bac2330d6f6f790.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/mem_map.cpp13
-rw-r--r--src/core/mem_map.h53
-rw-r--r--src/core/mem_map_funcs.cpp40
3 files changed, 58 insertions, 48 deletions
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp
index 8fc8388ec..44b4b07b7 100644
--- a/src/core/mem_map.cpp
+++ b/src/core/mem_map.cpp
@@ -17,20 +17,23 @@ u8* g_base = NULL; ///< The base pointer to the aut
MemArena g_arena; ///< The MemArena class
u8* g_bootrom = NULL; ///< Bootrom physical memory
-u8* g_fcram = NULL; ///< Main memory (FCRAM) pointer
+u8* g_heap_gsp = NULL;
+u8* g_heap = NULL;
u8* g_vram = NULL; ///< Video memory (VRAM) pointer
u8* g_physical_bootrom = NULL; ///< Bootrom physical memory
u8* g_uncached_bootrom = NULL;
u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM)
+u8* g_physical_heap_gsp = NULL;
u8* g_physical_vram = NULL; ///< Video physical memory (VRAM)
u8* g_physical_scratchpad = NULL; ///< Scratchpad memory used for main thread stack
// We don't declare the IO region in here since its handled by other means.
static MemoryView g_views[] = {
- { &g_vram, &g_physical_vram, MEM_VRAM_VADDR, MEM_VRAM_SIZE, 0 },
- { &g_fcram, &g_physical_fcram, MEM_FCRAM_VADDR, MEM_FCRAM_SIZE, MV_IS_PRIMARY_RAM },
+ {&g_vram, &g_physical_vram, VRAM_VADDR, VRAM_SIZE, 0},
+ {&g_heap_gsp, &g_physical_heap_gsp, HEAP_GSP_VADDR, HEAP_GSP_SIZE, 0},
+ {&g_heap, &g_physical_fcram, HEAP_VADDR, HEAP_SIZE, MV_IS_PRIMARY_RAM},
};
/*static MemoryView views[] =
@@ -54,12 +57,12 @@ void Init() {
for (size_t i = 0; i < ARRAY_SIZE(g_views); i++) {
if (g_views[i].flags & MV_IS_PRIMARY_RAM)
- g_views[i].size = MEM_FCRAM_SIZE;
+ g_views[i].size = FCRAM_SIZE;
}
g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &g_arena);
- NOTICE_LOG(MEMMAP, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_fcram,
+ NOTICE_LOG(MEMMAP, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_heap,
g_physical_fcram);
}
diff --git a/src/core/mem_map.h b/src/core/mem_map.h
index 82cfdece5..a1fa90f3e 100644
--- a/src/core/mem_map.h
+++ b/src/core/mem_map.h
@@ -12,25 +12,38 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
enum {
- MEM_BOOTROM_SIZE = 0x00010000, ///< Bootrom (super secret code/data @ 0x8000) size
- MEM_MPCORE_PRIV_SIZE = 0x00002000, ///< MPCore private memory region size
- MEM_VRAM_SIZE = 0x00600000, ///< VRAM size
- MEM_DSP_SIZE = 0x00080000, ///< DSP memory size
- MEM_AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size
- MEM_FCRAM_SIZE = 0x08000000, ///< FCRAM size
- MEM_SCRATCHPAD_SIZE = 0x00004000, ///< Typical stack size - TODO: Read from exheader
-
- MEM_VRAM_MASK = 0x007FFFFF,
- MEM_FCRAM_MASK = (MEM_FCRAM_SIZE - 1), ///< FCRAM mask
- MEM_SCRATCHPAD_MASK = (MEM_SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask
-
- MEM_FCRAM_PADDR = 0x20000000, ///< FCRAM physical address
- MEM_FCRAM_PADDR_END = (MEM_FCRAM_PADDR + MEM_FCRAM_SIZE), ///< FCRAM end of physical space
- MEM_FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address
- MEM_FCRAM_VADDR_END = (MEM_FCRAM_VADDR + MEM_FCRAM_SIZE), ///< FCRAM end of virtual space
-
- MEM_VRAM_VADDR = 0x1F000000,
- MEM_SCRATCHPAD_VADDR = (0x10000000 - MEM_SCRATCHPAD_SIZE), ///< Scratchpad virtual address
+ BOOTROM_SIZE = 0x00010000, ///< Bootrom (super secret code/data @ 0x8000) size
+ MPCORE_PRIV_SIZE = 0x00002000, ///< MPCore private memory region size
+ VRAM_SIZE = 0x00600000, ///< VRAM size
+ DSP_SIZE = 0x00080000, ///< DSP memory size
+ AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size
+ FCRAM_SIZE = 0x08000000, ///< FCRAM size
+ SCRATCHPAD_SIZE = 0x00004000, ///< Typical stack size - TODO: Read from exheader
+ HEAP_GSP_SIZE = 0x02000000, ///< GSP heap size... TODO: Define correctly?
+ HEAP_SIZE = FCRAM_SIZE, ///< Application heap size
+
+ HEAP_PADDR = HEAP_GSP_SIZE,
+ HEAP_PADDR_END = (HEAP_PADDR + HEAP_SIZE),
+ HEAP_VADDR = 0x08000000,
+ HEAP_VADDR_END = (HEAP_VADDR + HEAP_SIZE),
+ HEAP_GSP_VADDR = 0x14000000,
+ HEAP_GSP_VADDR_END = (HEAP_GSP_VADDR + HEAP_GSP_SIZE),
+ HEAP_GSP_PADDR = 0x00000000,
+ HEAP_GSP_PADDR_END = (HEAP_GSP_PADDR + HEAP_GSP_SIZE),
+
+ VRAM_MASK = 0x007FFFFF,
+ FCRAM_MASK = (FCRAM_SIZE - 1), ///< FCRAM mask
+ SCRATCHPAD_MASK = (SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask
+ HEAP_MASK = (HEAP_SIZE - 1),
+
+ FCRAM_PADDR = 0x20000000, ///< FCRAM physical address
+ FCRAM_PADDR_END = (FCRAM_PADDR + FCRAM_SIZE), ///< FCRAM end of physical space
+ FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address
+ FCRAM_VADDR_END = (FCRAM_VADDR + FCRAM_SIZE), ///< FCRAM end of virtual space
+
+ VRAM_VADDR = 0x1F000000,
+ SCRATCHPAD_VADDR_END = 0x10000000,
+ SCRATCHPAD_VADDR = (SCRATCHPAD_VADDR_END - SCRATCHPAD_SIZE), ///< Stack space
};
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -49,7 +62,7 @@ extern u8 *g_base;
// These are guaranteed to point to "low memory" addresses (sub-32-bit).
// 64-bit: Pointers to low-mem (sub-0x10000000) mirror
// 32-bit: Same as the corresponding physical/virtual pointers.
-extern u8* g_fcram; ///< Main memory
+extern u8* g_heap; ///< Main memory
extern u8* g_vram; ///< Video memory (VRAM)
void Init();
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp
index bb83855fe..40d9dab3a 100644
--- a/src/core/mem_map_funcs.cpp
+++ b/src/core/mem_map_funcs.cpp
@@ -15,8 +15,8 @@ u32 _AddressPhysicalToVirtual(const u32 addr) {
// 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
// any MMU emulation yet or anything
- if (((addr & 0xF0000000) == MEM_FCRAM_PADDR) && (addr < (MEM_FCRAM_PADDR_END))) {
- return (addr & MEM_FCRAM_MASK) | MEM_FCRAM_VADDR;
+ if ((addr >= FCRAM_PADDR) && (addr < (FCRAM_PADDR_END))) {
+ return (addr & FCRAM_MASK) | FCRAM_VADDR;
}
return addr;
}
@@ -40,15 +40,15 @@ inline void _Read(T &var, const u32 addr) {
} else if ((vaddr & 0xFF000000) == 0x10000000 || (vaddr & 0xFF000000) == 0x1E000000) {
HW::Read<T>(var, vaddr);
- // FCRAM
- } else if ((vaddr > MEM_FCRAM_VADDR) && (vaddr < MEM_FCRAM_VADDR_END)) {
- var = *((const T*)&g_fcram[vaddr & MEM_FCRAM_MASK]);
+ // FCRAM - application heap
+ } else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
+ var = *((const T*)&g_heap[vaddr & HEAP_MASK]);
/*else if ((vaddr & 0x3F800000) == 0x04000000) {
var = *((const T*)&m_pVRAM[vaddr & VRAM_MASK]);*/
} 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);
}
}
@@ -66,20 +66,14 @@ inline void _Write(u32 addr, const T data) {
// 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space
} else if ((vaddr & 0xFF000000) == 0x10000000 || (vaddr & 0xFF000000) == 0x1E000000) {
HW::Write<T>(vaddr, data);
-
- // ExeFS:/.code is loaded here:
- } else if ((vaddr & 0xFFF00000) == 0x00100000) {
- // TODO(ShizZy): This is dumb... handle correctly. From 3DBrew:
- // 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
- } else if ((vaddr > MEM_FCRAM_VADDR) && (vaddr < MEM_FCRAM_VADDR_END)) {
- *(T*)&g_fcram[vaddr & MEM_FCRAM_MASK] = data;
+
+ // FCRAM - GSP heap
+ //} else if ((vaddr > HEAP_GSP_VADDR) && (vaddr < HEAP_VADDR_GSP_END)) {
+ // *(T*)&g_heap_gsp[vaddr & FCRAM_MASK] = data;
+
+ // FCRAM - application heap
+ } else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
+ *(T*)&g_heap[vaddr & HEAP_MASK] = data;
} else if ((vaddr & 0xFF000000) == 0x14000000) {
_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) {
const u32 vaddr = _AddressPhysicalToVirtual(addr);
- // FCRAM
- if ((vaddr > MEM_FCRAM_VADDR) && (vaddr < MEM_FCRAM_VADDR_END)) {
- return g_fcram + (vaddr & MEM_FCRAM_MASK);
+ // FCRAM - application heap
+ if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) {
+ return g_heap + (vaddr & HEAP_MASK);
} else {
ERROR_LOG(MEMMAP, "Unknown GetPointer @ 0x%08x", vaddr);