vm_manager: Migrate memory querying to the VMManager interface

Gets rid of the need to directly access the managed VMAs outside of the
memory manager itself just for querying memory.
This commit is contained in:
Lioncash
2018-12-12 11:34:01 -05:00
parent c02b8c895b
commit a8cc03502b
4 changed files with 33 additions and 18 deletions

View File

@ -302,6 +302,25 @@ ResultCode VMManager::HeapFree(VAddr target, u64 size) {
return RESULT_SUCCESS;
}
MemoryInfo VMManager::QueryMemory(VAddr address) const {
const auto vma = FindVMA(address);
MemoryInfo memory_info{};
if (IsValidHandle(vma)) {
memory_info.base_address = vma->second.base;
memory_info.permission = static_cast<u32>(vma->second.permissions);
memory_info.size = vma->second.size;
memory_info.state = ToSvcMemoryState(vma->second.meminfo_state);
} else {
memory_info.base_address = 0;
memory_info.permission = static_cast<u32>(VMAPermission::None);
memory_info.size = 0;
memory_info.state = static_cast<u32>(MemoryState::Unmapped);
}
return memory_info;
}
ResultCode VMManager::MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state) {
const auto vma = FindVMA(src_addr);