diff options
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r-- | src/core/hle/kernel/process.cpp | 16 | ||||
-rw-r--r-- | src/core/hle/kernel/process.h | 9 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 35 |
3 files changed, 22 insertions, 38 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index d5ca235b0..c5aa19afa 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -227,22 +227,6 @@ void Process::LoadModule(CodeSet module_, VAddr base_addr) { Core::System::GetInstance().ArmInterface(3).ClearInstructionCache(); } -ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission perms) { - return vm_manager.HeapAllocate(target, size, perms); -} - -ResultCode Process::HeapFree(VAddr target, u32 size) { - return vm_manager.HeapFree(target, size); -} - -ResultCode Process::MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state) { - return vm_manager.MirrorMemory(dst_addr, src_addr, size, state); -} - -ResultCode Process::UnmapMemory(VAddr dst_addr, VAddr /*src_addr*/, u64 size) { - return vm_manager.UnmapRange(dst_addr, size); -} - Kernel::Process::Process(KernelCore& kernel) : WaitObject{kernel} {} Kernel::Process::~Process() {} diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index ce7d143de..450dc6eeb 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -242,7 +242,7 @@ public: void LoadModule(CodeSet module_, VAddr base_addr); /////////////////////////////////////////////////////////////////////////////////////////////// - // Memory Management + // Thread-local storage management // Marks the next available region as used and returns the address of the slot. VAddr MarkNextAvailableTLSSlotAsUsed(Thread& thread); @@ -250,13 +250,6 @@ public: // Frees a used TLS slot identified by the given address void FreeTLSSlot(VAddr tls_address); - ResultVal<VAddr> HeapAllocate(VAddr target, u64 size, VMAPermission perms); - ResultCode HeapFree(VAddr target, u32 size); - - ResultCode MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state); - - ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size); - private: explicit Process(KernelCore& kernel); ~Process() override; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 18fb3c44d..660e6f577 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) { return ERR_INVALID_SIZE; } - auto& process = *Core::CurrentProcess(); - const VAddr heap_base = process.VMManager().GetHeapRegionBaseAddress(); - CASCADE_RESULT(*heap_addr, - process.HeapAllocate(heap_base, heap_size, VMAPermission::ReadWrite)); + auto& vm_manager = Core::CurrentProcess()->VMManager(); + const VAddr heap_base = vm_manager.GetHeapRegionBaseAddress(); + const auto alloc_result = + vm_manager.HeapAllocate(heap_base, heap_size, VMAPermission::ReadWrite); + + if (alloc_result.Failed()) { + return alloc_result.Code(); + } + + *heap_addr = *alloc_result; return RESULT_SUCCESS; } @@ -307,15 +313,14 @@ static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, src_addr, size); - auto* const current_process = Core::CurrentProcess(); - const auto& vm_manager = current_process->VMManager(); - + auto& vm_manager = Core::CurrentProcess()->VMManager(); const auto result = MapUnmapMemorySanityChecks(vm_manager, dst_addr, src_addr, size); - if (result != RESULT_SUCCESS) { + + if (result.IsError()) { return result; } - return current_process->MirrorMemory(dst_addr, src_addr, size, MemoryState::Stack); + return vm_manager.MirrorMemory(dst_addr, src_addr, size, MemoryState::Stack); } /// Unmaps a region that was previously mapped with svcMapMemory @@ -323,15 +328,14 @@ static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, src_addr, size); - auto* const current_process = Core::CurrentProcess(); - const auto& vm_manager = current_process->VMManager(); - + auto& vm_manager = Core::CurrentProcess()->VMManager(); const auto result = MapUnmapMemorySanityChecks(vm_manager, dst_addr, src_addr, size); - if (result != RESULT_SUCCESS) { + + if (result.IsError()) { return result; } - return current_process->UnmapMemory(dst_addr, src_addr, size); + return vm_manager.UnmapRange(dst_addr, size); } /// Connect to an OS service given the port name, returns the handle to the port to out @@ -680,6 +684,9 @@ static void Break(u32 reason, u64 info1, u64 info2) { "Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}", reason, info1, info2); handle_debug_buffer(info1, info2); + Core::System::GetInstance() + .ArmInterface(static_cast<std::size_t>(GetCurrentThread()->GetProcessorID())) + .LogBacktrace(); ASSERT(false); Core::CurrentProcess()->PrepareForTermination(); |