diff options
Diffstat (limited to 'src/core/mem_map_funcs.cpp')
| -rw-r--r-- | src/core/mem_map_funcs.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index 8e97ef111..af4cfacbd 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <map> | ||
| 6 | |||
| 5 | #include "common/common.h" | 7 | #include "common/common.h" |
| 6 | 8 | ||
| 7 | #include "core/mem_map.h" | 9 | #include "core/mem_map.h" |
| @@ -10,6 +12,8 @@ | |||
| 10 | 12 | ||
| 11 | namespace Memory { | 13 | namespace Memory { |
| 12 | 14 | ||
| 15 | std::map<u32, HeapBlock> g_heap_gsp_map; | ||
| 16 | |||
| 13 | /// Convert a physical address to virtual address | 17 | /// Convert a physical address to virtual address |
| 14 | u32 _AddressPhysicalToVirtual(const u32 addr) { | 18 | u32 _AddressPhysicalToVirtual(const u32 addr) { |
| 15 | // Our memory interface read/write functions assume virtual addresses. Put any physical address | 19 | // Our memory interface read/write functions assume virtual addresses. Put any physical address |
| @@ -116,6 +120,28 @@ u8 *GetPointer(const u32 addr) { | |||
| 116 | } | 120 | } |
| 117 | } | 121 | } |
| 118 | 122 | ||
| 123 | /** | ||
| 124 | * Maps a block of memory on the GSP heap | ||
| 125 | * @param size Size of block in bytes | ||
| 126 | * @param flags Memory allocation flags | ||
| 127 | */ | ||
| 128 | u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) { | ||
| 129 | HeapBlock block; | ||
| 130 | |||
| 131 | block.base_address = HEAP_GSP_VADDR; | ||
| 132 | block.size = size; | ||
| 133 | block.operation = operation; | ||
| 134 | block.permissions = permissions; | ||
| 135 | |||
| 136 | if (g_heap_gsp_map.size() > 0) { | ||
| 137 | const HeapBlock last_block = g_heap_gsp_map.rbegin()->second; | ||
| 138 | block.address = last_block.address + last_block.size; | ||
| 139 | } | ||
| 140 | g_heap_gsp_map[block.GetVirtualAddress()] = block; | ||
| 141 | |||
| 142 | return block.GetVirtualAddress(); | ||
| 143 | } | ||
| 144 | |||
| 119 | u8 Read8(const u32 addr) { | 145 | u8 Read8(const u32 addr) { |
| 120 | u8 _var = 0; | 146 | u8 _var = 0; |
| 121 | _Read<u8>(_var, addr); | 147 | _Read<u8>(_var, addr); |