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 | 32 |
3 files changed, 19 insertions, 38 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 4f209a979..06a673b9b 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -198,22 +198,6 @@ void Process::LoadModule(CodeSet module_, VAddr base_addr) { | |||
| 198 | Core::System::GetInstance().ArmInterface(3).ClearInstructionCache(); | 198 | Core::System::GetInstance().ArmInterface(3).ClearInstructionCache(); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission perms) { | ||
| 202 | return vm_manager.HeapAllocate(target, size, perms); | ||
| 203 | } | ||
| 204 | |||
| 205 | ResultCode Process::HeapFree(VAddr target, u32 size) { | ||
| 206 | return vm_manager.HeapFree(target, size); | ||
| 207 | } | ||
| 208 | |||
| 209 | ResultCode Process::MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state) { | ||
| 210 | return vm_manager.MirrorMemory(dst_addr, src_addr, size, state); | ||
| 211 | } | ||
| 212 | |||
| 213 | ResultCode Process::UnmapMemory(VAddr dst_addr, VAddr /*src_addr*/, u64 size) { | ||
| 214 | return vm_manager.UnmapRange(dst_addr, size); | ||
| 215 | } | ||
| 216 | |||
| 217 | Kernel::Process::Process(KernelCore& kernel) : WaitObject{kernel} {} | 201 | Kernel::Process::Process(KernelCore& kernel) : WaitObject{kernel} {} |
| 218 | Kernel::Process::~Process() {} | 202 | Kernel::Process::~Process() {} |
| 219 | 203 | ||
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 2c0b20f9e..ac6956266 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h | |||
| @@ -242,7 +242,7 @@ public: | |||
| 242 | void LoadModule(CodeSet module_, VAddr base_addr); | 242 | void LoadModule(CodeSet module_, VAddr base_addr); |
| 243 | 243 | ||
| 244 | /////////////////////////////////////////////////////////////////////////////////////////////// | 244 | /////////////////////////////////////////////////////////////////////////////////////////////// |
| 245 | // Memory Management | 245 | // Thread-local storage management |
| 246 | 246 | ||
| 247 | // Marks the next available region as used and returns the address of the slot. | 247 | // Marks the next available region as used and returns the address of the slot. |
| 248 | VAddr MarkNextAvailableTLSSlotAsUsed(Thread& thread); | 248 | VAddr MarkNextAvailableTLSSlotAsUsed(Thread& thread); |
| @@ -250,13 +250,6 @@ public: | |||
| 250 | // Frees a used TLS slot identified by the given address | 250 | // Frees a used TLS slot identified by the given address |
| 251 | void FreeTLSSlot(VAddr tls_address); | 251 | void FreeTLSSlot(VAddr tls_address); |
| 252 | 252 | ||
| 253 | ResultVal<VAddr> HeapAllocate(VAddr target, u64 size, VMAPermission perms); | ||
| 254 | ResultCode HeapFree(VAddr target, u32 size); | ||
| 255 | |||
| 256 | ResultCode MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size, MemoryState state); | ||
| 257 | |||
| 258 | ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size); | ||
| 259 | |||
| 260 | private: | 253 | private: |
| 261 | explicit Process(KernelCore& kernel); | 254 | explicit Process(KernelCore& kernel); |
| 262 | ~Process() override; | 255 | ~Process() override; |
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 |