diff options
| -rw-r--r-- | src/core/src/mem_map.cpp | 53 | ||||
| -rw-r--r-- | src/core/src/mem_map.h | 2 |
2 files changed, 36 insertions, 19 deletions
diff --git a/src/core/src/mem_map.cpp b/src/core/src/mem_map.cpp index 8793fdc8d..0d3c6ca12 100644 --- a/src/core/src/mem_map.cpp +++ b/src/core/src/mem_map.cpp | |||
| @@ -33,29 +33,47 @@ | |||
| 33 | namespace Memory { | 33 | namespace Memory { |
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | u8* g_mem_base = NULL; ///< The base pointer to the auto-mirrored arena. | 36 | u8* g_base = NULL; ///< The base pointer to the auto-mirrored arena. |
| 37 | 37 | ||
| 38 | MemArena g_mem_arena; ///< The MemArena class | 38 | MemArena g_arena; ///< The MemArena class |
| 39 | 39 | ||
| 40 | u8* g_bootrom = NULL; ///< Bootrom memory (super secret code/data @ 0x8000) pointer | ||
| 40 | u8* g_fcram = NULL; ///< Main memory (FCRAM) pointer | 41 | u8* g_fcram = NULL; ///< Main memory (FCRAM) pointer |
| 41 | u8* g_vram = NULL; ///< Video memory (VRAM) pointer | 42 | u8* g_vram = NULL; ///< Video memory (VRAM) pointer |
| 42 | 43 | ||
| 44 | u8* g_physical_bootrom = NULL; ///< Bootrom physical memory (super secret code/data @ 0x8000) | ||
| 45 | u8* g_uncached_bootrom = NULL; | ||
| 46 | |||
| 43 | u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM) | 47 | u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM) |
| 44 | u8* g_physical_vram = NULL; ///< Video physical memory (VRAM) | 48 | u8* g_physical_vram = NULL; ///< Video physical memory (VRAM) |
| 45 | 49 | ||
| 46 | // We don't declare the IO region in here since its handled by other means. | 50 | // We don't declare the IO region in here since its handled by other means. |
| 47 | static MemoryView g_mem_views[] = | 51 | static MemoryView g_views[] = |
| 48 | { | 52 | { |
| 49 | {NULL, NULL, 0x00000000, MEM_BOOTROM_SIZE, 0}, | 53 | {&g_bootrom, &g_physical_bootrom, 0x00000000, MEM_BOOTROM_SIZE, 0}, |
| 50 | {NULL, NULL, 0x00010000, MEM_BOOTROM_SIZE, MV_MIRROR_PREVIOUS}, | 54 | {NULL, &g_uncached_bootrom, 0x00010000, MEM_BOOTROM_SIZE, MV_MIRROR_PREVIOUS}, |
| 51 | {NULL, NULL, 0x17E00000, MEM_MPCORE_PRIV_SIZE, 0}, | 55 | // //{NULL, NULL, 0x17E00000, MEM_MPCORE_PRIV_SIZE, 0}, |
| 52 | {&g_vram, &g_physical_vram, 0x18000000, MEM_VRAM_SIZE, 0}, | 56 | {&g_vram, &g_physical_vram, 0x18000000, MEM_VRAM_SIZE, 0}, |
| 53 | {NULL, NULL, 0x1FF00000, MEM_DSP_SIZE, 0}, | 57 | // //{NULL, NULL, 0x1FF00000, MEM_DSP_SIZE, 0}, |
| 54 | {NULL, NULL, 0x1FF80000, MEM_AXI_WRAM_SIZE, 0}, | 58 | // //{NULL, NULL, 0x1FF80000, MEM_AXI_WRAM_SIZE, 0}, |
| 55 | {&g_ram, &g_physical_fcram, 0x20000000, MEM_FCRAM_SIZE, MV_IS_PRIMARY_RAM}, | 59 | {&g_fcram, &g_physical_fcram, 0x20000000, MEM_FCRAM_SIZE, MV_IS_PRIMARY_RAM}, |
| 56 | }; | 60 | }; |
| 57 | 61 | ||
| 58 | static const int kNumMemViews = sizeof(g_mem_views) / sizeof(MemoryView); ///< Number of mem views | 62 | /*static MemoryView views[] = |
| 63 | { | ||
| 64 | {&m_pScratchPad, &m_pPhysicalScratchPad, 0x00010000, SCRATCHPAD_SIZE, 0}, | ||
| 65 | {NULL, &m_pUncachedScratchPad, 0x40010000, SCRATCHPAD_SIZE, MV_MIRROR_PREVIOUS}, | ||
| 66 | {&m_pVRAM, &m_pPhysicalVRAM, 0x04000000, 0x00800000, 0}, | ||
| 67 | {NULL, &m_pUncachedVRAM, 0x44000000, 0x00800000, MV_MIRROR_PREVIOUS}, | ||
| 68 | {&m_pRAM, &m_pPhysicalRAM, 0x08000000, g_MemorySize, MV_IS_PRIMARY_RAM}, // only from 0x08800000 is it usable (last 24 megs) | ||
| 69 | {NULL, &m_pUncachedRAM, 0x48000000, g_MemorySize, MV_MIRROR_PREVIOUS | MV_IS_PRIMARY_RAM}, | ||
| 70 | {NULL, &m_pKernelRAM, 0x88000000, g_MemorySize, MV_MIRROR_PREVIOUS | MV_IS_PRIMARY_RAM}, | ||
| 71 | |||
| 72 | // TODO: There are a few swizzled mirrors of VRAM, not sure about the best way to | ||
| 73 | // implement those. | ||
| 74 | };*/ | ||
| 75 | |||
| 76 | static const int kNumMemViews = sizeof(g_views) / sizeof(MemoryView); ///< Number of mem views | ||
| 59 | 77 | ||
| 60 | u8 Read8(const u32 addr) { | 78 | u8 Read8(const u32 addr) { |
| 61 | return 0xDE; | 79 | return 0xDE; |
| @@ -81,11 +99,10 @@ void Write32(const u32 addr, const u32 data) { | |||
| 81 | void Init() { | 99 | void Init() { |
| 82 | int flags = 0; | 100 | int flags = 0; |
| 83 | 101 | ||
| 84 | for (size_t i = 0; i < ARRAY_SIZE(g_mem_views); i++) { | 102 | for (size_t i = 0; i < ARRAY_SIZE(g_views); i++) { |
| 85 | if (g_mem_views[i].flags & MV_IS_PRIMARY_RAM) | 103 | if (g_views[i].flags & MV_IS_PRIMARY_RAM) |
| 86 | g_mem_views[i].size = MEMORY_SIZE; | 104 | g_views[i].size = MEMORY_SIZE; |
| 87 | } | 105 | } |
| 88 | g_base = MemoryMap_Setup(g_mem_views, kNumMemViews, flags, &g_mem_arena); | ||
| 89 | 106 | ||
| 90 | INFO_LOG(MEMMAP, "Memory system initialized. RAM at %p (mirror at 0 @ %p)", g_fcram, | 107 | INFO_LOG(MEMMAP, "Memory system initialized. RAM at %p (mirror at 0 @ %p)", g_fcram, |
| 91 | g_physical_fcram); | 108 | g_physical_fcram); |
| @@ -93,9 +110,9 @@ void Init() { | |||
| 93 | 110 | ||
| 94 | void Shutdown() { | 111 | void Shutdown() { |
| 95 | u32 flags = 0; | 112 | u32 flags = 0; |
| 96 | MemoryMap_Shutdown(g_mem_views, kNumMemViews, flags, &g_mem_arena); | 113 | MemoryMap_Shutdown(g_views, kNumMemViews, flags, &g_arena); |
| 97 | g_mem_arena.ReleaseSpace(); | 114 | g_arena.ReleaseSpace(); |
| 98 | g_mem_base = NULL; | 115 | g_base = NULL; |
| 99 | INFO_LOG(MEMMAP, "Memory system shut down."); | 116 | INFO_LOG(MEMMAP, "Memory system shut down."); |
| 100 | } | 117 | } |
| 101 | 118 | ||
diff --git a/src/core/src/mem_map.h b/src/core/src/mem_map.h index 29ec2e7a9..a6370f766 100644 --- a/src/core/src/mem_map.h +++ b/src/core/src/mem_map.h | |||
| @@ -58,7 +58,7 @@ extern u8 *g_base; | |||
| 58 | // These are guaranteed to point to "low memory" addresses (sub-32-bit). | 58 | // These are guaranteed to point to "low memory" addresses (sub-32-bit). |
| 59 | // 64-bit: Pointers to low-mem (sub-0x10000000) mirror | 59 | // 64-bit: Pointers to low-mem (sub-0x10000000) mirror |
| 60 | // 32-bit: Same as the corresponding physical/virtual pointers. | 60 | // 32-bit: Same as the corresponding physical/virtual pointers. |
| 61 | extern u8* g_ram; ///< Main memory | 61 | extern u8* g_fcram; ///< Main memory |
| 62 | extern u8* g_vram; ///< Video memory (VRAM) | 62 | extern u8* g_vram; ///< Video memory (VRAM) |
| 63 | 63 | ||
| 64 | void Init(); | 64 | void Init(); |