diff options
| author | 2018-08-02 12:19:05 -0400 | |
|---|---|---|
| committer | 2018-08-02 12:21:46 -0400 | |
| commit | c4e0c3d76ce4cf3cf3844b204ff7028ffa65a0d9 (patch) | |
| tree | d491f1c2ab5a036e57d0080564447bfd1cd5fb74 /src | |
| parent | kernel/vm_manager: Use the VAddr type alias in CarveVMA() (diff) | |
| download | yuzu-c4e0c3d76ce4cf3cf3844b204ff7028ffa65a0d9.tar.gz yuzu-c4e0c3d76ce4cf3cf3844b204ff7028ffa65a0d9.tar.xz yuzu-c4e0c3d76ce4cf3cf3844b204ff7028ffa65a0d9.zip | |
kernel/vm_manager: Use const where applicable
Makes our immutable state explicit.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 28 | ||||
| -rw-r--r-- | src/core/hle/kernel/vm_manager.h | 8 |
3 files changed, 19 insertions, 19 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index d1cbbc1f2..5db2db687 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -267,7 +267,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 267 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, | 267 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, |
| 268 | info_sub_id, handle); | 268 | info_sub_id, handle); |
| 269 | 269 | ||
| 270 | auto& vm_manager = Core::CurrentProcess()->vm_manager; | 270 | const auto& vm_manager = Core::CurrentProcess()->vm_manager; |
| 271 | 271 | ||
| 272 | switch (static_cast<GetInfoType>(info_id)) { | 272 | switch (static_cast<GetInfoType>(info_id)) { |
| 273 | case GetInfoType::AllowedCpuIdBitmask: | 273 | case GetInfoType::AllowedCpuIdBitmask: |
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index d8b389b65..0f89dd9f3 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp | |||
| @@ -175,9 +175,9 @@ VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) { | |||
| 175 | 175 | ||
| 176 | ResultCode VMManager::UnmapRange(VAddr target, u64 size) { | 176 | ResultCode VMManager::UnmapRange(VAddr target, u64 size) { |
| 177 | CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); | 177 | CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); |
| 178 | VAddr target_end = target + size; | 178 | const VAddr target_end = target + size; |
| 179 | 179 | ||
| 180 | VMAIter end = vma_map.end(); | 180 | const VMAIter end = vma_map.end(); |
| 181 | // The comparison against the end of the range must be done using addresses since VMAs can be | 181 | // The comparison against the end of the range must be done using addresses since VMAs can be |
| 182 | // merged during this process, causing invalidation of the iterators. | 182 | // merged during this process, causing invalidation of the iterators. |
| 183 | while (vma != end && vma->second.base < target_end) { | 183 | while (vma != end && vma->second.base < target_end) { |
| @@ -207,9 +207,9 @@ VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission ne | |||
| 207 | 207 | ||
| 208 | ResultCode VMManager::ReprotectRange(VAddr target, u64 size, VMAPermission new_perms) { | 208 | ResultCode VMManager::ReprotectRange(VAddr target, u64 size, VMAPermission new_perms) { |
| 209 | CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); | 209 | CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); |
| 210 | VAddr target_end = target + size; | 210 | const VAddr target_end = target + size; |
| 211 | 211 | ||
| 212 | VMAIter end = vma_map.end(); | 212 | const VMAIter end = vma_map.end(); |
| 213 | // The comparison against the end of the range must be done using addresses since VMAs can be | 213 | // The comparison against the end of the range must be done using addresses since VMAs can be |
| 214 | // merged during this process, causing invalidation of the iterators. | 214 | // merged during this process, causing invalidation of the iterators. |
| 215 | while (vma != end && vma->second.base < target_end) { | 215 | while (vma != end && vma->second.base < target_end) { |
| @@ -258,14 +258,14 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u64 size) { | |||
| 258 | return ERR_INVALID_ADDRESS; | 258 | return ERR_INVALID_ADDRESS; |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | VirtualMemoryArea& vma = vma_handle->second; | 261 | const VirtualMemoryArea& vma = vma_handle->second; |
| 262 | if (vma.type != VMAType::Free) { | 262 | if (vma.type != VMAType::Free) { |
| 263 | // Region is already allocated | 263 | // Region is already allocated |
| 264 | return ERR_INVALID_ADDRESS_STATE; | 264 | return ERR_INVALID_ADDRESS_STATE; |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | VAddr start_in_vma = base - vma.base; | 267 | const VAddr start_in_vma = base - vma.base; |
| 268 | VAddr end_in_vma = start_in_vma + size; | 268 | const VAddr end_in_vma = start_in_vma + size; |
| 269 | 269 | ||
| 270 | if (end_in_vma > vma.size) { | 270 | if (end_in_vma > vma.size) { |
| 271 | // Requested allocation doesn't fit inside VMA | 271 | // Requested allocation doesn't fit inside VMA |
| @@ -288,13 +288,13 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u64 size) { | |||
| 288 | ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x{:016X}", size); | 288 | ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x{:016X}", size); |
| 289 | ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x{:016X}", target); | 289 | ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x{:016X}", target); |
| 290 | 290 | ||
| 291 | VAddr target_end = target + size; | 291 | const VAddr target_end = target + size; |
| 292 | ASSERT(target_end >= target); | 292 | ASSERT(target_end >= target); |
| 293 | ASSERT(target_end <= MAX_ADDRESS); | 293 | ASSERT(target_end <= MAX_ADDRESS); |
| 294 | ASSERT(size > 0); | 294 | ASSERT(size > 0); |
| 295 | 295 | ||
| 296 | VMAIter begin_vma = StripIterConstness(FindVMA(target)); | 296 | VMAIter begin_vma = StripIterConstness(FindVMA(target)); |
| 297 | VMAIter i_end = vma_map.lower_bound(target_end); | 297 | const VMAIter i_end = vma_map.lower_bound(target_end); |
| 298 | for (auto i = begin_vma; i != i_end; ++i) { | 298 | for (auto i = begin_vma; i != i_end; ++i) { |
| 299 | if (i->second.type == VMAType::Free) { | 299 | if (i->second.type == VMAType::Free) { |
| 300 | return ERR_INVALID_ADDRESS_STATE; | 300 | return ERR_INVALID_ADDRESS_STATE; |
| @@ -346,7 +346,7 @@ VMManager::VMAIter VMManager::SplitVMA(VMAIter vma_handle, u64 offset_in_vma) { | |||
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | VMManager::VMAIter VMManager::MergeAdjacent(VMAIter iter) { | 348 | VMManager::VMAIter VMManager::MergeAdjacent(VMAIter iter) { |
| 349 | VMAIter next_vma = std::next(iter); | 349 | const VMAIter next_vma = std::next(iter); |
| 350 | if (next_vma != vma_map.end() && iter->second.CanBeMergedWith(next_vma->second)) { | 350 | if (next_vma != vma_map.end() && iter->second.CanBeMergedWith(next_vma->second)) { |
| 351 | iter->second.size += next_vma->second.size; | 351 | iter->second.size += next_vma->second.size; |
| 352 | vma_map.erase(next_vma); | 352 | vma_map.erase(next_vma); |
| @@ -382,22 +382,22 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) { | |||
| 382 | } | 382 | } |
| 383 | } | 383 | } |
| 384 | 384 | ||
| 385 | u64 VMManager::GetTotalMemoryUsage() { | 385 | u64 VMManager::GetTotalMemoryUsage() const { |
| 386 | LOG_WARNING(Kernel, "(STUBBED) called"); | 386 | LOG_WARNING(Kernel, "(STUBBED) called"); |
| 387 | return 0xF8000000; | 387 | return 0xF8000000; |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | u64 VMManager::GetTotalHeapUsage() { | 390 | u64 VMManager::GetTotalHeapUsage() const { |
| 391 | LOG_WARNING(Kernel, "(STUBBED) called"); | 391 | LOG_WARNING(Kernel, "(STUBBED) called"); |
| 392 | return 0x0; | 392 | return 0x0; |
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | VAddr VMManager::GetAddressSpaceBaseAddr() { | 395 | VAddr VMManager::GetAddressSpaceBaseAddr() const { |
| 396 | LOG_WARNING(Kernel, "(STUBBED) called"); | 396 | LOG_WARNING(Kernel, "(STUBBED) called"); |
| 397 | return 0x8000000; | 397 | return 0x8000000; |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | u64 VMManager::GetAddressSpaceSize() { | 400 | u64 VMManager::GetAddressSpaceSize() const { |
| 401 | LOG_WARNING(Kernel, "(STUBBED) called"); | 401 | LOG_WARNING(Kernel, "(STUBBED) called"); |
| 402 | return MAX_ADDRESS; | 402 | return MAX_ADDRESS; |
| 403 | } | 403 | } |
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 38e4ebcd3..98bd04bea 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h | |||
| @@ -190,16 +190,16 @@ public: | |||
| 190 | void LogLayout() const; | 190 | void LogLayout() const; |
| 191 | 191 | ||
| 192 | /// Gets the total memory usage, used by svcGetInfo | 192 | /// Gets the total memory usage, used by svcGetInfo |
| 193 | u64 GetTotalMemoryUsage(); | 193 | u64 GetTotalMemoryUsage() const; |
| 194 | 194 | ||
| 195 | /// Gets the total heap usage, used by svcGetInfo | 195 | /// Gets the total heap usage, used by svcGetInfo |
| 196 | u64 GetTotalHeapUsage(); | 196 | u64 GetTotalHeapUsage() const; |
| 197 | 197 | ||
| 198 | /// Gets the total address space base address, used by svcGetInfo | 198 | /// Gets the total address space base address, used by svcGetInfo |
| 199 | VAddr GetAddressSpaceBaseAddr(); | 199 | VAddr GetAddressSpaceBaseAddr() const; |
| 200 | 200 | ||
| 201 | /// Gets the total address space address size, used by svcGetInfo | 201 | /// Gets the total address space address size, used by svcGetInfo |
| 202 | u64 GetAddressSpaceSize(); | 202 | u64 GetAddressSpaceSize() const; |
| 203 | 203 | ||
| 204 | /// Each VMManager has its own page table, which is set as the main one when the owning process | 204 | /// Each VMManager has its own page table, which is set as the main one when the owning process |
| 205 | /// is scheduled. | 205 | /// is scheduled. |