diff options
Diffstat (limited to 'src/core/hle/kernel')
| -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 | |||
| 1068 | 1068 | ||
| 1069 | /// Query process memory | 1069 | /// Query process memory |
| 1070 | static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_info*/, | 1070 | static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_info*/, |
| 1071 | Handle process_handle, u64 addr) { | 1071 | Handle process_handle, u64 address) { |
| 1072 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} addr={:X}", process_handle, addr); | 1072 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); |
| 1073 | const auto& handle_table = Core::CurrentProcess()->GetHandleTable(); | 1073 | const auto& handle_table = Core::CurrentProcess()->GetHandleTable(); |
| 1074 | SharedPtr<Process> process = handle_table.Get<Process>(process_handle); | 1074 | SharedPtr<Process> process = handle_table.Get<Process>(process_handle); |
| 1075 | if (!process) { | 1075 | if (!process) { |
| @@ -1079,21 +1079,9 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_i | |||
| 1079 | } | 1079 | } |
| 1080 | 1080 | ||
| 1081 | const auto& vm_manager = process->VMManager(); | 1081 | const auto& vm_manager = process->VMManager(); |
| 1082 | const auto vma = vm_manager.FindVMA(addr); | 1082 | const auto result = vm_manager.QueryMemory(address); |
| 1083 | |||
| 1084 | memory_info->attributes = 0; | ||
| 1085 | if (vm_manager.IsValidHandle(vma)) { | ||
| 1086 | memory_info->base_address = vma->second.base; | ||
| 1087 | memory_info->permission = static_cast<u32>(vma->second.permissions); | ||
| 1088 | memory_info->size = vma->second.size; | ||
| 1089 | memory_info->type = ToSvcMemoryState(vma->second.meminfo_state); | ||
| 1090 | } else { | ||
| 1091 | memory_info->base_address = 0; | ||
| 1092 | memory_info->permission = static_cast<u32>(VMAPermission::None); | ||
| 1093 | memory_info->size = 0; | ||
| 1094 | memory_info->type = static_cast<u32>(MemoryState::Unmapped); | ||
| 1095 | } | ||
| 1096 | 1083 | ||
| 1084 | *memory_info = result; | ||
| 1097 | return RESULT_SUCCESS; | 1085 | return RESULT_SUCCESS; |
| 1098 | } | 1086 | } |
| 1099 | 1087 | ||
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() { | |||
| 199 | 199 | ||
| 200 | Memory::Write64(Param(0), memory_info.base_address); | 200 | Memory::Write64(Param(0), memory_info.base_address); |
| 201 | Memory::Write64(Param(0) + 8, memory_info.size); | 201 | Memory::Write64(Param(0) + 8, memory_info.size); |
| 202 | Memory::Write32(Param(0) + 16, memory_info.type); | 202 | Memory::Write32(Param(0) + 16, memory_info.state); |
| 203 | Memory::Write32(Param(0) + 20, memory_info.attributes); | 203 | Memory::Write32(Param(0) + 20, memory_info.attributes); |
| 204 | Memory::Write32(Param(0) + 24, memory_info.permission); | 204 | Memory::Write32(Param(0) + 24, memory_info.permission); |
| 205 | 205 | ||
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) { | |||
| 302 | return RESULT_SUCCESS; | 302 | return RESULT_SUCCESS; |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | MemoryInfo VMManager::QueryMemory(VAddr address) const { | ||
| 306 | const auto vma = FindVMA(address); | ||
| 307 | MemoryInfo memory_info{}; | ||
| 308 | |||
| 309 | if (IsValidHandle(vma)) { | ||
| 310 | memory_info.base_address = vma->second.base; | ||
| 311 | memory_info.permission = static_cast<u32>(vma->second.permissions); | ||
| 312 | memory_info.size = vma->second.size; | ||
| 313 | memory_info.state = ToSvcMemoryState(vma->second.meminfo_state); | ||
| 314 | } else { | ||
| 315 | memory_info.base_address = 0; | ||
| 316 | memory_info.permission = static_cast<u32>(VMAPermission::None); | ||
| 317 | memory_info.size = 0; | ||
| 318 | memory_info.state = static_cast<u32>(MemoryState::Unmapped); | ||
| 319 | } | ||
| 320 | |||
| 321 | return memory_info; | ||
| 322 | } | ||
| 323 | |||
| 305 | ResultCode VMManager::MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state) { | 324 | ResultCode VMManager::MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state) { |
| 306 | const auto vma = FindVMA(src_addr); | 325 | const auto vma = FindVMA(src_addr); |
| 307 | 326 | ||
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) { | |||
| 153 | struct MemoryInfo { | 153 | struct MemoryInfo { |
| 154 | u64 base_address; | 154 | u64 base_address; |
| 155 | u64 size; | 155 | u64 size; |
| 156 | u32 type; | 156 | u32 state; |
| 157 | u32 attributes; | 157 | u32 attributes; |
| 158 | u32 permission; | 158 | u32 permission; |
| 159 | u32 device_refcount; | 159 | u32 device_refcount; |
| @@ -288,6 +288,14 @@ public: | |||
| 288 | 288 | ||
| 289 | ResultCode MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state); | 289 | ResultCode MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state); |
| 290 | 290 | ||
| 291 | /// Queries the memory manager for information about the given address. | ||
| 292 | /// | ||
| 293 | /// @param address The address to query the memory manager about for information. | ||
| 294 | /// | ||
| 295 | /// @return A MemoryInfo instance containing information about the given address. | ||
| 296 | /// | ||
| 297 | MemoryInfo QueryMemory(VAddr address) const; | ||
| 298 | |||
| 291 | /** | 299 | /** |
| 292 | * Scans all VMAs and updates the page table range of any that use the given vector as backing | 300 | * Scans all VMAs and updates the page table range of any that use the given vector as backing |
| 293 | * memory. This should be called after any operation that causes reallocation of the vector. | 301 | * memory. This should be called after any operation that causes reallocation of the vector. |