summaryrefslogtreecommitdiff
path: root/src/core/mem_map.h
diff options
context:
space:
mode:
authorGravatar bunnei2014-04-18 17:52:49 -0400
committerGravatar bunnei2014-04-18 17:52:49 -0400
commit958bca606e80110e05d7c142dda3097fddc96503 (patch)
tree576917751444b4dfdb476d040b4e075bde431b7b /src/core/mem_map.h
parentInit window size from VideoCore. Start changing the default window behavior... (diff)
parentrenamed hw_lcd module to just lcd (diff)
downloadyuzu-958bca606e80110e05d7c142dda3097fddc96503.tar.gz
yuzu-958bca606e80110e05d7c142dda3097fddc96503.tar.xz
yuzu-958bca606e80110e05d7c142dda3097fddc96503.zip
Merge branch 'hle-interface'
Diffstat (limited to 'src/core/mem_map.h')
-rw-r--r--src/core/mem_map.h92
1 files changed, 66 insertions, 26 deletions
diff --git a/src/core/mem_map.h b/src/core/mem_map.h
index 1a3bd7234..ab1eb2606 100644
--- a/src/core/mem_map.h
+++ b/src/core/mem_map.h
@@ -4,39 +4,67 @@
4 4
5#pragma once 5#pragma once
6 6
7////////////////////////////////////////////////////////////////////////////////////////////////////
8
9#include "common/common.h" 7#include "common/common.h"
10#include "common/common_types.h" 8#include "common/common_types.h"
11 9
10namespace Memory {
11
12//////////////////////////////////////////////////////////////////////////////////////////////////// 12////////////////////////////////////////////////////////////////////////////////////////////////////
13 13
14enum { 14enum {
15 MEM_BOOTROM_SIZE = 0x00010000, ///< Bootrom (super secret code/data @ 0x8000) size 15 BOOTROM_SIZE = 0x00010000, ///< Bootrom (super secret code/data @ 0x8000) size
16 MEM_MPCORE_PRIV_SIZE = 0x00002000, ///< MPCore private memory region size 16 MPCORE_PRIV_SIZE = 0x00002000, ///< MPCore private memory region size
17 MEM_VRAM_SIZE = 0x00600000, ///< VRAM size 17 VRAM_SIZE = 0x00600000, ///< VRAM size
18 MEM_DSP_SIZE = 0x00080000, ///< DSP memory size 18 DSP_SIZE = 0x00080000, ///< DSP memory size
19 MEM_AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size 19 AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size
20 MEM_FCRAM_SIZE = 0x08000000, ///< FCRAM size... Really 0x07E00000, but power of 2 20 FCRAM_SIZE = 0x08000000, ///< FCRAM size
21 // works much better 21 SCRATCHPAD_SIZE = 0x00004000, ///< Typical stack size - TODO: Read from exheader
22 MEM_SCRATCHPAD_SIZE = 0x00004000, ///< Typical stack size - TODO: Read from exheader 22 HEAP_GSP_SIZE = 0x02000000, ///< GSP heap size... TODO: Define correctly?
23 23 HEAP_SIZE = FCRAM_SIZE, ///< Application heap size
24 MEM_VRAM_MASK = 0x007FFFFF, 24
25 MEM_FCRAM_MASK = (MEM_FCRAM_SIZE - 1), ///< FCRAM mask 25 HEAP_PADDR = HEAP_GSP_SIZE,
26 MEM_SCRATCHPAD_MASK = (MEM_SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask 26 HEAP_PADDR_END = (HEAP_PADDR + HEAP_SIZE),
27 27 HEAP_VADDR = 0x08000000,
28 MEM_FCRAM_PADDR = 0x20000000, ///< FCRAM physical address 28 HEAP_VADDR_END = (HEAP_VADDR + HEAP_SIZE),
29 MEM_FCRAM_PADDR_END = (MEM_FCRAM_PADDR + MEM_FCRAM_SIZE), ///< FCRAM end of physical space 29 HEAP_GSP_VADDR = 0x14000000,
30 MEM_FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address 30 HEAP_GSP_VADDR_END = (HEAP_GSP_VADDR + HEAP_GSP_SIZE),
31 MEM_FCRAM_VADDR_END = (MEM_FCRAM_VADDR + MEM_FCRAM_SIZE), ///< FCRAM end of virtual space 31 HEAP_GSP_PADDR = 0x00000000,
32 32 HEAP_GSP_PADDR_END = (HEAP_GSP_PADDR + HEAP_GSP_SIZE),
33 MEM_VRAM_VADDR = 0x1F000000, 33
34 MEM_SCRATCHPAD_VADDR = (0x10000000 - MEM_SCRATCHPAD_SIZE), ///< Scratchpad virtual address 34 VRAM_MASK = 0x007FFFFF,
35 FCRAM_MASK = (FCRAM_SIZE - 1), ///< FCRAM mask
36 SCRATCHPAD_MASK = (SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask
37 HEAP_GSP_MASK = (HEAP_GSP_SIZE - 1),
38 HEAP_MASK = (HEAP_SIZE - 1),
39
40 FCRAM_PADDR = 0x20000000, ///< FCRAM physical address
41 FCRAM_PADDR_END = (FCRAM_PADDR + FCRAM_SIZE), ///< FCRAM end of physical space
42 FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address
43 FCRAM_VADDR_END = (FCRAM_VADDR + FCRAM_SIZE), ///< FCRAM end of virtual space
44
45 VRAM_VADDR = 0x1F000000,
46 SCRATCHPAD_VADDR_END = 0x10000000,
47 SCRATCHPAD_VADDR = (SCRATCHPAD_VADDR_END - SCRATCHPAD_SIZE), ///< Stack space
35}; 48};
36 49
37//////////////////////////////////////////////////////////////////////////////////////////////////// 50////////////////////////////////////////////////////////////////////////////////////////////////////
38 51
39namespace Memory { 52/// Represents a block of heap memory mapped by ControlMemory
53struct HeapBlock {
54 HeapBlock() : base_address(0), address(0), size(0), operation(0), permissions(0) {
55 }
56 u32 base_address;
57 u32 address;
58 u32 size;
59 u32 operation;
60 u32 permissions;
61
62 const u32 GetVirtualAddress() const{
63 return base_address + address;
64 }
65};
66
67////////////////////////////////////////////////////////////////////////////////////////////////////
40 68
41// Base is a pointer to the base of the memory map. Yes, some MMU tricks 69// Base is a pointer to the base of the memory map. Yes, some MMU tricks
42// are used to set up a full GC or Wii memory map in process memory. on 70// are used to set up a full GC or Wii memory map in process memory. on
@@ -50,9 +78,9 @@ extern u8 *g_base;
50// These are guaranteed to point to "low memory" addresses (sub-32-bit). 78// These are guaranteed to point to "low memory" addresses (sub-32-bit).
51// 64-bit: Pointers to low-mem (sub-0x10000000) mirror 79// 64-bit: Pointers to low-mem (sub-0x10000000) mirror
52// 32-bit: Same as the corresponding physical/virtual pointers. 80// 32-bit: Same as the corresponding physical/virtual pointers.
53extern u8* g_fcram; ///< Main memory 81extern u8* g_heap_gsp; ///< GSP heap (main memory)
54extern u8* g_vram; ///< Video memory (VRAM) 82extern u8* g_heap; ///< Application heap (main memory)
55extern u8* g_scratchpad; ///< Stack memory 83extern u8* g_vram; ///< Video memory (VRAM)
56 84
57void Init(); 85void Init();
58void Shutdown(); 86void Shutdown();
@@ -70,4 +98,16 @@ void Write32(const u32 addr, const u32 data);
70 98
71u8* GetPointer(const u32 Address); 99u8* GetPointer(const u32 Address);
72 100
101/**
102 * Maps a block of memory on the GSP heap
103 * @param size Size of block in bytes
104 * @param operation Control memory operation
105 * @param permissions Control memory permissions
106 */
107u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions);
108
109inline const char* GetCharPointer(const u32 address) {
110 return (const char *)GetPointer(address);
111}
112
73} // namespace 113} // namespace