summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar bunnei2017-09-01 23:10:03 -0400
committerGravatar bunnei2017-09-30 14:28:54 -0400
commitf01472a5ffd03b535e8a66bb00d9a7548a0f61bf (patch)
treed11874933de837f7ce57ccb259f1f869db70bdb7 /src/core/hle/kernel
parentarm: Use 64-bit addressing in a bunch of places. (diff)
downloadyuzu-f01472a5ffd03b535e8a66bb00d9a7548a0f61bf.tar.gz
yuzu-f01472a5ffd03b535e8a66bb00d9a7548a0f61bf.tar.xz
yuzu-f01472a5ffd03b535e8a66bb00d9a7548a0f61bf.zip
core: Various changes to support 64-bit addressing.
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/vm_manager.cpp22
-rw-r--r--src/core/hle/kernel/vm_manager.h20
2 files changed, 21 insertions, 21 deletions
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp
index cef1f7fa8..f70c32501 100644
--- a/src/core/hle/kernel/vm_manager.cpp
+++ b/src/core/hle/kernel/vm_manager.cpp
@@ -56,7 +56,7 @@ void VMManager::Reset() {
56 initial_vma.size = MAX_ADDRESS; 56 initial_vma.size = MAX_ADDRESS;
57 vma_map.emplace(initial_vma.base, initial_vma); 57 vma_map.emplace(initial_vma.base, initial_vma);
58 58
59 UpdatePageTableForVMA(initial_vma); 59 //UpdatePageTableForVMA(initial_vma);
60} 60}
61 61
62VMManager::VMAHandle VMManager::FindVMA(VAddr target) const { 62VMManager::VMAHandle VMManager::FindVMA(VAddr target) const {
@@ -69,7 +69,7 @@ VMManager::VMAHandle VMManager::FindVMA(VAddr target) const {
69 69
70ResultVal<VMManager::VMAHandle> VMManager::MapMemoryBlock(VAddr target, 70ResultVal<VMManager::VMAHandle> VMManager::MapMemoryBlock(VAddr target,
71 std::shared_ptr<std::vector<u8>> block, 71 std::shared_ptr<std::vector<u8>> block,
72 size_t offset, u32 size, 72 size_t offset, u64 size,
73 MemoryState state) { 73 MemoryState state) {
74 ASSERT(block != nullptr); 74 ASSERT(block != nullptr);
75 ASSERT(offset + size <= block->size()); 75 ASSERT(offset + size <= block->size());
@@ -89,7 +89,7 @@ ResultVal<VMManager::VMAHandle> VMManager::MapMemoryBlock(VAddr target,
89 return MakeResult<VMAHandle>(MergeAdjacent(vma_handle)); 89 return MakeResult<VMAHandle>(MergeAdjacent(vma_handle));
90} 90}
91 91
92ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, u8* memory, u32 size, 92ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, u8* memory, u64 size,
93 MemoryState state) { 93 MemoryState state) {
94 ASSERT(memory != nullptr); 94 ASSERT(memory != nullptr);
95 95
@@ -107,7 +107,7 @@ ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, u8* me
107 return MakeResult<VMAHandle>(MergeAdjacent(vma_handle)); 107 return MakeResult<VMAHandle>(MergeAdjacent(vma_handle));
108} 108}
109 109
110ResultVal<VMManager::VMAHandle> VMManager::MapMMIO(VAddr target, PAddr paddr, u32 size, 110ResultVal<VMManager::VMAHandle> VMManager::MapMMIO(VAddr target, PAddr paddr, u64 size,
111 MemoryState state, 111 MemoryState state,
112 Memory::MMIORegionPointer mmio_handler) { 112 Memory::MMIORegionPointer mmio_handler) {
113 // This is the appropriately sized VMA that will turn into our allocation. 113 // This is the appropriately sized VMA that will turn into our allocation.
@@ -141,7 +141,7 @@ VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) {
141 return MergeAdjacent(vma_handle); 141 return MergeAdjacent(vma_handle);
142} 142}
143 143
144ResultCode VMManager::UnmapRange(VAddr target, u32 size) { 144ResultCode VMManager::UnmapRange(VAddr target, u64 size) {
145 CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); 145 CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size));
146 VAddr target_end = target + size; 146 VAddr target_end = target + size;
147 147
@@ -166,7 +166,7 @@ VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission ne
166 return MergeAdjacent(iter); 166 return MergeAdjacent(iter);
167} 167}
168 168
169ResultCode VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_perms) { 169ResultCode VMManager::ReprotectRange(VAddr target, u64 size, VMAPermission new_perms) {
170 CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); 170 CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size));
171 VAddr target_end = target + size; 171 VAddr target_end = target + size;
172 172
@@ -209,7 +209,7 @@ VMManager::VMAIter VMManager::StripIterConstness(const VMAHandle& iter) {
209 return vma_map.erase(iter, iter); // Erases an empty range of elements 209 return vma_map.erase(iter, iter); // Erases an empty range of elements
210} 210}
211 211
212ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u32 size) { 212ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u64 size) {
213 ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x%8X", size); 213 ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x%8X", size);
214 ASSERT_MSG((base & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x%08X", base); 214 ASSERT_MSG((base & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x%08X", base);
215 215
@@ -225,8 +225,8 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u32 size) {
225 return ERR_INVALID_ADDRESS_STATE; 225 return ERR_INVALID_ADDRESS_STATE;
226 } 226 }
227 227
228 u32 start_in_vma = base - vma.base; 228 u64 start_in_vma = base - vma.base;
229 u32 end_in_vma = start_in_vma + size; 229 u64 end_in_vma = start_in_vma + size;
230 230
231 if (end_in_vma > vma.size) { 231 if (end_in_vma > vma.size) {
232 // Requested allocation doesn't fit inside VMA 232 // Requested allocation doesn't fit inside VMA
@@ -245,7 +245,7 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u32 size) {
245 return MakeResult<VMAIter>(vma_handle); 245 return MakeResult<VMAIter>(vma_handle);
246} 246}
247 247
248ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u32 size) { 248ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u64 size) {
249 ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x%8X", size); 249 ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x%8X", size);
250 ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x%08X", target); 250 ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x%08X", target);
251 251
@@ -274,7 +274,7 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u32 size) {
274 return MakeResult<VMAIter>(begin_vma); 274 return MakeResult<VMAIter>(begin_vma);
275} 275}
276 276
277VMManager::VMAIter VMManager::SplitVMA(VMAIter vma_handle, u32 offset_in_vma) { 277VMManager::VMAIter VMManager::SplitVMA(VMAIter vma_handle, u64 offset_in_vma) {
278 VirtualMemoryArea& old_vma = vma_handle->second; 278 VirtualMemoryArea& old_vma = vma_handle->second;
279 VirtualMemoryArea new_vma = old_vma; // Make a copy of the VMA 279 VirtualMemoryArea new_vma = old_vma; // Make a copy of the VMA
280 280
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h
index 38e0d74d0..aa2265ce6 100644
--- a/src/core/hle/kernel/vm_manager.h
+++ b/src/core/hle/kernel/vm_manager.h
@@ -63,7 +63,7 @@ struct VirtualMemoryArea {
63 /// Virtual base address of the region. 63 /// Virtual base address of the region.
64 VAddr base = 0; 64 VAddr base = 0;
65 /// Size of the region. 65 /// Size of the region.
66 u32 size = 0; 66 u64 size = 0;
67 67
68 VMAType type = VMAType::Free; 68 VMAType type = VMAType::Free;
69 VMAPermission permissions = VMAPermission::None; 69 VMAPermission permissions = VMAPermission::None;
@@ -109,7 +109,7 @@ public:
109 * used. 109 * used.
110 * @note This is the limit used by the New 3DS kernel. Old 3DS used 0x20000000. 110 * @note This is the limit used by the New 3DS kernel. Old 3DS used 0x20000000.
111 */ 111 */
112 static const u32 MAX_ADDRESS = 0x40000000; 112 static const VAddr MAX_ADDRESS = 0x8000000000;
113 113
114 /** 114 /**
115 * A map covering the entirety of the managed address space, keyed by the `base` field of each 115 * A map covering the entirety of the managed address space, keyed by the `base` field of each
@@ -142,7 +142,7 @@ public:
142 * @param state MemoryState tag to attach to the VMA. 142 * @param state MemoryState tag to attach to the VMA.
143 */ 143 */
144 ResultVal<VMAHandle> MapMemoryBlock(VAddr target, std::shared_ptr<std::vector<u8>> block, 144 ResultVal<VMAHandle> MapMemoryBlock(VAddr target, std::shared_ptr<std::vector<u8>> block,
145 size_t offset, u32 size, MemoryState state); 145 size_t offset, u64 size, MemoryState state);
146 146
147 /** 147 /**
148 * Maps an unmanaged host memory pointer at a given address. 148 * Maps an unmanaged host memory pointer at a given address.
@@ -152,7 +152,7 @@ public:
152 * @param size Size of the mapping. 152 * @param size Size of the mapping.
153 * @param state MemoryState tag to attach to the VMA. 153 * @param state MemoryState tag to attach to the VMA.
154 */ 154 */
155 ResultVal<VMAHandle> MapBackingMemory(VAddr target, u8* memory, u32 size, MemoryState state); 155 ResultVal<VMAHandle> MapBackingMemory(VAddr target, u8* memory, u64 size, MemoryState state);
156 156
157 /** 157 /**
158 * Maps a memory-mapped IO region at a given address. 158 * Maps a memory-mapped IO region at a given address.
@@ -163,17 +163,17 @@ public:
163 * @param state MemoryState tag to attach to the VMA. 163 * @param state MemoryState tag to attach to the VMA.
164 * @param mmio_handler The handler that will implement read and write for this MMIO region. 164 * @param mmio_handler The handler that will implement read and write for this MMIO region.
165 */ 165 */
166 ResultVal<VMAHandle> MapMMIO(VAddr target, PAddr paddr, u32 size, MemoryState state, 166 ResultVal<VMAHandle> MapMMIO(VAddr target, PAddr paddr, u64 size, MemoryState state,
167 Memory::MMIORegionPointer mmio_handler); 167 Memory::MMIORegionPointer mmio_handler);
168 168
169 /// Unmaps a range of addresses, splitting VMAs as necessary. 169 /// Unmaps a range of addresses, splitting VMAs as necessary.
170 ResultCode UnmapRange(VAddr target, u32 size); 170 ResultCode UnmapRange(VAddr target, u64 size);
171 171
172 /// Changes the permissions of the given VMA. 172 /// Changes the permissions of the given VMA.
173 VMAHandle Reprotect(VMAHandle vma, VMAPermission new_perms); 173 VMAHandle Reprotect(VMAHandle vma, VMAPermission new_perms);
174 174
175 /// Changes the permissions of a range of addresses, splitting VMAs as necessary. 175 /// Changes the permissions of a range of addresses, splitting VMAs as necessary.
176 ResultCode ReprotectRange(VAddr target, u32 size, VMAPermission new_perms); 176 ResultCode ReprotectRange(VAddr target, u64 size, VMAPermission new_perms);
177 177
178 /** 178 /**
179 * Scans all VMAs and updates the page table range of any that use the given vector as backing 179 * Scans all VMAs and updates the page table range of any that use the given vector as backing
@@ -197,19 +197,19 @@ private:
197 * Carves a VMA of a specific size at the specified address by splitting Free VMAs while doing 197 * Carves a VMA of a specific size at the specified address by splitting Free VMAs while doing
198 * the appropriate error checking. 198 * the appropriate error checking.
199 */ 199 */
200 ResultVal<VMAIter> CarveVMA(VAddr base, u32 size); 200 ResultVal<VMAIter> CarveVMA(VAddr base, u64 size);
201 201
202 /** 202 /**
203 * Splits the edges of the given range of non-Free VMAs so that there is a VMA split at each 203 * Splits the edges of the given range of non-Free VMAs so that there is a VMA split at each
204 * end of the range. 204 * end of the range.
205 */ 205 */
206 ResultVal<VMAIter> CarveVMARange(VAddr base, u32 size); 206 ResultVal<VMAIter> CarveVMARange(VAddr base, u64 size);
207 207
208 /** 208 /**
209 * Splits a VMA in two, at the specified offset. 209 * Splits a VMA in two, at the specified offset.
210 * @returns the right side of the split, with the original iterator becoming the left side. 210 * @returns the right side of the split, with the original iterator becoming the left side.
211 */ 211 */
212 VMAIter SplitVMA(VMAIter vma, u32 offset_in_vma); 212 VMAIter SplitVMA(VMAIter vma, u64 offset_in_vma);
213 213
214 /** 214 /**
215 * Checks for and merges the specified VMA with adjacent ones if possible. 215 * Checks for and merges the specified VMA with adjacent ones if possible.