diff options
Diffstat (limited to 'src/core/mem_map.h')
| -rw-r--r-- | src/core/mem_map.h | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/core/mem_map.h b/src/core/mem_map.h index 3c7810573..eed445046 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h | |||
| @@ -9,6 +9,11 @@ | |||
| 9 | 9 | ||
| 10 | namespace Memory { | 10 | namespace Memory { |
| 11 | 11 | ||
| 12 | // TODO: It would be nice to eventually replace these with strong types that prevent accidental | ||
| 13 | // conversion between each other. | ||
| 14 | typedef u32 VAddr; ///< Represents a pointer in the ARM11 virtual address space. | ||
| 15 | typedef u32 PAddr; ///< Represents a pointer in the physical address space. | ||
| 16 | |||
| 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 13 | 18 | ||
| 14 | enum { | 19 | enum { |
| @@ -127,25 +132,25 @@ void Init(); | |||
| 127 | void Shutdown(); | 132 | void Shutdown(); |
| 128 | 133 | ||
| 129 | template <typename T> | 134 | template <typename T> |
| 130 | inline void Read(T &var, const u32 addr); | 135 | inline void Read(T &var, VAddr addr); |
| 131 | 136 | ||
| 132 | template <typename T> | 137 | template <typename T> |
| 133 | inline void Write(u32 addr, const T data); | 138 | inline void Write(VAddr addr, T data); |
| 134 | 139 | ||
| 135 | u8 Read8(const u32 addr); | 140 | u8 Read8(VAddr addr); |
| 136 | u16 Read16(const u32 addr); | 141 | u16 Read16(VAddr addr); |
| 137 | u32 Read32(const u32 addr); | 142 | u32 Read32(VAddr addr); |
| 138 | 143 | ||
| 139 | u32 Read8_ZX(const u32 addr); | 144 | u32 Read8_ZX(VAddr addr); |
| 140 | u32 Read16_ZX(const u32 addr); | 145 | u32 Read16_ZX(VAddr addr); |
| 141 | 146 | ||
| 142 | void Write8(const u32 addr, const u8 data); | 147 | void Write8(VAddr addr, u8 data); |
| 143 | void Write16(const u32 addr, const u16 data); | 148 | void Write16(VAddr addr, u16 data); |
| 144 | void Write32(const u32 addr, const u32 data); | 149 | void Write32(VAddr addr, u32 data); |
| 145 | 150 | ||
| 146 | void WriteBlock(const u32 addr, const u8* data, const int size); | 151 | void WriteBlock(VAddr addr, const u8* data, size_t size); |
| 147 | 152 | ||
| 148 | u8* GetPointer(const u32 virtual_address); | 153 | u8* GetPointer(VAddr virtual_address); |
| 149 | 154 | ||
| 150 | /** | 155 | /** |
| 151 | * Maps a block of memory on the heap | 156 | * Maps a block of memory on the heap |
| @@ -163,14 +168,18 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions); | |||
| 163 | */ | 168 | */ |
| 164 | u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions); | 169 | u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions); |
| 165 | 170 | ||
| 166 | inline const char* GetCharPointer(const u32 address) { | 171 | inline const char* GetCharPointer(const VAddr address) { |
| 167 | return (const char *)GetPointer(address); | 172 | return (const char *)GetPointer(address); |
| 168 | } | 173 | } |
| 169 | 174 | ||
| 170 | /// Converts a physical address to virtual address | 175 | /// Converts a physical address to virtual address |
| 171 | u32 PhysicalToVirtualAddress(const u32 addr); | 176 | VAddr PhysicalToVirtualAddress(PAddr addr); |
| 172 | 177 | ||
| 173 | /// Converts a virtual address to physical address | 178 | /// Converts a virtual address to physical address |
| 174 | u32 VirtualToPhysicalAddress(const u32 addr); | 179 | PAddr VirtualToPhysicalAddress(VAddr addr); |
| 175 | 180 | ||
| 176 | } // namespace | 181 | } // namespace |
| 182 | |||
| 183 | // These are used often, so re-export then on the root namespace | ||
| 184 | using Memory::VAddr; | ||
| 185 | using Memory::PAddr; | ||