summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/vm_manager.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-12-15 20:29:39 +0100
committerLioncash <mathew1800@gmail.com>2018-12-19 16:59:40 +0100
commit622242e3451fd562425f67317f3f0d7855eb5741 (patch)
tree8b0ed78dffd57cf69ec042a39318d12c67bb7fb7 /src/core/hle/kernel/vm_manager.cpp
parentvm_manager: Add member function for checking a memory range adheres to certain attributes, permissions and states (diff)
downloadyuzu-622242e3451fd562425f67317f3f0d7855eb5741.tar
yuzu-622242e3451fd562425f67317f3f0d7855eb5741.tar.gz
yuzu-622242e3451fd562425f67317f3f0d7855eb5741.tar.bz2
yuzu-622242e3451fd562425f67317f3f0d7855eb5741.tar.lz
yuzu-622242e3451fd562425f67317f3f0d7855eb5741.tar.xz
yuzu-622242e3451fd562425f67317f3f0d7855eb5741.tar.zst
yuzu-622242e3451fd562425f67317f3f0d7855eb5741.zip
Diffstat (limited to 'src/core/hle/kernel/vm_manager.cpp')
-rw-r--r--src/core/hle/kernel/vm_manager.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp
index 02504d750..f39e096ca 100644
--- a/src/core/hle/kernel/vm_manager.cpp
+++ b/src/core/hle/kernel/vm_manager.cpp
@@ -322,6 +322,34 @@ MemoryInfo VMManager::QueryMemory(VAddr address) const {
return memory_info;
}
+ResultCode VMManager::SetMemoryAttribute(VAddr address, u64 size, MemoryAttribute mask,
+ MemoryAttribute attribute) {
+ constexpr auto ignore_mask = MemoryAttribute::Uncached | MemoryAttribute::DeviceMapped;
+ constexpr auto attribute_mask = ~ignore_mask;
+
+ const auto result = CheckRangeState(
+ address, size, MemoryState::FlagUncached, MemoryState::FlagUncached, VMAPermission::None,
+ VMAPermission::None, attribute_mask, MemoryAttribute::None, ignore_mask);
+
+ if (result.Failed()) {
+ return result.Code();
+ }
+
+ const auto [prev_state, prev_permissions, prev_attributes] = *result;
+ const auto new_attribute = (prev_attributes & ~mask) | (mask & attribute);
+
+ const auto carve_result = CarveVMARange(address, size);
+ if (carve_result.Failed()) {
+ return carve_result.Code();
+ }
+
+ auto vma_iter = *carve_result;
+ vma_iter->second.attribute = new_attribute;
+
+ MergeAdjacent(vma_iter);
+ return RESULT_SUCCESS;
+}
+
ResultCode VMManager::MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state) {
const auto vma = FindVMA(src_addr);