summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar ShizZy2013-09-05 23:04:04 -0400
committerGravatar ShizZy2013-09-05 23:04:04 -0400
commit62d873da3ec77044d0135dbb2c6492eca29482fa (patch)
tree3a21f3df2e1784af68f2df5ac98ced6a73f43c20 /src/core
parentadded core and mem_map files to the project (diff)
downloadyuzu-62d873da3ec77044d0135dbb2c6492eca29482fa.tar.gz
yuzu-62d873da3ec77044d0135dbb2c6492eca29482fa.tar.xz
yuzu-62d873da3ec77044d0135dbb2c6492eca29482fa.zip
start of 3DS memory map
Diffstat (limited to 'src/core')
-rw-r--r--src/core/src/mem_map.cpp52
-rw-r--r--src/core/src/mem_map.h29
2 files changed, 77 insertions, 4 deletions
diff --git a/src/core/src/mem_map.cpp b/src/core/src/mem_map.cpp
index 3ff516cbd..e649da91b 100644
--- a/src/core/src/mem_map.cpp
+++ b/src/core/src/mem_map.cpp
@@ -22,10 +22,41 @@
22 * http://code.google.com/p/gekko-gc-emu/ 22 * http://code.google.com/p/gekko-gc-emu/
23 */ 23 */
24 24
25#include "common.h"
26#include "mem_arena.h"
27
25#include "mem_map.h" 28#include "mem_map.h"
29#include "core.h"
30
31////////////////////////////////////////////////////////////////////////////////////////////////////
26 32
27namespace Memory { 33namespace Memory {
28 34
35
36u8* g_mem_base = NULL; ///< The base pointer to the auto-mirrored arena.
37
38MemArena g_mem_arena; ///< The MemArena class
39
40u8* g_fcram = NULL; ///< Main memory (FCRAM) pointer
41u8* g_vram = NULL; ///< Video memory (VRAM) pointer
42
43u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM)
44u8* g_physical_vram = NULL; ///< Video physical memory (VRAM)
45
46// We don't declare the IO region in here since its handled by other means.
47static MemoryView g_mem_views[] =
48{
49 {NULL, NULL, 0x00000000, MEM_BOOTROM_SIZE, 0},
50 {NULL, NULL, 0x00010000, MEM_BOOTROM_SIZE, MV_MIRROR_PREVIOUS},
51 {NULL, NULL, 0x17E00000, MEM_MPCORE_PRIV_SIZE, 0},
52 {&g_vram, &g_physical_vram, 0x18000000, MEM_VRAM_SIZE, 0},
53 {NULL, NULL, 0x1FF00000, MEM_DSP_SIZE, 0},
54 {NULL, NULL, 0x1FF80000, MEM_AXI_WRAM_SIZE, 0},
55 {&g_ram, &g_physical_fcram, 0x20000000, MEM_FCRAM_SIZE, MV_IS_PRIMARY_RAM},
56};
57
58static const int kNumMemViews = sizeof(g_mem_views) / sizeof(MemoryView); ///< Number of mem views
59
29u8 Read8(const u32 addr) { 60u8 Read8(const u32 addr) {
30 return 0xDE; 61 return 0xDE;
31} 62}
@@ -47,6 +78,27 @@ void Write16(const u32 addr, const u32 data) {
47void Write32(const u32 addr, const u32 data) { 78void Write32(const u32 addr, const u32 data) {
48} 79}
49 80
81void Init() {
82 int flags = 0;
83
84 for (size_t i = 0; i < ARRAY_SIZE(g_mem_views); i++) {
85 if (g_mem_views[i].flags & MV_IS_PRIMARY_RAM)
86 g_mem_views[i].size = MEMORY_SIZE;
87 }
88 g_base = MemoryMap_Setup(g_mem_views, kNumMemViews, flags, &g_mem_arena);
89
90 INFO_LOG(MEMMAP, "Memory system initialized. RAM at %p (mirror at 0 @ %p)", g_fcram,
91 g_physical_fcram);
92}
93
94void Shutdown() {
95 u32 flags = 0;
96 MemoryMap_Shutdown(g_mem_views, kNumMemViews, flags, &g_mem_arena);
97 g_mem_arena.ReleaseSpace();
98 g_mem_base = NULL;
99 INFO_LOG(MEMMAP, "Memory system shut down.");
100}
101
50 102
51 103
52} // namespace 104} // namespace
diff --git a/src/core/src/mem_map.h b/src/core/src/mem_map.h
index 8ef6e58a2..3251fc416 100644
--- a/src/core/src/mem_map.h
+++ b/src/core/src/mem_map.h
@@ -32,13 +32,34 @@
32 32
33//////////////////////////////////////////////////////////////////////////////////////////////////// 33////////////////////////////////////////////////////////////////////////////////////////////////////
34 34
35#define MEM_BOOTROM_SIZE 0x00010000 ///< Bootrom (super secret code/data @ 0x8000) size
36#define MEM_MPCORE_PRIV_SIZE 0x00002000 ///< MPCore private memory region size
37#define MEM_VRAM_SIZE 0x00600000 ///< VRAM size
38#define MEM_DSP_SIZE 0x00080000 ///< DSP memory size
39#define MEM_AXI_WRAM_SIZE 0x00080000 ///< AXI WRAM size
40#define MEM_FCRAM_SIZE 0x08000000 ///< FCRAM size
41
42#define MEMORY_SIZE MEM_FCRAM_SIZE
43#define MEMORY_MASK (MEM_FCRAM_SIZE - 1) ///< Main memory mask
44
45////////////////////////////////////////////////////////////////////////////////////////////////////
46
35namespace Memory { 47namespace Memory {
36 48
37extern u8* g_ram; 49// Base is a pointer to the base of the memory map. Yes, some MMU tricks
38extern u8* g_vram; 50// are used to set up a full GC or Wii memory map in process memory. on
51// 32-bit, you have to mask your offsets with 0x3FFFFFFF. This means that
52// some things are mirrored too many times, but eh... it works.
53
54// In 64-bit, this might point to "high memory" (above the 32-bit limit),
55// so be sure to load it into a 64-bit register.
56extern u8 *g_base;
39 57
40extern u32 g_memory_size; 58// These are guaranteed to point to "low memory" addresses (sub-32-bit).
41extern u32 g_memory_mask; 59// 64-bit: Pointers to low-mem (sub-0x10000000) mirror
60// 32-bit: Same as the corresponding physical/virtual pointers.
61extern u8* g_ram; ///< Main memory
62extern u8* g_vram; ///< Video memory (VRAM)
42 63
43void Init(); 64void Init();
44void Shutdown(); 65void Shutdown();