diff options
| author | 2015-04-27 21:59:06 -0400 | |
|---|---|---|
| committer | 2015-05-01 18:27:01 -0400 | |
| commit | bbabed8e98e573df5a566aa44f6a05147167b2a7 (patch) | |
| tree | 4b3888a936bd38929815d56a93aa957c569f806b /src | |
| parent | Qt: Create emu thread on bootup, kill it on shutdown. (diff) | |
| download | yuzu-bbabed8e98e573df5a566aa44f6a05147167b2a7.tar.gz yuzu-bbabed8e98e573df5a566aa44f6a05147167b2a7.tar.xz yuzu-bbabed8e98e573df5a566aa44f6a05147167b2a7.zip | |
Memory: Properly cleanup & shutdown.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/mem_map.cpp | 71 | ||||
| -rw-r--r-- | src/core/mem_map.h | 6 | ||||
| -rw-r--r-- | src/core/mem_map_funcs.cpp | 21 |
3 files changed, 60 insertions, 38 deletions
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp index a14e8303e..22e359b3e 100644 --- a/src/core/mem_map.cpp +++ b/src/core/mem_map.cpp | |||
| @@ -11,30 +11,30 @@ | |||
| 11 | 11 | ||
| 12 | namespace Memory { | 12 | namespace Memory { |
| 13 | 13 | ||
| 14 | u8* g_base = nullptr; ///< The base pointer to the auto-mirrored arena. | 14 | u8* g_base; ///< The base pointer to the auto-mirrored arena. |
| 15 | 15 | ||
| 16 | static MemArena arena; ///< The MemArena class | 16 | static MemArena arena; ///< The MemArena class |
| 17 | 17 | ||
| 18 | u8* g_exefs_code = nullptr; ///< ExeFS:/.code is loaded here | 18 | u8* g_exefs_code; ///< ExeFS:/.code is loaded here |
| 19 | u8* g_system_mem = nullptr; ///< System memory | 19 | u8* g_system_mem; ///< System memory |
| 20 | u8* g_heap = nullptr; ///< Application heap (main memory) | 20 | u8* g_heap; ///< Application heap (main memory) |
| 21 | u8* g_heap_linear = nullptr; ///< Linear heap | 21 | u8* g_heap_linear; ///< Linear heap |
| 22 | u8* g_vram = nullptr; ///< Video memory (VRAM) pointer | 22 | u8* g_vram; ///< Video memory (VRAM) pointer |
| 23 | u8* g_shared_mem = nullptr; ///< Shared memory | 23 | u8* g_shared_mem; ///< Shared memory |
| 24 | u8* g_dsp_mem = nullptr; ///< DSP memory | 24 | u8* g_dsp_mem; ///< DSP memory |
| 25 | u8* g_kernel_mem; ///< Kernel memory | 25 | u8* g_kernel_mem; ///< Kernel memory |
| 26 | 26 | ||
| 27 | static u8* physical_bootrom = nullptr; ///< Bootrom physical memory | 27 | static u8* physical_bootrom; ///< Bootrom physical memory |
| 28 | static u8* uncached_bootrom = nullptr; | 28 | static u8* uncached_bootrom; |
| 29 | 29 | ||
| 30 | static u8* physical_exefs_code = nullptr; ///< Phsical ExeFS:/.code is loaded here | 30 | static u8* physical_exefs_code; ///< Phsical ExeFS:/.code is loaded here |
| 31 | static u8* physical_system_mem = nullptr; ///< System physical memory | 31 | static u8* physical_system_mem; ///< System physical memory |
| 32 | static u8* physical_fcram = nullptr; ///< Main physical memory (FCRAM) | 32 | static u8* physical_fcram; ///< Main physical memory (FCRAM) |
| 33 | static u8* physical_heap_gsp = nullptr; ///< GSP heap physical memory | 33 | static u8* physical_heap_gsp; ///< GSP heap physical memory |
| 34 | static u8* physical_vram = nullptr; ///< Video physical memory (VRAM) | 34 | static u8* physical_vram; ///< Video physical memory (VRAM) |
| 35 | static u8* physical_shared_mem = nullptr; ///< Physical shared memory | 35 | static u8* physical_shared_mem; ///< Physical shared memory |
| 36 | static u8* physical_dsp_mem = nullptr; ///< Physical DSP memory | 36 | static u8* physical_dsp_mem; ///< Physical DSP memory |
| 37 | static u8* physical_kernel_mem; ///< Kernel memory | 37 | static u8* physical_kernel_mem; ///< Kernel memory |
| 38 | 38 | ||
| 39 | // We don't declare the IO region in here since its handled by other means. | 39 | // We don't declare the IO region in here since its handled by other means. |
| 40 | static MemoryView g_views[] = { | 40 | static MemoryView g_views[] = { |
| @@ -73,6 +73,7 @@ void Init() { | |||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &arena); | 75 | g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &arena); |
| 76 | MemBlock_Init(); | ||
| 76 | 77 | ||
| 77 | LOG_DEBUG(HW_Memory, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_heap, | 78 | LOG_DEBUG(HW_Memory, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_heap, |
| 78 | physical_fcram); | 79 | physical_fcram); |
| @@ -81,9 +82,29 @@ void Init() { | |||
| 81 | void Shutdown() { | 82 | void Shutdown() { |
| 82 | u32 flags = 0; | 83 | u32 flags = 0; |
| 83 | MemoryMap_Shutdown(g_views, kNumMemViews, flags, &arena); | 84 | MemoryMap_Shutdown(g_views, kNumMemViews, flags, &arena); |
| 84 | |||
| 85 | arena.ReleaseSpace(); | 85 | arena.ReleaseSpace(); |
| 86 | MemBlock_Shutdown(); | ||
| 87 | |||
| 86 | g_base = nullptr; | 88 | g_base = nullptr; |
| 89 | g_exefs_code = nullptr; | ||
| 90 | g_system_mem = nullptr; | ||
| 91 | g_heap = nullptr; | ||
| 92 | g_heap_linear = nullptr; | ||
| 93 | g_vram = nullptr; | ||
| 94 | g_shared_mem = nullptr; | ||
| 95 | g_dsp_mem = nullptr; | ||
| 96 | g_kernel_mem = nullptr; | ||
| 97 | |||
| 98 | physical_bootrom = nullptr; | ||
| 99 | uncached_bootrom = nullptr; | ||
| 100 | physical_exefs_code = nullptr; | ||
| 101 | physical_system_mem = nullptr; | ||
| 102 | physical_fcram = nullptr; | ||
| 103 | physical_heap_gsp = nullptr; | ||
| 104 | physical_vram = nullptr; | ||
| 105 | physical_shared_mem = nullptr; | ||
| 106 | physical_dsp_mem = nullptr; | ||
| 107 | physical_kernel_mem = nullptr; | ||
| 87 | 108 | ||
| 88 | LOG_DEBUG(HW_Memory, "shutdown OK"); | 109 | LOG_DEBUG(HW_Memory, "shutdown OK"); |
| 89 | } | 110 | } |
diff --git a/src/core/mem_map.h b/src/core/mem_map.h index ff730593e..1af02973b 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h | |||
| @@ -171,6 +171,12 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions); | |||
| 171 | */ | 171 | */ |
| 172 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions); | 172 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions); |
| 173 | 173 | ||
| 174 | /// Initialize mapped memory blocks | ||
| 175 | void MemBlock_Init(); | ||
| 176 | |||
| 177 | /// Shutdown mapped memory blocks | ||
| 178 | void MemBlock_Shutdown(); | ||
| 179 | |||
| 174 | inline const char* GetCharPointer(const VAddr address) { | 180 | inline const char* GetCharPointer(const VAddr address) { |
| 175 | return (const char *)GetPointer(address); | 181 | return (const char *)GetPointer(address); |
| 176 | } | 182 | } |
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index 5878b99dc..8759ebdfb 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp | |||
| @@ -15,7 +15,6 @@ namespace Memory { | |||
| 15 | 15 | ||
| 16 | static std::map<u32, MemoryBlock> heap_map; | 16 | static std::map<u32, MemoryBlock> heap_map; |
| 17 | static std::map<u32, MemoryBlock> heap_linear_map; | 17 | static std::map<u32, MemoryBlock> heap_linear_map; |
| 18 | static std::map<u32, MemoryBlock> shared_map; | ||
| 19 | 18 | ||
| 20 | /// Convert a physical address to virtual address | 19 | /// Convert a physical address to virtual address |
| 21 | VAddr PhysicalToVirtualAddress(const PAddr addr) { | 20 | VAddr PhysicalToVirtualAddress(const PAddr addr) { |
| @@ -185,12 +184,6 @@ u8 *GetPointer(const VAddr vaddr) { | |||
| 185 | } | 184 | } |
| 186 | } | 185 | } |
| 187 | 186 | ||
| 188 | /** | ||
| 189 | * Maps a block of memory on the heap | ||
| 190 | * @param size Size of block in bytes | ||
| 191 | * @param operation Memory map operation type | ||
| 192 | * @param flags Memory allocation flags | ||
| 193 | */ | ||
| 194 | u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions) { | 187 | u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions) { |
| 195 | MemoryBlock block; | 188 | MemoryBlock block; |
| 196 | 189 | ||
| @@ -208,12 +201,6 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions) { | |||
| 208 | return block.GetVirtualAddress(); | 201 | return block.GetVirtualAddress(); |
| 209 | } | 202 | } |
| 210 | 203 | ||
| 211 | /** | ||
| 212 | * Maps a block of memory on the linear heap | ||
| 213 | * @param size Size of block in bytes | ||
| 214 | * @param operation Memory map operation type | ||
| 215 | * @param flags Memory allocation flags | ||
| 216 | */ | ||
| 217 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions) { | 204 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions) { |
| 218 | MemoryBlock block; | 205 | MemoryBlock block; |
| 219 | 206 | ||
| @@ -231,6 +218,14 @@ u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions) { | |||
| 231 | return block.GetVirtualAddress(); | 218 | return block.GetVirtualAddress(); |
| 232 | } | 219 | } |
| 233 | 220 | ||
| 221 | void MemBlock_Init() { | ||
| 222 | } | ||
| 223 | |||
| 224 | void MemBlock_Shutdown() { | ||
| 225 | heap_map.clear(); | ||
| 226 | heap_linear_map.clear(); | ||
| 227 | } | ||
| 228 | |||
| 234 | u8 Read8(const VAddr addr) { | 229 | u8 Read8(const VAddr addr) { |
| 235 | u8 data = 0; | 230 | u8 data = 0; |
| 236 | Read<u8>(data, addr); | 231 | Read<u8>(data, addr); |