diff options
| author | 2015-07-29 11:54:44 -0300 | |
|---|---|---|
| committer | 2015-08-16 01:03:46 -0300 | |
| commit | e2c7954be5ccabc7c5f87000db01cef040ca4b47 (patch) | |
| tree | 5b3288c66f6941a9d6be0f2907c3526bb3b7e6ac /src | |
| parent | Process: Store kernel compatibility version during loading (diff) | |
| download | yuzu-e2c7954be5ccabc7c5f87000db01cef040ca4b47.tar.gz yuzu-e2c7954be5ccabc7c5f87000db01cef040ca4b47.tar.xz yuzu-e2c7954be5ccabc7c5f87000db01cef040ca4b47.zip | |
Memory: Move address type conversion routines to memory.cpp/h
These helpers aren't really part of the kernel, and mem_map.cpp/h is
going to be moved there next.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/skyeye_common/armstate.cpp | 1 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/armsupp.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/resource_limit.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/service/gsp_gpu.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/service/y2r_u.cpp | 1 | ||||
| -rw-r--r-- | src/core/mem_map.cpp | 36 | ||||
| -rw-r--r-- | src/core/mem_map.h | 11 | ||||
| -rw-r--r-- | src/core/memory.cpp | 37 | ||||
| -rw-r--r-- | src/core/memory.h | 11 |
9 files changed, 47 insertions, 53 deletions
diff --git a/src/core/arm/skyeye_common/armstate.cpp b/src/core/arm/skyeye_common/armstate.cpp index ccb2eb0eb..0491717dc 100644 --- a/src/core/arm/skyeye_common/armstate.cpp +++ b/src/core/arm/skyeye_common/armstate.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/swap.h" | 5 | #include "common/swap.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/mem_map.h" | ||
| 8 | #include "core/memory.h" | 7 | #include "core/memory.h" |
| 9 | #include "core/arm/skyeye_common/armstate.h" | 8 | #include "core/arm/skyeye_common/armstate.h" |
| 10 | #include "core/arm/skyeye_common/vfp/vfp.h" | 9 | #include "core/arm/skyeye_common/vfp/vfp.h" |
diff --git a/src/core/arm/skyeye_common/armsupp.cpp b/src/core/arm/skyeye_common/armsupp.cpp index d31fb9449..883713e86 100644 --- a/src/core/arm/skyeye_common/armsupp.cpp +++ b/src/core/arm/skyeye_common/armsupp.cpp | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | 17 | ||
| 18 | #include "common/logging/log.h" | 18 | #include "common/logging/log.h" |
| 19 | 19 | ||
| 20 | #include "core/mem_map.h" | ||
| 21 | #include "core/arm/skyeye_common/arm_regformat.h" | 20 | #include "core/arm/skyeye_common/arm_regformat.h" |
| 22 | #include "core/arm/skyeye_common/armstate.h" | 21 | #include "core/arm/skyeye_common/armstate.h" |
| 23 | #include "core/arm/skyeye_common/armsupp.h" | 22 | #include "core/arm/skyeye_common/armsupp.h" |
diff --git a/src/core/hle/kernel/resource_limit.cpp b/src/core/hle/kernel/resource_limit.cpp index 94b3e3298..67dde08c2 100644 --- a/src/core/hle/kernel/resource_limit.cpp +++ b/src/core/hle/kernel/resource_limit.cpp | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | 8 | ||
| 9 | #include "core/mem_map.h" | ||
| 10 | #include "core/hle/kernel/resource_limit.h" | 9 | #include "core/hle/kernel/resource_limit.h" |
| 11 | 10 | ||
| 12 | namespace Kernel { | 11 | namespace Kernel { |
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index e93c1b436..5050b9f7d 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/bit_field.h" | 5 | #include "common/bit_field.h" |
| 6 | 6 | ||
| 7 | #include "core/mem_map.h" | ||
| 8 | #include "core/memory.h" | 7 | #include "core/memory.h" |
| 9 | #include "core/hle/kernel/event.h" | 8 | #include "core/hle/kernel/event.h" |
| 10 | #include "core/hle/kernel/shared_memory.h" | 9 | #include "core/hle/kernel/shared_memory.h" |
diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp index 6e7dafaad..6b1b71fe4 100644 --- a/src/core/hle/service/y2r_u.cpp +++ b/src/core/hle/service/y2r_u.cpp | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | #include "core/hle/kernel/event.h" | 10 | #include "core/hle/kernel/event.h" |
| 11 | #include "core/hle/service/y2r_u.h" | 11 | #include "core/hle/service/y2r_u.h" |
| 12 | #include "core/hw/y2r.h" | 12 | #include "core/hw/y2r.h" |
| 13 | #include "core/mem_map.h" | ||
| 14 | 13 | ||
| 15 | #include "video_core/renderer_base.h" | 14 | #include "video_core/renderer_base.h" |
| 16 | #include "video_core/utils.h" | 15 | #include "video_core/utils.h" |
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp index c95dea064..f6a063825 100644 --- a/src/core/mem_map.cpp +++ b/src/core/mem_map.cpp | |||
| @@ -93,42 +93,6 @@ u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions) { | |||
| 93 | return block.GetVirtualAddress(); | 93 | return block.GetVirtualAddress(); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | PAddr VirtualToPhysicalAddress(const VAddr addr) { | ||
| 97 | if (addr == 0) { | ||
| 98 | return 0; | ||
| 99 | } else if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) { | ||
| 100 | return addr - VRAM_VADDR + VRAM_PADDR; | ||
| 101 | } else if (addr >= LINEAR_HEAP_VADDR && addr < LINEAR_HEAP_VADDR_END) { | ||
| 102 | return addr - LINEAR_HEAP_VADDR + FCRAM_PADDR; | ||
| 103 | } else if (addr >= DSP_RAM_VADDR && addr < DSP_RAM_VADDR_END) { | ||
| 104 | return addr - DSP_RAM_VADDR + DSP_RAM_PADDR; | ||
| 105 | } else if (addr >= IO_AREA_VADDR && addr < IO_AREA_VADDR_END) { | ||
| 106 | return addr - IO_AREA_VADDR + IO_AREA_PADDR; | ||
| 107 | } | ||
| 108 | |||
| 109 | LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%08x", addr); | ||
| 110 | // To help with debugging, set bit on address so that it's obviously invalid. | ||
| 111 | return addr | 0x80000000; | ||
| 112 | } | ||
| 113 | |||
| 114 | VAddr PhysicalToVirtualAddress(const PAddr addr) { | ||
| 115 | if (addr == 0) { | ||
| 116 | return 0; | ||
| 117 | } else if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) { | ||
| 118 | return addr - VRAM_PADDR + VRAM_VADDR; | ||
| 119 | } else if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) { | ||
| 120 | return addr - FCRAM_PADDR + LINEAR_HEAP_VADDR; | ||
| 121 | } else if (addr >= DSP_RAM_PADDR && addr < DSP_RAM_PADDR_END) { | ||
| 122 | return addr - DSP_RAM_PADDR + DSP_RAM_VADDR; | ||
| 123 | } else if (addr >= IO_AREA_PADDR && addr < IO_AREA_PADDR_END) { | ||
| 124 | return addr - IO_AREA_PADDR + IO_AREA_VADDR; | ||
| 125 | } | ||
| 126 | |||
| 127 | LOG_ERROR(HW_Memory, "Unknown physical address @ 0x%08x", addr); | ||
| 128 | // To help with debugging, set bit on address so that it's obviously invalid. | ||
| 129 | return addr | 0x80000000; | ||
| 130 | } | ||
| 131 | |||
| 132 | void Init() { | 96 | void Init() { |
| 133 | InitMemoryMap(); | 97 | InitMemoryMap(); |
| 134 | LOG_DEBUG(HW_Memory, "initialized OK"); | 98 | LOG_DEBUG(HW_Memory, "initialized OK"); |
diff --git a/src/core/mem_map.h b/src/core/mem_map.h index 229ef82c5..cba8a0714 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h | |||
| @@ -32,15 +32,4 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions); | |||
| 32 | */ | 32 | */ |
| 33 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions); | 33 | u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions); |
| 34 | 34 | ||
| 35 | /** | ||
| 36 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical | ||
| 37 | * address. This should be used by services to translate addresses for use by the hardware. | ||
| 38 | */ | ||
| 39 | PAddr VirtualToPhysicalAddress(VAddr addr); | ||
| 40 | |||
| 41 | /** | ||
| 42 | * Undoes a mapping performed by VirtualToPhysicalAddress(). | ||
| 43 | */ | ||
| 44 | VAddr PhysicalToVirtualAddress(PAddr addr); | ||
| 45 | |||
| 46 | } // namespace | 35 | } // namespace |
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 1f66bb27d..935dac90f 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| 11 | 11 | ||
| 12 | #include "core/mem_map.h" | ||
| 13 | #include "core/memory.h" | 12 | #include "core/memory.h" |
| 14 | #include "core/memory_setup.h" | 13 | #include "core/memory_setup.h" |
| 15 | 14 | ||
| @@ -198,4 +197,40 @@ void WriteBlock(const VAddr addr, const u8* data, const size_t size) { | |||
| 198 | Write8(addr + offset, data[offset]); | 197 | Write8(addr + offset, data[offset]); |
| 199 | } | 198 | } |
| 200 | 199 | ||
| 200 | PAddr VirtualToPhysicalAddress(const VAddr addr) { | ||
| 201 | if (addr == 0) { | ||
| 202 | return 0; | ||
| 203 | } else if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) { | ||
| 204 | return addr - VRAM_VADDR + VRAM_PADDR; | ||
| 205 | } else if (addr >= LINEAR_HEAP_VADDR && addr < LINEAR_HEAP_VADDR_END) { | ||
| 206 | return addr - LINEAR_HEAP_VADDR + FCRAM_PADDR; | ||
| 207 | } else if (addr >= DSP_RAM_VADDR && addr < DSP_RAM_VADDR_END) { | ||
| 208 | return addr - DSP_RAM_VADDR + DSP_RAM_PADDR; | ||
| 209 | } else if (addr >= IO_AREA_VADDR && addr < IO_AREA_VADDR_END) { | ||
| 210 | return addr - IO_AREA_VADDR + IO_AREA_PADDR; | ||
| 211 | } | ||
| 212 | |||
| 213 | LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%08X", addr); | ||
| 214 | // To help with debugging, set bit on address so that it's obviously invalid. | ||
| 215 | return addr | 0x80000000; | ||
| 216 | } | ||
| 217 | |||
| 218 | VAddr PhysicalToVirtualAddress(const PAddr addr) { | ||
| 219 | if (addr == 0) { | ||
| 220 | return 0; | ||
| 221 | } else if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) { | ||
| 222 | return addr - VRAM_PADDR + VRAM_VADDR; | ||
| 223 | } else if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) { | ||
| 224 | return addr - FCRAM_PADDR + LINEAR_HEAP_VADDR; | ||
| 225 | } else if (addr >= DSP_RAM_PADDR && addr < DSP_RAM_PADDR_END) { | ||
| 226 | return addr - DSP_RAM_PADDR + DSP_RAM_VADDR; | ||
| 227 | } else if (addr >= IO_AREA_PADDR && addr < IO_AREA_PADDR_END) { | ||
| 228 | return addr - IO_AREA_PADDR + IO_AREA_VADDR; | ||
| 229 | } | ||
| 230 | |||
| 231 | LOG_ERROR(HW_Memory, "Unknown physical address @ 0x%08X", addr); | ||
| 232 | // To help with debugging, set bit on address so that it's obviously invalid. | ||
| 233 | return addr | 0x80000000; | ||
| 234 | } | ||
| 235 | |||
| 201 | } // namespace | 236 | } // namespace |
diff --git a/src/core/memory.h b/src/core/memory.h index 2a06cc6c3..e6da3e2a5 100644 --- a/src/core/memory.h +++ b/src/core/memory.h | |||
| @@ -124,6 +124,17 @@ void WriteBlock(VAddr addr, const u8* data, size_t size); | |||
| 124 | u8* GetPointer(VAddr virtual_address); | 124 | u8* GetPointer(VAddr virtual_address); |
| 125 | 125 | ||
| 126 | /** | 126 | /** |
| 127 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical | ||
| 128 | * address. This should be used by services to translate addresses for use by the hardware. | ||
| 129 | */ | ||
| 130 | PAddr VirtualToPhysicalAddress(VAddr addr); | ||
| 131 | |||
| 132 | /** | ||
| 133 | * Undoes a mapping performed by VirtualToPhysicalAddress(). | ||
| 134 | */ | ||
| 135 | VAddr PhysicalToVirtualAddress(PAddr addr); | ||
| 136 | |||
| 137 | /** | ||
| 127 | * Gets a pointer to the memory region beginning at the specified physical address. | 138 | * Gets a pointer to the memory region beginning at the specified physical address. |
| 128 | * | 139 | * |
| 129 | * @note This is currently implemented using PhysicalToVirtualAddress(). | 140 | * @note This is currently implemented using PhysicalToVirtualAddress(). |