summaryrefslogtreecommitdiff
path: root/src/core/mem_map.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-05-12 23:38:56 -0300
committerGravatar Yuri Kunde Schlesner2015-05-15 00:04:43 -0300
commitdd4430609afce172542fba1d2cd53c3029f182ce (patch)
treea04ba64d18dd163709b1cb4b4212afaca6c091a6 /src/core/mem_map.cpp
parentMemory: Read SharedPage directly from Memory::Read (diff)
downloadyuzu-dd4430609afce172542fba1d2cd53c3029f182ce.tar.gz
yuzu-dd4430609afce172542fba1d2cd53c3029f182ce.tar.xz
yuzu-dd4430609afce172542fba1d2cd53c3029f182ce.zip
Memory: Use a table based lookup scheme to read from memory regions
Diffstat (limited to 'src/core/mem_map.cpp')
-rw-r--r--src/core/mem_map.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp
index 66c2f77c0..5ecec9566 100644
--- a/src/core/mem_map.cpp
+++ b/src/core/mem_map.cpp
@@ -7,8 +7,11 @@
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/logging/log.h" 8#include "common/logging/log.h"
9 9
10#include "core/hle/config_mem.h"
11#include "core/hle/shared_page.h"
10#include "core/mem_map.h" 12#include "core/mem_map.h"
11#include "core/memory.h" 13#include "core/memory.h"
14#include "core/memory_setup.h"
12 15
13//////////////////////////////////////////////////////////////////////////////////////////////////// 16////////////////////////////////////////////////////////////////////////////////////////////////////
14 17
@@ -26,18 +29,19 @@ namespace {
26 29
27struct MemoryArea { 30struct MemoryArea {
28 u8** ptr; 31 u8** ptr;
29 size_t size; 32 u32 base;
33 u32 size;
30}; 34};
31 35
32// We don't declare the IO regions in here since its handled by other means. 36// We don't declare the IO regions in here since its handled by other means.
33static MemoryArea memory_areas[] = { 37static MemoryArea memory_areas[] = {
34 {&g_exefs_code, PROCESS_IMAGE_MAX_SIZE}, 38 {&g_exefs_code, PROCESS_IMAGE_VADDR, PROCESS_IMAGE_MAX_SIZE},
35 {&g_heap, HEAP_SIZE }, 39 {&g_heap, HEAP_VADDR, HEAP_SIZE },
36 {&g_shared_mem, SHARED_MEMORY_SIZE }, 40 {&g_shared_mem, SHARED_MEMORY_VADDR, SHARED_MEMORY_SIZE },
37 {&g_heap_linear, LINEAR_HEAP_SIZE }, 41 {&g_heap_linear, LINEAR_HEAP_VADDR, LINEAR_HEAP_SIZE },
38 {&g_vram, VRAM_SIZE }, 42 {&g_vram, VRAM_VADDR, VRAM_SIZE },
39 {&g_dsp_mem, DSP_RAM_SIZE }, 43 {&g_dsp_mem, DSP_RAM_VADDR, DSP_RAM_SIZE },
40 {&g_tls_mem, TLS_AREA_SIZE }, 44 {&g_tls_mem, TLS_AREA_VADDR, TLS_AREA_SIZE },
41}; 45};
42 46
43/// Represents a block of memory mapped by ControlMemory/MapMemoryBlock 47/// Represents a block of memory mapped by ControlMemory/MapMemoryBlock
@@ -132,9 +136,14 @@ VAddr PhysicalToVirtualAddress(const PAddr addr) {
132} 136}
133 137
134void Init() { 138void Init() {
139 InitMemoryMap();
140
135 for (MemoryArea& area : memory_areas) { 141 for (MemoryArea& area : memory_areas) {
136 *area.ptr = new u8[area.size]; 142 *area.ptr = new u8[area.size];
143 MapMemoryRegion(area.base, area.size, *area.ptr);
137 } 144 }
145 MapMemoryRegion(CONFIG_MEMORY_VADDR, CONFIG_MEMORY_SIZE, (u8*)&ConfigMem::config_mem);
146 MapMemoryRegion(SHARED_PAGE_VADDR, SHARED_PAGE_SIZE, (u8*)&SharedPage::shared_page);
138 147
139 LOG_DEBUG(HW_Memory, "initialized OK, RAM at %p", g_heap); 148 LOG_DEBUG(HW_Memory, "initialized OK, RAM at %p", g_heap);
140} 149}