diff options
author | Lioncash <mathew1800@gmail.com> | 2018-12-12 17:34:01 +0100 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2018-12-12 21:07:30 +0100 |
commit | a8cc03502b41b44150af71535d2b662a7ee3390c (patch) | |
tree | 71084e1b71b5fd705143bbceb44c46e49f63cac2 /src/core | |
parent | vm_manager: Migrate MemoryInfo and PageInfo to vm_manager.h (diff) | |
download | yuzu-a8cc03502b41b44150af71535d2b662a7ee3390c.tar yuzu-a8cc03502b41b44150af71535d2b662a7ee3390c.tar.gz yuzu-a8cc03502b41b44150af71535d2b662a7ee3390c.tar.bz2 yuzu-a8cc03502b41b44150af71535d2b662a7ee3390c.tar.lz yuzu-a8cc03502b41b44150af71535d2b662a7ee3390c.tar.xz yuzu-a8cc03502b41b44150af71535d2b662a7ee3390c.tar.zst yuzu-a8cc03502b41b44150af71535d2b662a7ee3390c.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 20 | ||||
-rw-r--r-- | src/core/hle/kernel/svc_wrap.h | 2 | ||||
-rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 19 | ||||
-rw-r--r-- | src/core/hle/kernel/vm_manager.h | 10 |
4 files changed, 33 insertions, 18 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 4ae92ff9e..8b079bc40 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -1068,8 +1068,8 @@ static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 /// Query process memory static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_info*/, - Handle process_handle, u64 addr) { - LOG_TRACE(Kernel_SVC, "called process=0x{:08X} addr={:X}", process_handle, addr); + Handle process_handle, u64 address) { + LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); const auto& handle_table = Core::CurrentProcess()->GetHandleTable(); SharedPtr<Process> process = handle_table.Get<Process>(process_handle); if (!process) { @@ -1079,21 +1079,9 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_i } const auto& vm_manager = process->VMManager(); - const auto vma = vm_manager.FindVMA(addr); - - memory_info->attributes = 0; - if (vm_manager.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->type = 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->type = static_cast<u32>(MemoryState::Unmapped); - } + const auto result = vm_manager.QueryMemory(address); + *memory_info = result; return RESULT_SUCCESS; } diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index 3893b0f4a..27a11d82e 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h @@ -199,7 +199,7 @@ void SvcWrap() { Memory::Write64(Param(0), memory_info.base_address); Memory::Write64(Param(0) + 8, memory_info.size); - Memory::Write32(Param(0) + 16, memory_info.type); + Memory::Write32(Param(0) + 16, memory_info.state); Memory::Write32(Param(0) + 20, memory_info.attributes); Memory::Write32(Param(0) + 24, memory_info.permission); diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index e0f204b0b..21bcee192 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -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); diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 35f0f276e..91e8e8c8c 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -153,7 +153,7 @@ constexpr u32 ToSvcMemoryState(MemoryState state) { struct MemoryInfo { u64 base_address; u64 size; - u32 type; + u32 state; u32 attributes; u32 permission; u32 device_refcount; @@ -288,6 +288,14 @@ public: ResultCode MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state); + /// Queries the memory manager for information about the given address. + /// + /// @param address The address to query the memory manager about for information. + /// + /// @return A MemoryInfo instance containing information about the given address. + /// + MemoryInfo QueryMemory(VAddr address) const; + /** * Scans all VMAs and updates the page table range of any that use the given vector as backing * memory. This should be called after any operation that causes reallocation of the vector. |