diff options
| author | 2014-08-03 01:46:47 +0200 | |
|---|---|---|
| committer | 2014-08-12 13:32:56 +0200 | |
| commit | 7b6a7d7dfb92d7a6d3537ea8b0339c2170d7eb84 (patch) | |
| tree | 2b005f3358a228136e7711ddac790ed54bb67b1f /src/core/mem_map.h | |
| parent | GSP: Fix a major regression introduced in ffda035c, due to which no display t... (diff) | |
| download | yuzu-7b6a7d7dfb92d7a6d3537ea8b0339c2170d7eb84.tar.gz yuzu-7b6a7d7dfb92d7a6d3537ea8b0339c2170d7eb84.tar.xz yuzu-7b6a7d7dfb92d7a6d3537ea8b0339c2170d7eb84.zip | |
Pica/GPU: Change hardware registers to use physical addresses rather than virtual ones.
This cleans up the mess that address reading/writing had become and makes the code a *lot* more sensible.
This adds a physical<->virtual address converter to mem_map.h. For further accuracy, we will want to properly extend this to support a wider range of address regions. For now, this makes simply homebrew applications work in a good manner though.
Diffstat (limited to 'src/core/mem_map.h')
| -rw-r--r-- | src/core/mem_map.h | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/core/mem_map.h b/src/core/mem_map.h index 12941f558..3c7810573 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h | |||
| @@ -14,7 +14,6 @@ namespace Memory { | |||
| 14 | enum { | 14 | enum { |
| 15 | BOOTROM_SIZE = 0x00010000, ///< Bootrom (super secret code/data @ 0x8000) size | 15 | BOOTROM_SIZE = 0x00010000, ///< Bootrom (super secret code/data @ 0x8000) size |
| 16 | MPCORE_PRIV_SIZE = 0x00002000, ///< MPCore private memory region size | 16 | MPCORE_PRIV_SIZE = 0x00002000, ///< MPCore private memory region size |
| 17 | VRAM_SIZE = 0x00600000, ///< VRAM size | ||
| 18 | DSP_SIZE = 0x00080000, ///< DSP memory size | 17 | DSP_SIZE = 0x00080000, ///< DSP memory size |
| 19 | AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size | 18 | AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size |
| 20 | 19 | ||
| @@ -23,8 +22,6 @@ enum { | |||
| 23 | FCRAM_PADDR_END = (FCRAM_PADDR + FCRAM_SIZE), ///< FCRAM end of physical space | 22 | FCRAM_PADDR_END = (FCRAM_PADDR + FCRAM_SIZE), ///< FCRAM end of physical space |
| 24 | FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address | 23 | FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address |
| 25 | FCRAM_VADDR_END = (FCRAM_VADDR + FCRAM_SIZE), ///< FCRAM end of virtual space | 24 | FCRAM_VADDR_END = (FCRAM_VADDR + FCRAM_SIZE), ///< FCRAM end of virtual space |
| 26 | FCRAM_VADDR_FW0B = 0xF0000000, ///< FCRAM adress for firmare FW0B | ||
| 27 | FCRAM_VADDR_FW0B_END = (FCRAM_VADDR_FW0B + FCRAM_SIZE), ///< FCRAM adress end for FW0B | ||
| 28 | FCRAM_MASK = (FCRAM_SIZE - 1), ///< FCRAM mask | 25 | FCRAM_MASK = (FCRAM_SIZE - 1), ///< FCRAM mask |
| 29 | 26 | ||
| 30 | SHARED_MEMORY_SIZE = 0x04000000, ///< Shared memory size | 27 | SHARED_MEMORY_SIZE = 0x04000000, ///< Shared memory size |
| @@ -73,6 +70,7 @@ enum { | |||
| 73 | HARDWARE_IO_PADDR_END = (HARDWARE_IO_PADDR + HARDWARE_IO_SIZE), | 70 | HARDWARE_IO_PADDR_END = (HARDWARE_IO_PADDR + HARDWARE_IO_SIZE), |
| 74 | HARDWARE_IO_VADDR_END = (HARDWARE_IO_VADDR + HARDWARE_IO_SIZE), | 71 | HARDWARE_IO_VADDR_END = (HARDWARE_IO_VADDR + HARDWARE_IO_SIZE), |
| 75 | 72 | ||
| 73 | VRAM_SIZE = 0x00600000, | ||
| 76 | VRAM_PADDR = 0x18000000, | 74 | VRAM_PADDR = 0x18000000, |
| 77 | VRAM_VADDR = 0x1F000000, | 75 | VRAM_VADDR = 0x1F000000, |
| 78 | VRAM_PADDR_END = (VRAM_PADDR + VRAM_SIZE), | 76 | VRAM_PADDR_END = (VRAM_PADDR + VRAM_SIZE), |
| @@ -112,7 +110,7 @@ struct MemoryBlock { | |||
| 112 | 110 | ||
| 113 | // In 64-bit, this might point to "high memory" (above the 32-bit limit), | 111 | // In 64-bit, this might point to "high memory" (above the 32-bit limit), |
| 114 | // so be sure to load it into a 64-bit register. | 112 | // so be sure to load it into a 64-bit register. |
| 115 | extern u8 *g_base; | 113 | extern u8 *g_base; |
| 116 | 114 | ||
| 117 | // These are guaranteed to point to "low memory" addresses (sub-32-bit). | 115 | // These are guaranteed to point to "low memory" addresses (sub-32-bit). |
| 118 | // 64-bit: Pointers to low-mem (sub-0x10000000) mirror | 116 | // 64-bit: Pointers to low-mem (sub-0x10000000) mirror |
| @@ -147,7 +145,7 @@ void Write32(const u32 addr, const u32 data); | |||
| 147 | 145 | ||
| 148 | void WriteBlock(const u32 addr, const u8* data, const int size); | 146 | void WriteBlock(const u32 addr, const u8* data, const int size); |
| 149 | 147 | ||
| 150 | u8* GetPointer(const u32 Address); | 148 | u8* GetPointer(const u32 virtual_address); |
| 151 | 149 | ||
| 152 | /** | 150 | /** |
| 153 | * Maps a block of memory on the heap | 151 | * Maps a block of memory on the heap |
| @@ -169,16 +167,10 @@ inline const char* GetCharPointer(const u32 address) { | |||
| 169 | return (const char *)GetPointer(address); | 167 | return (const char *)GetPointer(address); |
| 170 | } | 168 | } |
| 171 | 169 | ||
| 172 | inline const u32 VirtualAddressFromPhysical_FCRAM(const u32 address) { | 170 | /// Converts a physical address to virtual address |
| 173 | return ((address & FCRAM_MASK) | FCRAM_VADDR); | 171 | u32 PhysicalToVirtualAddress(const u32 addr); |
| 174 | } | ||
| 175 | |||
| 176 | inline const u32 VirtualAddressFromPhysical_IO(const u32 address) { | ||
| 177 | return (address + 0x0EB00000); | ||
| 178 | } | ||
| 179 | 172 | ||
| 180 | inline const u32 VirtualAddressFromPhysical_VRAM(const u32 address) { | 173 | /// Converts a virtual address to physical address |
| 181 | return (address + 0x07000000); | 174 | u32 VirtualToPhysicalAddress(const u32 addr); |
| 182 | } | ||
| 183 | 175 | ||
| 184 | } // namespace | 176 | } // namespace |