diff options
| author | 2015-05-12 22:38:29 -0300 | |
|---|---|---|
| committer | 2015-05-15 00:04:38 -0300 | |
| commit | 7ada357b2d12cf616672425a8961804b865354d6 (patch) | |
| tree | 983003c1efc0950605eca3aa7d135b7c8fe9edcf /src/core/mem_map.h | |
| parent | Memmap: Remove unused declarations (diff) | |
| download | yuzu-7ada357b2d12cf616672425a8961804b865354d6.tar.gz yuzu-7ada357b2d12cf616672425a8961804b865354d6.tar.xz yuzu-7ada357b2d12cf616672425a8961804b865354d6.zip | |
Memmap: Re-organize memory function in two files
memory.cpp/h contains definitions related to acessing memory and
configuring the address space
mem_map.cpp/h contains higher-level definitions related to configuring
the address space accoording to the kernel and allocating memory.
Diffstat (limited to 'src/core/mem_map.h')
| -rw-r--r-- | src/core/mem_map.h | 148 |
1 files changed, 0 insertions, 148 deletions
diff --git a/src/core/mem_map.h b/src/core/mem_map.h index b6944deb4..945815cd6 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h | |||
| @@ -8,121 +8,6 @@ | |||
| 8 | 8 | ||
| 9 | namespace Memory { | 9 | namespace Memory { |
| 10 | 10 | ||
| 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 12 | |||
| 13 | const u32 PAGE_SIZE = 0x1000; | ||
| 14 | |||
| 15 | /// Physical memory regions as seen from the ARM11 | ||
| 16 | enum : PAddr { | ||
| 17 | /// IO register area | ||
| 18 | IO_AREA_PADDR = 0x10100000, | ||
| 19 | IO_AREA_SIZE = 0x01000000, ///< IO area size (16MB) | ||
| 20 | IO_AREA_PADDR_END = IO_AREA_PADDR + IO_AREA_SIZE, | ||
| 21 | |||
| 22 | /// MPCore internal memory region | ||
| 23 | MPCORE_RAM_PADDR = 0x17E00000, | ||
| 24 | MPCORE_RAM_SIZE = 0x00002000, ///< MPCore internal memory size (8KB) | ||
| 25 | MPCORE_RAM_PADDR_END = MPCORE_RAM_PADDR + MPCORE_RAM_SIZE, | ||
| 26 | |||
| 27 | /// Video memory | ||
| 28 | VRAM_PADDR = 0x18000000, | ||
| 29 | VRAM_SIZE = 0x00600000, ///< VRAM size (6MB) | ||
| 30 | VRAM_PADDR_END = VRAM_PADDR + VRAM_SIZE, | ||
| 31 | |||
| 32 | /// DSP memory | ||
| 33 | DSP_RAM_PADDR = 0x1FF00000, | ||
| 34 | DSP_RAM_SIZE = 0x00080000, ///< DSP memory size (512KB) | ||
| 35 | DSP_RAM_PADDR_END = DSP_RAM_PADDR + DSP_RAM_SIZE, | ||
| 36 | |||
| 37 | /// AXI WRAM | ||
| 38 | AXI_WRAM_PADDR = 0x1FF80000, | ||
| 39 | AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size (512KB) | ||
| 40 | AXI_WRAM_PADDR_END = AXI_WRAM_PADDR + AXI_WRAM_SIZE, | ||
| 41 | |||
| 42 | /// Main FCRAM | ||
| 43 | FCRAM_PADDR = 0x20000000, | ||
| 44 | FCRAM_SIZE = 0x08000000, ///< FCRAM size (128MB) | ||
| 45 | FCRAM_PADDR_END = FCRAM_PADDR + FCRAM_SIZE, | ||
| 46 | }; | ||
| 47 | |||
| 48 | /// Virtual user-space memory regions | ||
| 49 | enum : VAddr { | ||
| 50 | /// Where the application text, data and bss reside. | ||
| 51 | PROCESS_IMAGE_VADDR = 0x00100000, | ||
| 52 | PROCESS_IMAGE_MAX_SIZE = 0x03F00000, | ||
| 53 | PROCESS_IMAGE_VADDR_END = PROCESS_IMAGE_VADDR + PROCESS_IMAGE_MAX_SIZE, | ||
| 54 | |||
| 55 | /// Area where IPC buffers are mapped onto. | ||
| 56 | IPC_MAPPING_VADDR = 0x04000000, | ||
| 57 | IPC_MAPPING_SIZE = 0x04000000, | ||
| 58 | IPC_MAPPING_VADDR_END = IPC_MAPPING_VADDR + IPC_MAPPING_SIZE, | ||
| 59 | |||
| 60 | /// Application heap (includes stack). | ||
| 61 | HEAP_VADDR = 0x08000000, | ||
| 62 | HEAP_SIZE = 0x08000000, | ||
| 63 | HEAP_VADDR_END = HEAP_VADDR + HEAP_SIZE, | ||
| 64 | |||
| 65 | /// Area where shared memory buffers are mapped onto. | ||
| 66 | SHARED_MEMORY_VADDR = 0x10000000, | ||
| 67 | SHARED_MEMORY_SIZE = 0x04000000, | ||
| 68 | SHARED_MEMORY_VADDR_END = SHARED_MEMORY_VADDR + SHARED_MEMORY_SIZE, | ||
| 69 | |||
| 70 | /// Maps 1:1 to an offset in FCRAM. Used for HW allocations that need to be linear in physical memory. | ||
| 71 | LINEAR_HEAP_VADDR = 0x14000000, | ||
| 72 | LINEAR_HEAP_SIZE = 0x08000000, | ||
| 73 | LINEAR_HEAP_VADDR_END = LINEAR_HEAP_VADDR + LINEAR_HEAP_SIZE, | ||
| 74 | |||
| 75 | /// Maps 1:1 to the IO register area. | ||
| 76 | IO_AREA_VADDR = 0x1EC00000, | ||
| 77 | IO_AREA_VADDR_END = IO_AREA_VADDR + IO_AREA_SIZE, | ||
| 78 | |||
| 79 | /// Maps 1:1 to VRAM. | ||
| 80 | VRAM_VADDR = 0x1F000000, | ||
| 81 | VRAM_VADDR_END = VRAM_VADDR + VRAM_SIZE, | ||
| 82 | |||
| 83 | /// Maps 1:1 to DSP memory. | ||
| 84 | DSP_RAM_VADDR = 0x1FF00000, | ||
| 85 | DSP_RAM_VADDR_END = DSP_RAM_VADDR + DSP_RAM_SIZE, | ||
| 86 | |||
| 87 | /// Read-only page containing kernel and system configuration values. | ||
| 88 | CONFIG_MEMORY_VADDR = 0x1FF80000, | ||
| 89 | CONFIG_MEMORY_SIZE = 0x00001000, | ||
| 90 | CONFIG_MEMORY_VADDR_END = CONFIG_MEMORY_VADDR + CONFIG_MEMORY_SIZE, | ||
| 91 | |||
| 92 | /// Usually read-only page containing mostly values read from hardware. | ||
| 93 | SHARED_PAGE_VADDR = 0x1FF81000, | ||
| 94 | SHARED_PAGE_SIZE = 0x00001000, | ||
| 95 | SHARED_PAGE_VADDR_END = SHARED_PAGE_VADDR + SHARED_PAGE_SIZE, | ||
| 96 | |||
| 97 | // TODO(yuriks): The size of this area is dynamic, the kernel grows | ||
| 98 | // it as more and more threads are created. For now we'll just use a | ||
| 99 | // hardcoded value. | ||
| 100 | /// Area where TLS (Thread-Local Storage) buffers are allocated. | ||
| 101 | TLS_AREA_VADDR = 0x1FF82000, | ||
| 102 | TLS_AREA_SIZE = 0x00030000, // Each TLS buffer is 0x200 bytes, allows for 300 threads | ||
| 103 | TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE, | ||
| 104 | }; | ||
| 105 | |||
| 106 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 107 | |||
| 108 | /// Represents a block of memory mapped by ControlMemory/MapMemoryBlock | ||
| 109 | struct MemoryBlock { | ||
| 110 | MemoryBlock() : handle(0), base_address(0), address(0), size(0), operation(0), permissions(0) { | ||
| 111 | } | ||
| 112 | u32 handle; | ||
| 113 | u32 base_address; | ||
| 114 | u32 address; | ||
| 115 | u32 size; | ||
| 116 | u32 operation; | ||
| 117 | u32 permissions; | ||
| 118 | |||
| 119 | const u32 GetVirtualAddress() const{ | ||
| 120 | return base_address + address; | ||
| 121 | } | ||
| 122 | }; | ||
| 123 | |||
| 124 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 125 | |||
| 126 | extern u8* g_exefs_code; ///< ExeFS:/.code is loaded here | 11 | extern u8* g_exefs_code; ///< ExeFS:/.code is loaded here |
| 127 | extern u8* g_heap; ///< Application heap (main memory) | 12 | extern u8* g_heap; ///< Application heap (main memory) |
| 128 | extern u8* g_shared_mem; ///< Shared memory | 13 | extern u8* g_shared_mem; ///< Shared memory |
| @@ -134,20 +19,6 @@ extern u8* g_tls_mem; ///< TLS memory | |||
| 134 | void Init(); | 19 | void Init(); |
| 135 | void Shutdown(); | 20 | void Shutdown(); |
| 136 | 21 | ||
| 137 | u8 Read8(VAddr addr); | ||
| 138 | u16 Read16(VAddr addr); | ||
| 139 | u32 Read32(VAddr addr); | ||
| 140 | u64 Read64(VAddr addr); | ||
| 141 | |||
| 142 | void Write8(VAddr addr, u8 data); | ||
| 143 | void Write16(VAddr addr, u16 data); | ||
| 144 | void Write32(VAddr addr, u32 data); | ||
| 145 | void Write64(VAddr addr, u64 data); | ||
| 146 | |||
| 147 | void WriteBlock(VAddr addr, const u8* data, size_t size); | ||
| 148 | |||
| 149 | u8* GetPointer(VAddr virtual_address); | ||
| 150 | |||
| 151 | /** | 22 | /** |
| 152 | * Maps a block of memory on the heap | 23 | * Maps a block of memory on the heap |
| 153 | * @param size Size of block in bytes | 24 | * @param size Size of block in bytes |
| @@ -164,16 +35,6 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions); | |||
| 164 | */ | 35 | */ |
| 165 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions); | 36 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions); |
| 166 | 37 | ||
| 167 | /// Initialize mapped memory blocks | ||
| 168 | void MemBlock_Init(); | ||
| 169 | |||
| 170 | /// Shutdown mapped memory blocks | ||
| 171 | void MemBlock_Shutdown(); | ||
| 172 | |||
| 173 | inline const char* GetCharPointer(const VAddr address) { | ||
| 174 | return (const char *)GetPointer(address); | ||
| 175 | } | ||
| 176 | |||
| 177 | /** | 38 | /** |
| 178 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical | 39 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical |
| 179 | * address. This should be used by services to translate addresses for use by the hardware. | 40 | * address. This should be used by services to translate addresses for use by the hardware. |
| @@ -185,13 +46,4 @@ PAddr VirtualToPhysicalAddress(VAddr addr); | |||
| 185 | */ | 46 | */ |
| 186 | VAddr PhysicalToVirtualAddress(PAddr addr); | 47 | VAddr PhysicalToVirtualAddress(PAddr addr); |
| 187 | 48 | ||
| 188 | /** | ||
| 189 | * Gets a pointer to the memory region beginning at the specified physical address. | ||
| 190 | * | ||
| 191 | * @note This is currently implemented using PhysicalToVirtualAddress(). | ||
| 192 | */ | ||
| 193 | inline u8* GetPhysicalPointer(PAddr address) { | ||
| 194 | return GetPointer(PhysicalToVirtualAddress(address)); | ||
| 195 | } | ||
| 196 | |||
| 197 | } // namespace | 49 | } // namespace |