summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar bunnei2014-04-24 22:32:26 -0400
committerGravatar bunnei2014-04-24 22:32:26 -0400
commitb7cd4c9e90be42476a2e242571d36cbbca2fbd4c (patch)
treeded61f0cc1b93a96226a849388348feca591cfa5 /src/core
parentadded GSP::RegisterInterruptRelayQueue function (diff)
downloadyuzu-b7cd4c9e90be42476a2e242571d36cbbca2fbd4c.tar.gz
yuzu-b7cd4c9e90be42476a2e242571d36cbbca2fbd4c.tar.xz
yuzu-b7cd4c9e90be42476a2e242571d36cbbca2fbd4c.zip
added functions to map Heap and Shared memory space
Diffstat (limited to 'src/core')
-rw-r--r--src/core/mem_map.cpp4
-rw-r--r--src/core/mem_map.h27
-rw-r--r--src/core/mem_map_funcs.cpp54
3 files changed, 76 insertions, 9 deletions
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp
index 180829239..f0090206e 100644
--- a/src/core/mem_map.cpp
+++ b/src/core/mem_map.cpp
@@ -16,15 +16,15 @@ u8* g_base = NULL; ///< The base pointer to the aut
16 16
17MemArena g_arena; ///< The MemArena class 17MemArena g_arena; ///< The MemArena class
18 18
19u8* g_heap_gsp = NULL; ///< GSP heap (main memory)
20u8* g_heap = NULL; ///< Application heap (main memory) 19u8* g_heap = NULL; ///< Application heap (main memory)
20u8* g_heap_gsp = NULL; ///< GSP heap (main memory)
21u8* g_vram = NULL; ///< Video memory (VRAM) pointer 21u8* g_vram = NULL; ///< Video memory (VRAM) pointer
22 22
23u8* g_physical_bootrom = NULL; ///< Bootrom physical memory 23u8* g_physical_bootrom = NULL; ///< Bootrom physical memory
24u8* g_uncached_bootrom = NULL; 24u8* g_uncached_bootrom = NULL;
25 25
26u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM) 26u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM)
27u8* g_physical_heap_gsp = NULL; 27u8* g_physical_heap_gsp = NULL; ///< GSP heap physical memory
28u8* g_physical_vram = NULL; ///< Video physical memory (VRAM) 28u8* g_physical_vram = NULL; ///< Video physical memory (VRAM)
29u8* g_physical_scratchpad = NULL; ///< Scratchpad memory used for main thread stack 29u8* g_physical_scratchpad = NULL; ///< Scratchpad memory used for main thread stack
30 30
diff --git a/src/core/mem_map.h b/src/core/mem_map.h
index ab1eb2606..5346d04ee 100644
--- a/src/core/mem_map.h
+++ b/src/core/mem_map.h
@@ -22,6 +22,8 @@ enum {
22 HEAP_GSP_SIZE = 0x02000000, ///< GSP heap size... TODO: Define correctly? 22 HEAP_GSP_SIZE = 0x02000000, ///< GSP heap size... TODO: Define correctly?
23 HEAP_SIZE = FCRAM_SIZE, ///< Application heap size 23 HEAP_SIZE = FCRAM_SIZE, ///< Application heap size
24 24
25 SHARED_MEMORY_VADDR = 0x10000000, ///< Shared memory
26
25 HEAP_PADDR = HEAP_GSP_SIZE, 27 HEAP_PADDR = HEAP_GSP_SIZE,
26 HEAP_PADDR_END = (HEAP_PADDR + HEAP_SIZE), 28 HEAP_PADDR_END = (HEAP_PADDR + HEAP_SIZE),
27 HEAP_VADDR = 0x08000000, 29 HEAP_VADDR = 0x08000000,
@@ -49,10 +51,11 @@ enum {
49 51
50//////////////////////////////////////////////////////////////////////////////////////////////////// 52////////////////////////////////////////////////////////////////////////////////////////////////////
51 53
52/// Represents a block of heap memory mapped by ControlMemory 54/// Represents a block of memory mapped by ControlMemory/MapMemoryBlock
53struct HeapBlock { 55struct MemoryBlock {
54 HeapBlock() : base_address(0), address(0), size(0), operation(0), permissions(0) { 56 MemoryBlock() : handle(0), base_address(0), address(0), size(0), operation(0), permissions(0) {
55 } 57 }
58 u32 handle;
56 u32 base_address; 59 u32 base_address;
57 u32 address; 60 u32 address;
58 u32 size; 61 u32 size;
@@ -99,9 +102,25 @@ void Write32(const u32 addr, const u32 data);
99u8* GetPointer(const u32 Address); 102u8* GetPointer(const u32 Address);
100 103
101/** 104/**
105 * Maps a block of memory in shared memory
106 * @param handle Handle to map memory block for
107 * @param addr Address to map memory block to
108 * @param permissions Memory map permissions
109 */
110u32 MapBlock_Shared(u32 handle, u32 addr,u32 permissions) ;
111
112/**
113 * Maps a block of memory on the heap
114 * @param size Size of block in bytes
115 * @param operation Memory map operation type
116 * @param flags Memory allocation flags
117 */
118u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions);
119
120/**
102 * Maps a block of memory on the GSP heap 121 * Maps a block of memory on the GSP heap
103 * @param size Size of block in bytes 122 * @param size Size of block in bytes
104 * @param operation Control memory operation 123 * @param operation Memory map operation type
105 * @param permissions Control memory permissions 124 * @param permissions Control memory permissions
106 */ 125 */
107u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions); 126u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions);
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp
index af4cfacbd..eff0cf4b8 100644
--- a/src/core/mem_map_funcs.cpp
+++ b/src/core/mem_map_funcs.cpp
@@ -12,7 +12,9 @@
12 12
13namespace Memory { 13namespace Memory {
14 14
15std::map<u32, HeapBlock> g_heap_gsp_map; 15std::map<u32, MemoryBlock> g_heap_map;
16std::map<u32, MemoryBlock> g_heap_gsp_map;
17std::map<u32, MemoryBlock> g_shared_map;
16 18
17/// Convert a physical address to virtual address 19/// Convert a physical address to virtual address
18u32 _AddressPhysicalToVirtual(const u32 addr) { 20u32 _AddressPhysicalToVirtual(const u32 addr) {
@@ -121,12 +123,58 @@ u8 *GetPointer(const u32 addr) {
121} 123}
122 124
123/** 125/**
126 * Maps a block of memory in shared memory
127 * @param handle Handle to map memory block for
128 * @param addr Address to map memory block to
129 * @param permissions Memory map permissions
130 */
131u32 MapBlock_Shared(u32 handle, u32 addr,u32 permissions) {
132 MemoryBlock block;
133
134 block.handle = handle;
135 block.base_address = addr;
136 block.permissions = permissions;
137
138 if (g_shared_map.size() > 0) {
139 const MemoryBlock last_block = g_shared_map.rbegin()->second;
140 block.address = last_block.address + last_block.size;
141 }
142 g_shared_map[block.GetVirtualAddress()] = block;
143
144 return block.GetVirtualAddress();
145}
146
147/**
148 * Maps a block of memory on the heap
149 * @param size Size of block in bytes
150 * @param operation Memory map operation type
151 * @param flags Memory allocation flags
152 */
153u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions) {
154 MemoryBlock block;
155
156 block.base_address = HEAP_VADDR;
157 block.size = size;
158 block.operation = operation;
159 block.permissions = permissions;
160
161 if (g_heap_map.size() > 0) {
162 const MemoryBlock last_block = g_heap_map.rbegin()->second;
163 block.address = last_block.address + last_block.size;
164 }
165 g_heap_map[block.GetVirtualAddress()] = block;
166
167 return block.GetVirtualAddress();
168}
169
170/**
124 * Maps a block of memory on the GSP heap 171 * Maps a block of memory on the GSP heap
125 * @param size Size of block in bytes 172 * @param size Size of block in bytes
173 * @param operation Memory map operation type
126 * @param flags Memory allocation flags 174 * @param flags Memory allocation flags
127 */ 175 */
128u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) { 176u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) {
129 HeapBlock block; 177 MemoryBlock block;
130 178
131 block.base_address = HEAP_GSP_VADDR; 179 block.base_address = HEAP_GSP_VADDR;
132 block.size = size; 180 block.size = size;
@@ -134,7 +182,7 @@ u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) {
134 block.permissions = permissions; 182 block.permissions = permissions;
135 183
136 if (g_heap_gsp_map.size() > 0) { 184 if (g_heap_gsp_map.size() > 0) {
137 const HeapBlock last_block = g_heap_gsp_map.rbegin()->second; 185 const MemoryBlock last_block = g_heap_gsp_map.rbegin()->second;
138 block.address = last_block.address + last_block.size; 186 block.address = last_block.address + last_block.size;
139 } 187 }
140 g_heap_gsp_map[block.GetVirtualAddress()] = block; 188 g_heap_gsp_map[block.GetVirtualAddress()] = block;