diff options
| author | 2014-08-28 15:20:55 -0300 | |
|---|---|---|
| committer | 2014-08-31 00:04:11 -0300 | |
| commit | 83c3d2bcd192f069030450a863b57f28982f86d2 (patch) | |
| tree | 25a142d2f036790a0764f02fe3676efe8f776243 /src/core/mem_map_funcs.cpp | |
| parent | Merge pull request #81 from yuriks/downgrade-shader (diff) | |
| download | yuzu-83c3d2bcd192f069030450a863b57f28982f86d2.tar.gz yuzu-83c3d2bcd192f069030450a863b57f28982f86d2.tar.xz yuzu-83c3d2bcd192f069030450a863b57f28982f86d2.zip | |
Introduce VAddr and PAddr typedefs for ARM addresses.
Diffstat (limited to 'src/core/mem_map_funcs.cpp')
| -rw-r--r-- | src/core/mem_map_funcs.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index ecdaa06d7..391b75fc2 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp | |||
| @@ -18,7 +18,7 @@ std::map<u32, MemoryBlock> g_heap_gsp_map; | |||
| 18 | std::map<u32, MemoryBlock> g_shared_map; | 18 | std::map<u32, MemoryBlock> g_shared_map; |
| 19 | 19 | ||
| 20 | /// Convert a physical address to virtual address | 20 | /// Convert a physical address to virtual address |
| 21 | u32 PhysicalToVirtualAddress(const u32 addr) { | 21 | VAddr PhysicalToVirtualAddress(const PAddr addr) { |
| 22 | // Our memory interface read/write functions assume virtual addresses. Put any physical address | 22 | // Our memory interface read/write functions assume virtual addresses. Put any physical address |
| 23 | // to virtual address translations here. This is quite hacky, but necessary until we implement | 23 | // to virtual address translations here. This is quite hacky, but necessary until we implement |
| 24 | // proper MMU emulation. | 24 | // proper MMU emulation. |
| @@ -34,7 +34,7 @@ u32 PhysicalToVirtualAddress(const u32 addr) { | |||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | /// Convert a physical address to virtual address | 36 | /// Convert a physical address to virtual address |
| 37 | u32 VirtualToPhysicalAddress(const u32 addr) { | 37 | PAddr VirtualToPhysicalAddress(const VAddr addr) { |
| 38 | // Our memory interface read/write functions assume virtual addresses. Put any physical address | 38 | // Our memory interface read/write functions assume virtual addresses. Put any physical address |
| 39 | // to virtual address translations here. This is quite hacky, but necessary until we implement | 39 | // to virtual address translations here. This is quite hacky, but necessary until we implement |
| 40 | // proper MMU emulation. | 40 | // proper MMU emulation. |
| @@ -50,7 +50,7 @@ u32 VirtualToPhysicalAddress(const u32 addr) { | |||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | template <typename T> | 52 | template <typename T> |
| 53 | inline void Read(T &var, const u32 vaddr) { | 53 | inline void Read(T &var, const VAddr vaddr) { |
| 54 | // TODO: Figure out the fastest order of tests for both read and write (they are probably different). | 54 | // TODO: Figure out the fastest order of tests for both read and write (they are probably different). |
| 55 | // TODO: Make sure this represents the mirrors in a correct way. | 55 | // TODO: Make sure this represents the mirrors in a correct way. |
| 56 | // Could just do a base-relative read, too.... TODO | 56 | // Could just do a base-relative read, too.... TODO |
| @@ -98,7 +98,7 @@ inline void Read(T &var, const u32 vaddr) { | |||
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | template <typename T> | 100 | template <typename T> |
| 101 | inline void Write(u32 vaddr, const T data) { | 101 | inline void Write(const VAddr vaddr, const T data) { |
| 102 | 102 | ||
| 103 | // Kernel memory command buffer | 103 | // Kernel memory command buffer |
| 104 | if (vaddr >= KERNEL_MEMORY_VADDR && vaddr < KERNEL_MEMORY_VADDR_END) { | 104 | if (vaddr >= KERNEL_MEMORY_VADDR && vaddr < KERNEL_MEMORY_VADDR_END) { |
| @@ -146,7 +146,7 @@ inline void Write(u32 vaddr, const T data) { | |||
| 146 | } | 146 | } |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | u8 *GetPointer(const u32 vaddr) { | 149 | u8 *GetPointer(const VAddr vaddr) { |
| 150 | // Kernel memory command buffer | 150 | // Kernel memory command buffer |
| 151 | if (vaddr >= KERNEL_MEMORY_VADDR && vaddr < KERNEL_MEMORY_VADDR_END) { | 151 | if (vaddr >= KERNEL_MEMORY_VADDR && vaddr < KERNEL_MEMORY_VADDR_END) { |
| 152 | return g_kernel_mem + (vaddr & KERNEL_MEMORY_MASK); | 152 | return g_kernel_mem + (vaddr & KERNEL_MEMORY_MASK); |
| @@ -227,13 +227,13 @@ u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) { | |||
| 227 | return block.GetVirtualAddress(); | 227 | return block.GetVirtualAddress(); |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | u8 Read8(const u32 addr) { | 230 | u8 Read8(const VAddr addr) { |
| 231 | u8 data = 0; | 231 | u8 data = 0; |
| 232 | Read<u8>(data, addr); | 232 | Read<u8>(data, addr); |
| 233 | return (u8)data; | 233 | return data; |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | u16 Read16(const u32 addr) { | 236 | u16 Read16(const VAddr addr) { |
| 237 | u16_le data = 0; | 237 | u16_le data = 0; |
| 238 | Read<u16_le>(data, addr); | 238 | Read<u16_le>(data, addr); |
| 239 | 239 | ||
| @@ -246,7 +246,7 @@ u16 Read16(const u32 addr) { | |||
| 246 | return (u16)data; | 246 | return (u16)data; |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | u32 Read32(const u32 addr) { | 249 | u32 Read32(const VAddr addr) { |
| 250 | u32_le data = 0; | 250 | u32_le data = 0; |
| 251 | Read<u32_le>(data, addr); | 251 | Read<u32_le>(data, addr); |
| 252 | 252 | ||
| @@ -263,31 +263,31 @@ u32 Read32(const u32 addr) { | |||
| 263 | return (u32)data; | 263 | return (u32)data; |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | u32 Read8_ZX(const u32 addr) { | 266 | u32 Read8_ZX(const VAddr addr) { |
| 267 | return (u32)Read8(addr); | 267 | return (u32)Read8(addr); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | u32 Read16_ZX(const u32 addr) { | 270 | u32 Read16_ZX(const VAddr addr) { |
| 271 | return (u32)Read16(addr); | 271 | return (u32)Read16(addr); |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | void Write8(const u32 addr, const u8 data) { | 274 | void Write8(const VAddr addr, const u8 data) { |
| 275 | Write<u8>(addr, data); | 275 | Write<u8>(addr, data); |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | void Write16(const u32 addr, const u16 data) { | 278 | void Write16(const VAddr addr, const u16 data) { |
| 279 | Write<u16_le>(addr, data); | 279 | Write<u16_le>(addr, data); |
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | void Write32(const u32 addr, const u32 data) { | 282 | void Write32(const VAddr addr, const u32 data) { |
| 283 | Write<u32_le>(addr, data); | 283 | Write<u32_le>(addr, data); |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | void Write64(const u32 addr, const u64 data) { | 286 | void Write64(const VAddr addr, const u64 data) { |
| 287 | Write<u64_le>(addr, data); | 287 | Write<u64_le>(addr, data); |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | void WriteBlock(const u32 addr, const u8* data, const int size) { | 290 | void WriteBlock(const VAddr addr, const u8* data, const size_t size) { |
| 291 | int offset = 0; | 291 | int offset = 0; |
| 292 | while (offset < (size & ~3)) { | 292 | while (offset < (size & ~3)) { |
| 293 | Write32(addr + offset, *(u32*)&data[offset]); | 293 | Write32(addr + offset, *(u32*)&data[offset]); |