diff options
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 843fffd7e..5ad923fe7 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -47,14 +47,14 @@ static ResultCode SetMemoryAttribute(VAddr addr, u64 size, u32 state0, u32 state | |||
| 47 | /// Maps a memory range into a different range. | 47 | /// Maps a memory range into a different range. |
| 48 | static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { | 48 | static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { |
| 49 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, | 49 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, |
| 50 | src_addr, size); | 50 | src_addr, size); |
| 51 | return Core::CurrentProcess()->MirrorMemory(dst_addr, src_addr, size); | 51 | return Core::CurrentProcess()->MirrorMemory(dst_addr, src_addr, size); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | /// Unmaps a region that was previously mapped with svcMapMemory | 54 | /// Unmaps a region that was previously mapped with svcMapMemory |
| 55 | static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { | 55 | static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { |
| 56 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, | 56 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, |
| 57 | src_addr, size); | 57 | src_addr, size); |
| 58 | return Core::CurrentProcess()->UnmapMemory(dst_addr, src_addr, size); | 58 | return Core::CurrentProcess()->UnmapMemory(dst_addr, src_addr, size); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| @@ -150,7 +150,7 @@ static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thr | |||
| 150 | static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 handle_count, | 150 | static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 handle_count, |
| 151 | s64 nano_seconds) { | 151 | s64 nano_seconds) { |
| 152 | LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, handle_count={}, nano_seconds={}", | 152 | LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, handle_count={}, nano_seconds={}", |
| 153 | handles_address, handle_count, nano_seconds); | 153 | handles_address, handle_count, nano_seconds); |
| 154 | 154 | ||
| 155 | if (!Memory::IsValidVirtualAddress(handles_address)) | 155 | if (!Memory::IsValidVirtualAddress(handles_address)) |
| 156 | return ERR_INVALID_POINTER; | 156 | return ERR_INVALID_POINTER; |
| @@ -228,9 +228,9 @@ static ResultCode CancelSynchronization(Handle thread_handle) { | |||
| 228 | static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr, | 228 | static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr, |
| 229 | Handle requesting_thread_handle) { | 229 | Handle requesting_thread_handle) { |
| 230 | LOG_TRACE(Kernel_SVC, | 230 | LOG_TRACE(Kernel_SVC, |
| 231 | "called holding_thread_handle=0x{:08X}, mutex_addr=0x{:X}, " | 231 | "called holding_thread_handle=0x{:08X}, mutex_addr=0x{:X}, " |
| 232 | "requesting_current_thread_handle=0x{:08X}", | 232 | "requesting_current_thread_handle=0x{:08X}", |
| 233 | holding_thread_handle, mutex_addr, requesting_thread_handle); | 233 | holding_thread_handle, mutex_addr, requesting_thread_handle); |
| 234 | 234 | ||
| 235 | return Mutex::TryAcquire(mutex_addr, holding_thread_handle, requesting_thread_handle); | 235 | return Mutex::TryAcquire(mutex_addr, holding_thread_handle, requesting_thread_handle); |
| 236 | } | 236 | } |
| @@ -258,7 +258,7 @@ static void OutputDebugString(VAddr address, s32 len) { | |||
| 258 | /// Gets system/memory information for the current process | 258 | /// Gets system/memory information for the current process |
| 259 | static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) { | 259 | static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) { |
| 260 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, | 260 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, |
| 261 | info_sub_id, handle); | 261 | info_sub_id, handle); |
| 262 | 262 | ||
| 263 | auto& vm_manager = Core::CurrentProcess()->vm_manager; | 263 | auto& vm_manager = Core::CurrentProcess()->vm_manager; |
| 264 | 264 | ||
| @@ -314,12 +314,12 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 314 | break; | 314 | break; |
| 315 | case GetInfoType::PrivilegedProcessId: | 315 | case GetInfoType::PrivilegedProcessId: |
| 316 | LOG_WARNING(Kernel_SVC, | 316 | LOG_WARNING(Kernel_SVC, |
| 317 | "(STUBBED) Attempted to query privileged process id bounds, returned 0"); | 317 | "(STUBBED) Attempted to query privileged process id bounds, returned 0"); |
| 318 | *result = 0; | 318 | *result = 0; |
| 319 | break; | 319 | break; |
| 320 | case GetInfoType::UserExceptionContextAddr: | 320 | case GetInfoType::UserExceptionContextAddr: |
| 321 | LOG_WARNING(Kernel_SVC, | 321 | LOG_WARNING(Kernel_SVC, |
| 322 | "(STUBBED) Attempted to query user exception context address, returned 0"); | 322 | "(STUBBED) Attempted to query user exception context address, returned 0"); |
| 323 | *result = 0; | 323 | *result = 0; |
| 324 | break; | 324 | break; |
| 325 | default: | 325 | default: |
| @@ -331,8 +331,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 331 | 331 | ||
| 332 | /// Sets the thread activity | 332 | /// Sets the thread activity |
| 333 | static ResultCode SetThreadActivity(Handle handle, u32 unknown) { | 333 | static ResultCode SetThreadActivity(Handle handle, u32 unknown) { |
| 334 | LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, unknown=0x{:08X}", handle, | 334 | LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, unknown=0x{:08X}", handle, unknown); |
| 335 | unknown); | ||
| 336 | return RESULT_SUCCESS; | 335 | return RESULT_SUCCESS; |
| 337 | } | 336 | } |
| 338 | 337 | ||
| @@ -383,10 +382,9 @@ static u32 GetCurrentProcessorNumber() { | |||
| 383 | 382 | ||
| 384 | static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size, | 383 | static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size, |
| 385 | u32 permissions) { | 384 | u32 permissions) { |
| 386 | LOG_TRACE( | 385 | LOG_TRACE(Kernel_SVC, |
| 387 | Kernel_SVC, | 386 | "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", |
| 388 | "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", | 387 | shared_memory_handle, addr, size, permissions); |
| 389 | shared_memory_handle, addr, size, permissions); | ||
| 390 | 388 | ||
| 391 | SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle); | 389 | SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle); |
| 392 | if (!shared_memory) { | 390 | if (!shared_memory) { |
| @@ -414,7 +412,7 @@ static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 s | |||
| 414 | 412 | ||
| 415 | static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size) { | 413 | static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size) { |
| 416 | LOG_WARNING(Kernel_SVC, "called, shared_memory_handle=0x{:08X}, addr=0x{:X}, size=0x{:X}", | 414 | LOG_WARNING(Kernel_SVC, "called, shared_memory_handle=0x{:08X}, addr=0x{:X}, size=0x{:X}", |
| 417 | shared_memory_handle, addr, size); | 415 | shared_memory_handle, addr, size); |
| 418 | 416 | ||
| 419 | SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle); | 417 | SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(shared_memory_handle); |
| 420 | 418 | ||
| @@ -531,9 +529,9 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V | |||
| 531 | Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule(); | 529 | Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule(); |
| 532 | 530 | ||
| 533 | LOG_TRACE(Kernel_SVC, | 531 | LOG_TRACE(Kernel_SVC, |
| 534 | "called entrypoint=0x{:08X} ({}), arg=0x{:08X}, stacktop=0x{:08X}, " | 532 | "called entrypoint=0x{:08X} ({}), arg=0x{:08X}, stacktop=0x{:08X}, " |
| 535 | "threadpriority=0x{:08X}, processorid=0x{:08X} : created handle=0x{:08X}", | 533 | "threadpriority=0x{:08X}, processorid=0x{:08X} : created handle=0x{:08X}", |
| 536 | entry_point, name, arg, stack_top, priority, processor_id, *out_handle); | 534 | entry_point, name, arg, stack_top, priority, processor_id, *out_handle); |
| 537 | 535 | ||
| 538 | return RESULT_SUCCESS; | 536 | return RESULT_SUCCESS; |
| 539 | } | 537 | } |
| @@ -612,7 +610,7 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var | |||
| 612 | /// Signal process wide key | 610 | /// Signal process wide key |
| 613 | static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target) { | 611 | static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target) { |
| 614 | LOG_TRACE(Kernel_SVC, "called, condition_variable_addr=0x{:X}, target=0x{:08X}", | 612 | LOG_TRACE(Kernel_SVC, "called, condition_variable_addr=0x{:X}, target=0x{:08X}", |
| 615 | condition_variable_addr, target); | 613 | condition_variable_addr, target); |
| 616 | 614 | ||
| 617 | auto RetrieveWaitingThreads = | 615 | auto RetrieveWaitingThreads = |
| 618 | [](size_t core_index, std::vector<SharedPtr<Thread>>& waiting_threads, VAddr condvar_addr) { | 616 | [](size_t core_index, std::vector<SharedPtr<Thread>>& waiting_threads, VAddr condvar_addr) { |
| @@ -693,7 +691,7 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target | |||
| 693 | // Wait for an address (via Address Arbiter) | 691 | // Wait for an address (via Address Arbiter) |
| 694 | static ResultCode WaitForAddress(VAddr address, u32 type, s32 value, s64 timeout) { | 692 | static ResultCode WaitForAddress(VAddr address, u32 type, s32 value, s64 timeout) { |
| 695 | LOG_WARNING(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, timeout={}", | 693 | LOG_WARNING(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, timeout={}", |
| 696 | address, type, value, timeout); | 694 | address, type, value, timeout); |
| 697 | // If the passed address is a kernel virtual address, return invalid memory state. | 695 | // If the passed address is a kernel virtual address, return invalid memory state. |
| 698 | if (Memory::IsKernelVirtualAddress(address)) { | 696 | if (Memory::IsKernelVirtualAddress(address)) { |
| 699 | return ERR_INVALID_ADDRESS_STATE; | 697 | return ERR_INVALID_ADDRESS_STATE; |
| @@ -717,9 +715,8 @@ static ResultCode WaitForAddress(VAddr address, u32 type, s32 value, s64 timeout | |||
| 717 | 715 | ||
| 718 | // Signals to an address (via Address Arbiter) | 716 | // Signals to an address (via Address Arbiter) |
| 719 | static ResultCode SignalToAddress(VAddr address, u32 type, s32 value, s32 num_to_wake) { | 717 | static ResultCode SignalToAddress(VAddr address, u32 type, s32 value, s32 num_to_wake) { |
| 720 | LOG_WARNING(Kernel_SVC, | 718 | LOG_WARNING(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, num_to_wake=0x{:X}", |
| 721 | "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, num_to_wake=0x{:X}", address, | 719 | address, type, value, num_to_wake); |
| 722 | type, value, num_to_wake); | ||
| 723 | // If the passed address is a kernel virtual address, return invalid memory state. | 720 | // If the passed address is a kernel virtual address, return invalid memory state. |
| 724 | if (Memory::IsKernelVirtualAddress(address)) { | 721 | if (Memory::IsKernelVirtualAddress(address)) { |
| 725 | return ERR_INVALID_ADDRESS_STATE; | 722 | return ERR_INVALID_ADDRESS_STATE; |
| @@ -769,8 +766,8 @@ static ResultCode ResetSignal(Handle handle) { | |||
| 769 | 766 | ||
| 770 | /// Creates a TransferMemory object | 767 | /// Creates a TransferMemory object |
| 771 | static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 permissions) { | 768 | static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 permissions) { |
| 772 | LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x{:X}, size=0x{:X}, perms=0x{:08X}", addr, | 769 | LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x{:X}, size=0x{:X}, perms=0x{:08X}", addr, size, |
| 773 | size, permissions); | 770 | permissions); |
| 774 | *handle = 0; | 771 | *handle = 0; |
| 775 | return RESULT_SUCCESS; | 772 | return RESULT_SUCCESS; |
| 776 | } | 773 | } |
| @@ -791,7 +788,7 @@ static ResultCode GetThreadCoreMask(Handle thread_handle, u32* core, u64* mask) | |||
| 791 | 788 | ||
| 792 | static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { | 789 | static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { |
| 793 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, mask=0x{:16X}, core=0x{:X}", thread_handle, | 790 | LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, mask=0x{:16X}, core=0x{:X}", thread_handle, |
| 794 | mask, core); | 791 | mask, core); |
| 795 | 792 | ||
| 796 | const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); | 793 | const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); |
| 797 | if (!thread) { | 794 | if (!thread) { |
| @@ -831,7 +828,7 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { | |||
| 831 | static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permissions, | 828 | static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permissions, |
| 832 | u32 remote_permissions) { | 829 | u32 remote_permissions) { |
| 833 | LOG_TRACE(Kernel_SVC, "called, size=0x{:X}, localPerms=0x{:08X}, remotePerms=0x{:08X}", size, | 830 | LOG_TRACE(Kernel_SVC, "called, size=0x{:X}, localPerms=0x{:08X}, remotePerms=0x{:08X}", size, |
| 834 | local_permissions, remote_permissions); | 831 | local_permissions, remote_permissions); |
| 835 | auto sharedMemHandle = | 832 | auto sharedMemHandle = |
| 836 | SharedMemory::Create(g_handle_table.Get<Process>(KernelHandle::CurrentProcess), size, | 833 | SharedMemory::Create(g_handle_table.Get<Process>(KernelHandle::CurrentProcess), size, |
| 837 | static_cast<MemoryPermission>(local_permissions), | 834 | static_cast<MemoryPermission>(local_permissions), |