diff options
Diffstat (limited to 'src/core/memory.h')
| -rw-r--r-- | src/core/memory.h | 88 |
1 files changed, 1 insertions, 87 deletions
diff --git a/src/core/memory.h b/src/core/memory.h index 8d5d017a4..b5d885b8a 100644 --- a/src/core/memory.h +++ b/src/core/memory.h | |||
| @@ -6,12 +6,9 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <cstddef> | 8 | #include <cstddef> |
| 9 | #include <map> | ||
| 10 | #include <string> | 9 | #include <string> |
| 11 | #include <tuple> | 10 | #include <tuple> |
| 12 | #include <vector> | ||
| 13 | #include <boost/icl/interval_map.hpp> | 11 | #include <boost/icl/interval_map.hpp> |
| 14 | #include <boost/optional.hpp> | ||
| 15 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 16 | #include "core/memory_hook.h" | 13 | #include "core/memory_hook.h" |
| 17 | #include "video_core/memory_manager.h" | 14 | #include "video_core/memory_manager.h" |
| @@ -85,40 +82,6 @@ struct PageTable { | |||
| 85 | std::array<PageType, PAGE_TABLE_NUM_ENTRIES> attributes; | 82 | std::array<PageType, PAGE_TABLE_NUM_ENTRIES> attributes; |
| 86 | }; | 83 | }; |
| 87 | 84 | ||
| 88 | /// Physical memory regions as seen from the ARM11 | ||
| 89 | enum : PAddr { | ||
| 90 | /// IO register area | ||
| 91 | IO_AREA_PADDR = 0x10100000, | ||
| 92 | IO_AREA_SIZE = 0x01000000, ///< IO area size (16MB) | ||
| 93 | IO_AREA_PADDR_END = IO_AREA_PADDR + IO_AREA_SIZE, | ||
| 94 | |||
| 95 | /// MPCore internal memory region | ||
| 96 | MPCORE_RAM_PADDR = 0x17E00000, | ||
| 97 | MPCORE_RAM_SIZE = 0x00002000, ///< MPCore internal memory size (8KB) | ||
| 98 | MPCORE_RAM_PADDR_END = MPCORE_RAM_PADDR + MPCORE_RAM_SIZE, | ||
| 99 | |||
| 100 | /// Video memory | ||
| 101 | VRAM_PADDR = 0x18000000, | ||
| 102 | VRAM_SIZE = 0x00600000, ///< VRAM size (6MB) | ||
| 103 | VRAM_PADDR_END = VRAM_PADDR + VRAM_SIZE, | ||
| 104 | |||
| 105 | /// DSP memory | ||
| 106 | DSP_RAM_PADDR = 0x1FF00000, | ||
| 107 | DSP_RAM_SIZE = 0x00080000, ///< DSP memory size (512KB) | ||
| 108 | DSP_RAM_PADDR_END = DSP_RAM_PADDR + DSP_RAM_SIZE, | ||
| 109 | |||
| 110 | /// AXI WRAM | ||
| 111 | AXI_WRAM_PADDR = 0x1FF80000, | ||
| 112 | AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size (512KB) | ||
| 113 | AXI_WRAM_PADDR_END = AXI_WRAM_PADDR + AXI_WRAM_SIZE, | ||
| 114 | |||
| 115 | /// Main FCRAM | ||
| 116 | FCRAM_PADDR = 0x20000000, | ||
| 117 | FCRAM_SIZE = 0x08000000, ///< FCRAM size on the Old 3DS (128MB) | ||
| 118 | FCRAM_N3DS_SIZE = 0x10000000, ///< FCRAM size on the New 3DS (256MB) | ||
| 119 | FCRAM_PADDR_END = FCRAM_PADDR + FCRAM_SIZE, | ||
| 120 | }; | ||
| 121 | |||
| 122 | /// Virtual user-space memory regions | 85 | /// Virtual user-space memory regions |
| 123 | enum : VAddr { | 86 | enum : VAddr { |
| 124 | /// Where the application text, data and bss reside. | 87 | /// Where the application text, data and bss reside. |
| @@ -126,24 +89,6 @@ enum : VAddr { | |||
| 126 | PROCESS_IMAGE_MAX_SIZE = 0x08000000, | 89 | PROCESS_IMAGE_MAX_SIZE = 0x08000000, |
| 127 | PROCESS_IMAGE_VADDR_END = PROCESS_IMAGE_VADDR + PROCESS_IMAGE_MAX_SIZE, | 90 | PROCESS_IMAGE_VADDR_END = PROCESS_IMAGE_VADDR + PROCESS_IMAGE_MAX_SIZE, |
| 128 | 91 | ||
| 129 | /// Maps 1:1 to an offset in FCRAM. Used for HW allocations that need to be linear in physical | ||
| 130 | /// memory. | ||
| 131 | LINEAR_HEAP_VADDR = 0x14000000, | ||
| 132 | LINEAR_HEAP_SIZE = 0x08000000, | ||
| 133 | LINEAR_HEAP_VADDR_END = LINEAR_HEAP_VADDR + LINEAR_HEAP_SIZE, | ||
| 134 | |||
| 135 | /// Maps 1:1 to the IO register area. | ||
| 136 | IO_AREA_VADDR = 0x1EC00000, | ||
| 137 | IO_AREA_VADDR_END = IO_AREA_VADDR + IO_AREA_SIZE, | ||
| 138 | |||
| 139 | /// Maps 1:1 to VRAM. | ||
| 140 | VRAM_VADDR = 0x1F000000, | ||
| 141 | VRAM_VADDR_END = VRAM_VADDR + VRAM_SIZE, | ||
| 142 | |||
| 143 | /// Maps 1:1 to DSP memory. | ||
| 144 | DSP_RAM_VADDR = 0x1FF00000, | ||
| 145 | DSP_RAM_VADDR_END = DSP_RAM_VADDR + DSP_RAM_SIZE, | ||
| 146 | |||
| 147 | /// Read-only page containing kernel and system configuration values. | 92 | /// Read-only page containing kernel and system configuration values. |
| 148 | CONFIG_MEMORY_VADDR = 0x1FF80000, | 93 | CONFIG_MEMORY_VADDR = 0x1FF80000, |
| 149 | CONFIG_MEMORY_SIZE = 0x00001000, | 94 | CONFIG_MEMORY_SIZE = 0x00001000, |
| @@ -154,13 +99,8 @@ enum : VAddr { | |||
| 154 | SHARED_PAGE_SIZE = 0x00001000, | 99 | SHARED_PAGE_SIZE = 0x00001000, |
| 155 | SHARED_PAGE_VADDR_END = SHARED_PAGE_VADDR + SHARED_PAGE_SIZE, | 100 | SHARED_PAGE_VADDR_END = SHARED_PAGE_VADDR + SHARED_PAGE_SIZE, |
| 156 | 101 | ||
| 157 | /// Equivalent to LINEAR_HEAP_VADDR, but expanded to cover the extra memory in the New 3DS. | ||
| 158 | NEW_LINEAR_HEAP_VADDR = 0x30000000, | ||
| 159 | NEW_LINEAR_HEAP_SIZE = 0x10000000, | ||
| 160 | NEW_LINEAR_HEAP_VADDR_END = NEW_LINEAR_HEAP_VADDR + NEW_LINEAR_HEAP_SIZE, | ||
| 161 | |||
| 162 | /// Area where TLS (Thread-Local Storage) buffers are allocated. | 102 | /// Area where TLS (Thread-Local Storage) buffers are allocated. |
| 163 | TLS_AREA_VADDR = NEW_LINEAR_HEAP_VADDR_END, | 103 | TLS_AREA_VADDR = 0x40000000, |
| 164 | TLS_ENTRY_SIZE = 0x200, | 104 | TLS_ENTRY_SIZE = 0x200, |
| 165 | TLS_AREA_SIZE = 0x10000000, | 105 | TLS_AREA_SIZE = 0x10000000, |
| 166 | TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE, | 106 | TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE, |
| @@ -205,8 +145,6 @@ bool IsValidVirtualAddress(const VAddr addr); | |||
| 205 | /// Determines if the given VAddr is a kernel address | 145 | /// Determines if the given VAddr is a kernel address |
| 206 | bool IsKernelVirtualAddress(const VAddr addr); | 146 | bool IsKernelVirtualAddress(const VAddr addr); |
| 207 | 147 | ||
| 208 | bool IsValidPhysicalAddress(const PAddr addr); | ||
| 209 | |||
| 210 | u8 Read8(VAddr addr); | 148 | u8 Read8(VAddr addr); |
| 211 | u16 Read16(VAddr addr); | 149 | u16 Read16(VAddr addr); |
| 212 | u32 Read32(VAddr addr); | 150 | u32 Read32(VAddr addr); |
| @@ -230,30 +168,6 @@ u8* GetPointer(VAddr virtual_address); | |||
| 230 | 168 | ||
| 231 | std::string ReadCString(VAddr virtual_address, std::size_t max_length); | 169 | std::string ReadCString(VAddr virtual_address, std::size_t max_length); |
| 232 | 170 | ||
| 233 | /** | ||
| 234 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical | ||
| 235 | * address. This should be used by services to translate addresses for use by the hardware. | ||
| 236 | */ | ||
| 237 | boost::optional<PAddr> TryVirtualToPhysicalAddress(VAddr addr); | ||
| 238 | |||
| 239 | /** | ||
| 240 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical | ||
| 241 | * address. This should be used by services to translate addresses for use by the hardware. | ||
| 242 | * | ||
| 243 | * @deprecated Use TryVirtualToPhysicalAddress(), which reports failure. | ||
| 244 | */ | ||
| 245 | PAddr VirtualToPhysicalAddress(VAddr addr); | ||
| 246 | |||
| 247 | /** | ||
| 248 | * Undoes a mapping performed by VirtualToPhysicalAddress(). | ||
| 249 | */ | ||
| 250 | boost::optional<VAddr> PhysicalToVirtualAddress(PAddr addr); | ||
| 251 | |||
| 252 | /** | ||
| 253 | * Gets a pointer to the memory region beginning at the specified physical address. | ||
| 254 | */ | ||
| 255 | u8* GetPhysicalPointer(PAddr address); | ||
| 256 | |||
| 257 | enum class FlushMode { | 171 | enum class FlushMode { |
| 258 | /// Write back modified surfaces to RAM | 172 | /// Write back modified surfaces to RAM |
| 259 | Flush, | 173 | Flush, |