diff options
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 4c3b53a88..9928b3a26 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -359,7 +359,7 @@ static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle, | |||
| 359 | 359 | ||
| 360 | auto client_port = it->second; | 360 | auto client_port = it->second; |
| 361 | 361 | ||
| 362 | SharedPtr<ClientSession> client_session; | 362 | std::shared_ptr<ClientSession> client_session; |
| 363 | CASCADE_RESULT(client_session, client_port->Connect()); | 363 | CASCADE_RESULT(client_session, client_port->Connect()); |
| 364 | 364 | ||
| 365 | // Return the client session | 365 | // Return the client session |
| @@ -371,7 +371,7 @@ static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle, | |||
| 371 | /// Makes a blocking IPC call to an OS service. | 371 | /// Makes a blocking IPC call to an OS service. |
| 372 | static ResultCode SendSyncRequest(Core::System& system, Handle handle) { | 372 | static ResultCode SendSyncRequest(Core::System& system, Handle handle) { |
| 373 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 373 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 374 | SharedPtr<ClientSession> session = handle_table.Get<ClientSession>(handle); | 374 | std::shared_ptr<ClientSession> session = handle_table.Get<ClientSession>(handle); |
| 375 | if (!session) { | 375 | if (!session) { |
| 376 | LOG_ERROR(Kernel_SVC, "called with invalid handle=0x{:08X}", handle); | 376 | LOG_ERROR(Kernel_SVC, "called with invalid handle=0x{:08X}", handle); |
| 377 | return ERR_INVALID_HANDLE; | 377 | return ERR_INVALID_HANDLE; |
| @@ -391,7 +391,7 @@ static ResultCode GetThreadId(Core::System& system, u64* thread_id, Handle threa | |||
| 391 | LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); | 391 | LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); |
| 392 | 392 | ||
| 393 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 393 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 394 | const SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 394 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); |
| 395 | if (!thread) { | 395 | if (!thread) { |
| 396 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", thread_handle); | 396 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", thread_handle); |
| 397 | return ERR_INVALID_HANDLE; | 397 | return ERR_INVALID_HANDLE; |
| @@ -406,13 +406,13 @@ static ResultCode GetProcessId(Core::System& system, u64* process_id, Handle han | |||
| 406 | LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); | 406 | LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); |
| 407 | 407 | ||
| 408 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 408 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 409 | const SharedPtr<Process> process = handle_table.Get<Process>(handle); | 409 | const std::shared_ptr<Process> process = handle_table.Get<Process>(handle); |
| 410 | if (process) { | 410 | if (process) { |
| 411 | *process_id = process->GetProcessID(); | 411 | *process_id = process->GetProcessID(); |
| 412 | return RESULT_SUCCESS; | 412 | return RESULT_SUCCESS; |
| 413 | } | 413 | } |
| 414 | 414 | ||
| 415 | const SharedPtr<Thread> thread = handle_table.Get<Thread>(handle); | 415 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(handle); |
| 416 | if (thread) { | 416 | if (thread) { |
| 417 | const Process* const owner_process = thread->GetOwnerProcess(); | 417 | const Process* const owner_process = thread->GetOwnerProcess(); |
| 418 | if (!owner_process) { | 418 | if (!owner_process) { |
| @@ -431,8 +431,8 @@ static ResultCode GetProcessId(Core::System& system, u64* process_id, Handle han | |||
| 431 | } | 431 | } |
| 432 | 432 | ||
| 433 | /// Default thread wakeup callback for WaitSynchronization | 433 | /// Default thread wakeup callback for WaitSynchronization |
| 434 | static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> thread, | 434 | static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, |
| 435 | SharedPtr<WaitObject> object, std::size_t index) { | 435 | std::shared_ptr<WaitObject> object, std::size_t index) { |
| 436 | ASSERT(thread->GetStatus() == ThreadStatus::WaitSynch); | 436 | ASSERT(thread->GetStatus() == ThreadStatus::WaitSynch); |
| 437 | 437 | ||
| 438 | if (reason == ThreadWakeupReason::Timeout) { | 438 | if (reason == ThreadWakeupReason::Timeout) { |
| @@ -512,7 +512,7 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr | |||
| 512 | } | 512 | } |
| 513 | 513 | ||
| 514 | for (auto& object : objects) { | 514 | for (auto& object : objects) { |
| 515 | object->AddWaitingThread(thread); | 515 | object->AddWaitingThread(SharedFrom(thread)); |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | thread->SetWaitObjects(std::move(objects)); | 518 | thread->SetWaitObjects(std::move(objects)); |
| @@ -532,7 +532,7 @@ static ResultCode CancelSynchronization(Core::System& system, Handle thread_hand | |||
| 532 | LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle); | 532 | LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle); |
| 533 | 533 | ||
| 534 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 534 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 535 | SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 535 | std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); |
| 536 | if (!thread) { | 536 | if (!thread) { |
| 537 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", | 537 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", |
| 538 | thread_handle); | 538 | thread_handle); |
| @@ -941,7 +941,7 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha | |||
| 941 | const auto& core_timing = system.CoreTiming(); | 941 | const auto& core_timing = system.CoreTiming(); |
| 942 | const auto& scheduler = system.CurrentScheduler(); | 942 | const auto& scheduler = system.CurrentScheduler(); |
| 943 | const auto* const current_thread = scheduler.GetCurrentThread(); | 943 | const auto* const current_thread = scheduler.GetCurrentThread(); |
| 944 | const bool same_thread = current_thread == thread; | 944 | const bool same_thread = current_thread == thread.get(); |
| 945 | 945 | ||
| 946 | const u64 prev_ctx_ticks = scheduler.GetLastContextSwitchTicks(); | 946 | const u64 prev_ctx_ticks = scheduler.GetLastContextSwitchTicks(); |
| 947 | u64 out_ticks = 0; | 947 | u64 out_ticks = 0; |
| @@ -1051,7 +1051,7 @@ static ResultCode SetThreadActivity(Core::System& system, Handle handle, u32 act | |||
| 1051 | } | 1051 | } |
| 1052 | 1052 | ||
| 1053 | const auto* current_process = system.Kernel().CurrentProcess(); | 1053 | const auto* current_process = system.Kernel().CurrentProcess(); |
| 1054 | const SharedPtr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); | 1054 | const std::shared_ptr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); |
| 1055 | if (!thread) { | 1055 | if (!thread) { |
| 1056 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); | 1056 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); |
| 1057 | return ERR_INVALID_HANDLE; | 1057 | return ERR_INVALID_HANDLE; |
| @@ -1067,7 +1067,7 @@ static ResultCode SetThreadActivity(Core::System& system, Handle handle, u32 act | |||
| 1067 | return ERR_INVALID_HANDLE; | 1067 | return ERR_INVALID_HANDLE; |
| 1068 | } | 1068 | } |
| 1069 | 1069 | ||
| 1070 | if (thread == system.CurrentScheduler().GetCurrentThread()) { | 1070 | if (thread.get() == system.CurrentScheduler().GetCurrentThread()) { |
| 1071 | LOG_ERROR(Kernel_SVC, "The thread handle specified is the current running thread"); | 1071 | LOG_ERROR(Kernel_SVC, "The thread handle specified is the current running thread"); |
| 1072 | return ERR_BUSY; | 1072 | return ERR_BUSY; |
| 1073 | } | 1073 | } |
| @@ -1083,7 +1083,7 @@ static ResultCode GetThreadContext(Core::System& system, VAddr thread_context, H | |||
| 1083 | LOG_DEBUG(Kernel_SVC, "called, context=0x{:08X}, thread=0x{:X}", thread_context, handle); | 1083 | LOG_DEBUG(Kernel_SVC, "called, context=0x{:08X}, thread=0x{:X}", thread_context, handle); |
| 1084 | 1084 | ||
| 1085 | const auto* current_process = system.Kernel().CurrentProcess(); | 1085 | const auto* current_process = system.Kernel().CurrentProcess(); |
| 1086 | const SharedPtr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); | 1086 | const std::shared_ptr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); |
| 1087 | if (!thread) { | 1087 | if (!thread) { |
| 1088 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); | 1088 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); |
| 1089 | return ERR_INVALID_HANDLE; | 1089 | return ERR_INVALID_HANDLE; |
| @@ -1099,7 +1099,7 @@ static ResultCode GetThreadContext(Core::System& system, VAddr thread_context, H | |||
| 1099 | return ERR_INVALID_HANDLE; | 1099 | return ERR_INVALID_HANDLE; |
| 1100 | } | 1100 | } |
| 1101 | 1101 | ||
| 1102 | if (thread == system.CurrentScheduler().GetCurrentThread()) { | 1102 | if (thread.get() == system.CurrentScheduler().GetCurrentThread()) { |
| 1103 | LOG_ERROR(Kernel_SVC, "The thread handle specified is the current running thread"); | 1103 | LOG_ERROR(Kernel_SVC, "The thread handle specified is the current running thread"); |
| 1104 | return ERR_BUSY; | 1104 | return ERR_BUSY; |
| 1105 | } | 1105 | } |
| @@ -1124,7 +1124,7 @@ static ResultCode GetThreadPriority(Core::System& system, u32* priority, Handle | |||
| 1124 | LOG_TRACE(Kernel_SVC, "called"); | 1124 | LOG_TRACE(Kernel_SVC, "called"); |
| 1125 | 1125 | ||
| 1126 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1126 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 1127 | const SharedPtr<Thread> thread = handle_table.Get<Thread>(handle); | 1127 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(handle); |
| 1128 | if (!thread) { | 1128 | if (!thread) { |
| 1129 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); | 1129 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); |
| 1130 | return ERR_INVALID_HANDLE; | 1130 | return ERR_INVALID_HANDLE; |
| @@ -1148,7 +1148,7 @@ static ResultCode SetThreadPriority(Core::System& system, Handle handle, u32 pri | |||
| 1148 | 1148 | ||
| 1149 | const auto* const current_process = system.Kernel().CurrentProcess(); | 1149 | const auto* const current_process = system.Kernel().CurrentProcess(); |
| 1150 | 1150 | ||
| 1151 | SharedPtr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); | 1151 | std::shared_ptr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); |
| 1152 | if (!thread) { | 1152 | if (!thread) { |
| 1153 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); | 1153 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); |
| 1154 | return ERR_INVALID_HANDLE; | 1154 | return ERR_INVALID_HANDLE; |
| @@ -1268,7 +1268,7 @@ static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_add | |||
| 1268 | VAddr address) { | 1268 | VAddr address) { |
| 1269 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); | 1269 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); |
| 1270 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1270 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 1271 | SharedPtr<Process> process = handle_table.Get<Process>(process_handle); | 1271 | std::shared_ptr<Process> process = handle_table.Get<Process>(process_handle); |
| 1272 | if (!process) { | 1272 | if (!process) { |
| 1273 | LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}", | 1273 | LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}", |
| 1274 | process_handle); | 1274 | process_handle); |
| @@ -1496,7 +1496,7 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e | |||
| 1496 | } | 1496 | } |
| 1497 | 1497 | ||
| 1498 | auto& kernel = system.Kernel(); | 1498 | auto& kernel = system.Kernel(); |
| 1499 | CASCADE_RESULT(SharedPtr<Thread> thread, | 1499 | CASCADE_RESULT(std::shared_ptr<Thread> thread, |
| 1500 | Thread::Create(kernel, "", entry_point, priority, arg, processor_id, stack_top, | 1500 | Thread::Create(kernel, "", entry_point, priority, arg, processor_id, stack_top, |
| 1501 | *current_process)); | 1501 | *current_process)); |
| 1502 | 1502 | ||
| @@ -1522,7 +1522,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) { | |||
| 1522 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); | 1522 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); |
| 1523 | 1523 | ||
| 1524 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1524 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 1525 | const SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 1525 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); |
| 1526 | if (!thread) { | 1526 | if (!thread) { |
| 1527 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", | 1527 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", |
| 1528 | thread_handle); | 1528 | thread_handle); |
| @@ -1546,7 +1546,7 @@ static void ExitThread(Core::System& system) { | |||
| 1546 | 1546 | ||
| 1547 | auto* const current_thread = system.CurrentScheduler().GetCurrentThread(); | 1547 | auto* const current_thread = system.CurrentScheduler().GetCurrentThread(); |
| 1548 | current_thread->Stop(); | 1548 | current_thread->Stop(); |
| 1549 | system.GlobalScheduler().RemoveThread(current_thread); | 1549 | system.GlobalScheduler().RemoveThread(SharedFrom(current_thread)); |
| 1550 | system.PrepareReschedule(); | 1550 | system.PrepareReschedule(); |
| 1551 | } | 1551 | } |
| 1552 | 1552 | ||
| @@ -1618,7 +1618,7 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add | |||
| 1618 | 1618 | ||
| 1619 | auto* const current_process = system.Kernel().CurrentProcess(); | 1619 | auto* const current_process = system.Kernel().CurrentProcess(); |
| 1620 | const auto& handle_table = current_process->GetHandleTable(); | 1620 | const auto& handle_table = current_process->GetHandleTable(); |
| 1621 | SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 1621 | std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); |
| 1622 | ASSERT(thread); | 1622 | ASSERT(thread); |
| 1623 | 1623 | ||
| 1624 | const auto release_result = current_process->GetMutex().Release(mutex_addr); | 1624 | const auto release_result = current_process->GetMutex().Release(mutex_addr); |
| @@ -1626,13 +1626,13 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add | |||
| 1626 | return release_result; | 1626 | return release_result; |
| 1627 | } | 1627 | } |
| 1628 | 1628 | ||
| 1629 | SharedPtr<Thread> current_thread = system.CurrentScheduler().GetCurrentThread(); | 1629 | Thread* current_thread = system.CurrentScheduler().GetCurrentThread(); |
| 1630 | current_thread->SetCondVarWaitAddress(condition_variable_addr); | 1630 | current_thread->SetCondVarWaitAddress(condition_variable_addr); |
| 1631 | current_thread->SetMutexWaitAddress(mutex_addr); | 1631 | current_thread->SetMutexWaitAddress(mutex_addr); |
| 1632 | current_thread->SetWaitHandle(thread_handle); | 1632 | current_thread->SetWaitHandle(thread_handle); |
| 1633 | current_thread->SetStatus(ThreadStatus::WaitCondVar); | 1633 | current_thread->SetStatus(ThreadStatus::WaitCondVar); |
| 1634 | current_thread->InvalidateWakeupCallback(); | 1634 | current_thread->InvalidateWakeupCallback(); |
| 1635 | current_process->InsertConditionVariableThread(current_thread); | 1635 | current_process->InsertConditionVariableThread(SharedFrom(current_thread)); |
| 1636 | 1636 | ||
| 1637 | current_thread->WakeAfterDelay(nano_seconds); | 1637 | current_thread->WakeAfterDelay(nano_seconds); |
| 1638 | 1638 | ||
| @@ -1652,7 +1652,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var | |||
| 1652 | 1652 | ||
| 1653 | // Retrieve a list of all threads that are waiting for this condition variable. | 1653 | // Retrieve a list of all threads that are waiting for this condition variable. |
| 1654 | auto* const current_process = system.Kernel().CurrentProcess(); | 1654 | auto* const current_process = system.Kernel().CurrentProcess(); |
| 1655 | std::vector<SharedPtr<Thread>> waiting_threads = | 1655 | std::vector<std::shared_ptr<Thread>> waiting_threads = |
| 1656 | current_process->GetConditionVariableThreads(condition_variable_addr); | 1656 | current_process->GetConditionVariableThreads(condition_variable_addr); |
| 1657 | 1657 | ||
| 1658 | // Only process up to 'target' threads, unless 'target' is less equal 0, in which case process | 1658 | // Only process up to 'target' threads, unless 'target' is less equal 0, in which case process |
| @@ -1969,7 +1969,7 @@ static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, | |||
| 1969 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); | 1969 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); |
| 1970 | 1970 | ||
| 1971 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1971 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 1972 | const SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 1972 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); |
| 1973 | if (!thread) { | 1973 | if (!thread) { |
| 1974 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", | 1974 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", |
| 1975 | thread_handle); | 1975 | thread_handle); |
| @@ -2028,7 +2028,7 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, | |||
| 2028 | } | 2028 | } |
| 2029 | 2029 | ||
| 2030 | const auto& handle_table = current_process->GetHandleTable(); | 2030 | const auto& handle_table = current_process->GetHandleTable(); |
| 2031 | const SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 2031 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); |
| 2032 | if (!thread) { | 2032 | if (!thread) { |
| 2033 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", | 2033 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", |
| 2034 | thread_handle); | 2034 | thread_handle); |