diff options
| author | 2013-09-05 23:04:04 -0400 | |
|---|---|---|
| committer | 2013-09-05 23:04:04 -0400 | |
| commit | 62d873da3ec77044d0135dbb2c6492eca29482fa (patch) | |
| tree | 3a21f3df2e1784af68f2df5ac98ced6a73f43c20 /src/core | |
| parent | added core and mem_map files to the project (diff) | |
| download | yuzu-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.cpp | 52 | ||||
| -rw-r--r-- | src/core/src/mem_map.h | 29 |
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 | ||
| 27 | namespace Memory { | 33 | namespace Memory { |
| 28 | 34 | ||
| 35 | |||
| 36 | u8* g_mem_base = NULL; ///< The base pointer to the auto-mirrored arena. | ||
| 37 | |||
| 38 | MemArena g_mem_arena; ///< The MemArena class | ||
| 39 | |||
| 40 | u8* g_fcram = NULL; ///< Main memory (FCRAM) pointer | ||
| 41 | u8* g_vram = NULL; ///< Video memory (VRAM) pointer | ||
| 42 | |||
| 43 | u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM) | ||
| 44 | u8* 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. | ||
| 47 | static 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 | |||
| 58 | static const int kNumMemViews = sizeof(g_mem_views) / sizeof(MemoryView); ///< Number of mem views | ||
| 59 | |||
| 29 | u8 Read8(const u32 addr) { | 60 | u8 Read8(const u32 addr) { |
| 30 | return 0xDE; | 61 | return 0xDE; |
| 31 | } | 62 | } |
| @@ -47,6 +78,27 @@ void Write16(const u32 addr, const u32 data) { | |||
| 47 | void Write32(const u32 addr, const u32 data) { | 78 | void Write32(const u32 addr, const u32 data) { |
| 48 | } | 79 | } |
| 49 | 80 | ||
| 81 | void 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 | |||
| 94 | void 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 | |||
| 35 | namespace Memory { | 47 | namespace Memory { |
| 36 | 48 | ||
| 37 | extern u8* g_ram; | 49 | // Base is a pointer to the base of the memory map. Yes, some MMU tricks |
| 38 | extern 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. | ||
| 56 | extern u8 *g_base; | ||
| 39 | 57 | ||
| 40 | extern u32 g_memory_size; | 58 | // These are guaranteed to point to "low memory" addresses (sub-32-bit). |
| 41 | extern u32 g_memory_mask; | 59 | // 64-bit: Pointers to low-mem (sub-0x10000000) mirror |
| 60 | // 32-bit: Same as the corresponding physical/virtual pointers. | ||
| 61 | extern u8* g_ram; ///< Main memory | ||
| 62 | extern u8* g_vram; ///< Video memory (VRAM) | ||
| 42 | 63 | ||
| 43 | void Init(); | 64 | void Init(); |
| 44 | void Shutdown(); | 65 | void Shutdown(); |