summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 2e80b48c2..b955f9839 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -190,10 +190,16 @@ static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) {
190 return ERR_INVALID_SIZE; 190 return ERR_INVALID_SIZE;
191 } 191 }
192 192
193 auto& process = *Core::CurrentProcess(); 193 auto& vm_manager = Core::CurrentProcess()->VMManager();
194 const VAddr heap_base = process.VMManager().GetHeapRegionBaseAddress(); 194 const VAddr heap_base = vm_manager.GetHeapRegionBaseAddress();
195 CASCADE_RESULT(*heap_addr, 195 const auto alloc_result =
196 process.HeapAllocate(heap_base, heap_size, VMAPermission::ReadWrite)); 196 vm_manager.HeapAllocate(heap_base, heap_size, VMAPermission::ReadWrite);
197
198 if (alloc_result.Failed()) {
199 return alloc_result.Code();
200 }
201
202 *heap_addr = *alloc_result;
197 return RESULT_SUCCESS; 203 return RESULT_SUCCESS;
198} 204}
199 205
@@ -307,15 +313,14 @@ static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) {
307 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 313 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
308 src_addr, size); 314 src_addr, size);
309 315
310 auto* const current_process = Core::CurrentProcess(); 316 auto& vm_manager = Core::CurrentProcess()->VMManager();
311 const auto& vm_manager = current_process->VMManager();
312
313 const auto result = MapUnmapMemorySanityChecks(vm_manager, dst_addr, src_addr, size); 317 const auto result = MapUnmapMemorySanityChecks(vm_manager, dst_addr, src_addr, size);
314 if (result != RESULT_SUCCESS) { 318
319 if (result.IsError()) {
315 return result; 320 return result;
316 } 321 }
317 322
318 return current_process->MirrorMemory(dst_addr, src_addr, size, MemoryState::Stack); 323 return vm_manager.MirrorMemory(dst_addr, src_addr, size, MemoryState::Stack);
319} 324}
320 325
321/// Unmaps a region that was previously mapped with svcMapMemory 326/// Unmaps a region that was previously mapped with svcMapMemory
@@ -323,15 +328,14 @@ static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) {
323 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 328 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
324 src_addr, size); 329 src_addr, size);
325 330
326 auto* const current_process = Core::CurrentProcess(); 331 auto& vm_manager = Core::CurrentProcess()->VMManager();
327 const auto& vm_manager = current_process->VMManager();
328
329 const auto result = MapUnmapMemorySanityChecks(vm_manager, dst_addr, src_addr, size); 332 const auto result = MapUnmapMemorySanityChecks(vm_manager, dst_addr, src_addr, size);
330 if (result != RESULT_SUCCESS) { 333
334 if (result.IsError()) {
331 return result; 335 return result;
332 } 336 }
333 337
334 return current_process->UnmapMemory(dst_addr, src_addr, size); 338 return vm_manager.UnmapRange(dst_addr, size);
335} 339}
336 340
337/// Connect to an OS service given the port name, returns the handle to the port to out 341/// Connect to an OS service given the port name, returns the handle to the port to out