diff options
| author | 2021-04-02 23:53:31 -0700 | |
|---|---|---|
| committer | 2021-05-05 16:40:50 -0700 | |
| commit | 6fca1c82fd98b284cef2fb45fbaeae0cbc6241ac (patch) | |
| tree | 81ceb1a0366d363f36d11f5cd088278f8a05fb88 /src | |
| parent | hle: kernel: svc: Migrate CreateThread. (diff) | |
| download | yuzu-6fca1c82fd98b284cef2fb45fbaeae0cbc6241ac.tar.gz yuzu-6fca1c82fd98b284cef2fb45fbaeae0cbc6241ac.tar.xz yuzu-6fca1c82fd98b284cef2fb45fbaeae0cbc6241ac.zip | |
hle: kernel: svc: Migrate GetThreadPriority, StartThread, and ExitThread.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 036603315..395962885 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -1150,12 +1150,9 @@ static ResultCode GetThreadPriority(Core::System& system, u32* out_priority, Han | |||
| 1150 | LOG_TRACE(Kernel_SVC, "called"); | 1150 | LOG_TRACE(Kernel_SVC, "called"); |
| 1151 | 1151 | ||
| 1152 | // Get the thread from its handle. | 1152 | // Get the thread from its handle. |
| 1153 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1153 | KScopedAutoObject thread = |
| 1154 | const std::shared_ptr<KThread> thread = handle_table.Get<KThread>(handle); | 1154 | system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(handle); |
| 1155 | if (!thread) { | 1155 | R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); |
| 1156 | LOG_ERROR(Kernel_SVC, "Invalid thread handle provided (handle={:08X})", handle); | ||
| 1157 | return ResultInvalidHandle; | ||
| 1158 | } | ||
| 1159 | 1156 | ||
| 1160 | // Get the thread's priority. | 1157 | // Get the thread's priority. |
| 1161 | *out_priority = thread->GetPriority(); | 1158 | *out_priority = thread->GetPriority(); |
| @@ -1552,7 +1549,7 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e | |||
| 1552 | thread_reservation.Commit(); | 1549 | thread_reservation.Commit(); |
| 1553 | 1550 | ||
| 1554 | // Register the new thread. | 1551 | // Register the new thread. |
| 1555 | KThread::Register(thread); | 1552 | KThread::Register(kernel, thread); |
| 1556 | 1553 | ||
| 1557 | // Add the thread to the handle table. | 1554 | // Add the thread to the handle table. |
| 1558 | R_TRY(process.GetHandleTable().Add(out_handle, thread)); | 1555 | R_TRY(process.GetHandleTable().Add(out_handle, thread)); |
| @@ -1570,21 +1567,15 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) { | |||
| 1570 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); | 1567 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); |
| 1571 | 1568 | ||
| 1572 | // Get the thread from its handle. | 1569 | // Get the thread from its handle. |
| 1573 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1570 | KScopedAutoObject thread = |
| 1574 | const std::shared_ptr<KThread> thread = handle_table.Get<KThread>(thread_handle); | 1571 | system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle); |
| 1575 | if (!thread) { | 1572 | R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); |
| 1576 | LOG_ERROR(Kernel_SVC, "Invalid thread handle provided (handle={:08X})", thread_handle); | ||
| 1577 | return ResultInvalidHandle; | ||
| 1578 | } | ||
| 1579 | 1573 | ||
| 1580 | // Try to start the thread. | 1574 | // Try to start the thread. |
| 1581 | const auto run_result = thread->Run(); | 1575 | R_TRY(thread->Run()); |
| 1582 | if (run_result.IsError()) { | 1576 | |
| 1583 | LOG_ERROR(Kernel_SVC, | 1577 | // If we succeeded, persist a reference to the thread. |
| 1584 | "Unable to successfuly start thread (thread handle={:08X}, result={})", | 1578 | thread->Open(); |
| 1585 | thread_handle, run_result.raw); | ||
| 1586 | return run_result; | ||
| 1587 | } | ||
| 1588 | 1579 | ||
| 1589 | return RESULT_SUCCESS; | 1580 | return RESULT_SUCCESS; |
| 1590 | } | 1581 | } |
| @@ -1598,7 +1589,7 @@ static void ExitThread(Core::System& system) { | |||
| 1598 | LOG_DEBUG(Kernel_SVC, "called, pc=0x{:08X}", system.CurrentArmInterface().GetPC()); | 1589 | LOG_DEBUG(Kernel_SVC, "called, pc=0x{:08X}", system.CurrentArmInterface().GetPC()); |
| 1599 | 1590 | ||
| 1600 | auto* const current_thread = system.Kernel().CurrentScheduler()->GetCurrentThread(); | 1591 | auto* const current_thread = system.Kernel().CurrentScheduler()->GetCurrentThread(); |
| 1601 | system.GlobalSchedulerContext().RemoveThread(SharedFrom(current_thread)); | 1592 | system.GlobalSchedulerContext().RemoveThread(current_thread); |
| 1602 | current_thread->Exit(); | 1593 | current_thread->Exit(); |
| 1603 | } | 1594 | } |
| 1604 | 1595 | ||