summaryrefslogtreecommitdiff
path: root/src/core/mem_map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/mem_map.cpp')
-rw-r--r--src/core/mem_map.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp
new file mode 100644
index 000000000..96f77d32e
--- /dev/null
+++ b/src/core/mem_map.cpp
@@ -0,0 +1,83 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common.h"
6#include "mem_arena.h"
7
8#include "mem_map.h"
9#include "core.h"
10
11////////////////////////////////////////////////////////////////////////////////////////////////////
12
13namespace Memory {
14
15
16u8* g_base = NULL; ///< The base pointer to the auto-mirrored arena.
17
18MemArena g_arena; ///< The MemArena class
19
20u8* g_bootrom = NULL; ///< Bootrom physical memory
21u8* g_fcram = NULL; ///< Main memory (FCRAM) pointer
22u8* g_vram = NULL; ///< Video memory (VRAM) pointer
23u8* g_scratchpad = NULL; ///< Scratchpad memory - Used for main thread stack
24
25u8* g_physical_bootrom = NULL; ///< Bootrom physical memory
26u8* g_uncached_bootrom = NULL;
27
28u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM)
29u8* g_physical_vram = NULL; ///< Video physical memory (VRAM)
30u8* g_physical_scratchpad = NULL; ///< Scratchpad memory used for main thread stack
31
32// We don't declare the IO region in here since its handled by other means.
33static MemoryView g_views[] = {
34 { &g_vram, &g_physical_vram, MEM_VRAM_VADDR, MEM_VRAM_SIZE, 0 },
35 { &g_fcram, &g_physical_fcram, MEM_FCRAM_VADDR, MEM_FCRAM_SIZE, MV_IS_PRIMARY_RAM },
36};
37
38/*static MemoryView views[] =
39{
40 {&m_pScratchPad, &m_pPhysicalScratchPad, 0x00010000, SCRATCHPAD_SIZE, 0},
41 {NULL, &m_pUncachedScratchPad, 0x40010000, SCRATCHPAD_SIZE, MV_MIRROR_PREVIOUS},
42 {&m_pVRAM, &m_pPhysicalVRAM, 0x04000000, 0x00800000, 0},
43 {NULL, &m_pUncachedVRAM, 0x44000000, 0x00800000, MV_MIRROR_PREVIOUS},
44 {&m_pRAM, &m_pPhysicalRAM, 0x08000000, g_MemorySize, MV_IS_PRIMARY_RAM}, // only from 0x08800000 is it usable (last 24 megs)
45 {NULL, &m_pUncachedRAM, 0x48000000, g_MemorySize, MV_MIRROR_PREVIOUS | MV_IS_PRIMARY_RAM},
46 {NULL, &m_pKernelRAM, 0x88000000, g_MemorySize, MV_MIRROR_PREVIOUS | MV_IS_PRIMARY_RAM},
47
48 // TODO: There are a few swizzled mirrors of VRAM, not sure about the best way to
49 // implement those.
50};*/
51
52static const int kNumMemViews = sizeof(g_views) / sizeof(MemoryView); ///< Number of mem views
53
54void Init() {
55 int flags = 0;
56
57 for (size_t i = 0; i < ARRAY_SIZE(g_views); i++) {
58 if (g_views[i].flags & MV_IS_PRIMARY_RAM)
59 g_views[i].size = MEM_FCRAM_SIZE;
60 }
61
62 g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &g_arena);
63
64 g_scratchpad = new u8[MEM_SCRATCHPAD_SIZE];
65
66 NOTICE_LOG(MEMMAP, "Memory system initialized. RAM at %p (mirror at 0 @ %p)", g_fcram,
67 g_physical_fcram);
68}
69
70void Shutdown() {
71 u32 flags = 0;
72 MemoryMap_Shutdown(g_views, kNumMemViews, flags, &g_arena);
73
74 g_arena.ReleaseSpace();
75 delete[] g_scratchpad;
76
77 g_base = NULL;
78 g_scratchpad = NULL;
79
80 NOTICE_LOG(MEMMAP, "Memory system shut down.");
81}
82
83} // namespace