diff options
author | Lioncash <mathew1800@gmail.com> | 2018-12-15 19:49:40 +0100 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2018-12-19 16:59:36 +0100 |
commit | 603cc72168b2165a0aa77a39a14ca63a879cf8f9 (patch) | |
tree | b6e8f3b8a53739c2ffdc857017666ad7e3b53188 /src/core/hle/kernel/vm_manager.cpp | |
parent | vm_manager: Rename meminfo_state to state (diff) | |
download | yuzu-603cc72168b2165a0aa77a39a14ca63a879cf8f9.tar yuzu-603cc72168b2165a0aa77a39a14ca63a879cf8f9.tar.gz yuzu-603cc72168b2165a0aa77a39a14ca63a879cf8f9.tar.bz2 yuzu-603cc72168b2165a0aa77a39a14ca63a879cf8f9.tar.lz yuzu-603cc72168b2165a0aa77a39a14ca63a879cf8f9.tar.xz yuzu-603cc72168b2165a0aa77a39a14ca63a879cf8f9.tar.zst yuzu-603cc72168b2165a0aa77a39a14ca63a879cf8f9.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 252f92df2..02504d750 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -592,6 +592,66 @@ void VMManager::ClearPageTable() { Memory::PageType::Unmapped); } +VMManager::CheckResults VMManager::CheckRangeState(VAddr address, u64 size, MemoryState state_mask, + MemoryState state, VMAPermission permission_mask, + VMAPermission permissions, + MemoryAttribute attribute_mask, + MemoryAttribute attribute, + MemoryAttribute ignore_mask) const { + auto iter = FindVMA(address); + + // If we don't have a valid VMA handle at this point, then it means this is + // being called with an address outside of the address space, which is definitely + // indicative of a bug, as this function only operates on mapped memory regions. + DEBUG_ASSERT(IsValidHandle(iter)); + + const VAddr end_address = address + size - 1; + const MemoryAttribute initial_attributes = iter->second.attribute; + const VMAPermission initial_permissions = iter->second.permissions; + const MemoryState initial_state = iter->second.state; + + while (true) { + // The iterator should be valid throughout the traversal. Hitting the end of + // the mapped VMA regions is unquestionably indicative of a bug. + DEBUG_ASSERT(IsValidHandle(iter)); + + const auto& vma = iter->second; + + if (vma.state != initial_state) { + return ERR_INVALID_ADDRESS_STATE; + } + + if ((vma.state & state_mask) != state) { + return ERR_INVALID_ADDRESS_STATE; + } + + if (vma.permissions != initial_permissions) { + return ERR_INVALID_ADDRESS_STATE; + } + + if ((vma.permissions & permission_mask) != permissions) { + return ERR_INVALID_ADDRESS_STATE; + } + + if ((vma.attribute | ignore_mask) != (initial_attributes | ignore_mask)) { + return ERR_INVALID_ADDRESS_STATE; + } + + if ((vma.attribute & attribute_mask) != attribute) { + return ERR_INVALID_ADDRESS_STATE; + } + + if (end_address <= vma.EndAddress()) { + break; + } + + ++iter; + } + + return MakeResult( + std::make_tuple(initial_state, initial_permissions, initial_attributes & ~ignore_mask)); +} + u64 VMManager::GetTotalMemoryUsage() const { LOG_WARNING(Kernel, "(STUBBED) called"); return 0xF8000000; |