summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 948989b31..72da3eb3d 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -851,8 +851,35 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
851} 851}
852 852
853/// Sets the thread activity 853/// Sets the thread activity
854static ResultCode SetThreadActivity(Handle handle, u32 unknown) { 854static ResultCode SetThreadActivity(Handle handle, u32 activity) {
855 LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, unknown=0x{:08X}", handle, unknown); 855 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", handle, activity);
856 if (activity > static_cast<u32>(ThreadActivity::Paused)) {
857 return ERR_INVALID_ENUM_VALUE;
858 }
859
860 const auto* current_process = Core::CurrentProcess();
861 const SharedPtr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle);
862 if (!thread) {
863 LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle);
864 return ERR_INVALID_HANDLE;
865 }
866
867 if (thread->GetOwnerProcess() != current_process) {
868 LOG_ERROR(Kernel_SVC,
869 "The current process does not own the current thread, thread_handle={:08X} "
870 "thread_pid={}, "
871 "current_process_pid={}",
872 handle, thread->GetOwnerProcess()->GetProcessID(),
873 current_process->GetProcessID());
874 return ERR_INVALID_HANDLE;
875 }
876
877 if (thread == GetCurrentThread()) {
878 LOG_ERROR(Kernel_SVC, "The thread handle specified is the current running thread");
879 return ERR_BUSY;
880 }
881
882 thread->SetActivity(static_cast<ThreadActivity>(activity));
856 return RESULT_SUCCESS; 883 return RESULT_SUCCESS;
857} 884}
858 885
@@ -879,7 +906,7 @@ static ResultCode GetThreadContext(VAddr thread_context, Handle handle) {
879 906
880 if (thread == GetCurrentThread()) { 907 if (thread == GetCurrentThread()) {
881 LOG_ERROR(Kernel_SVC, "The thread handle specified is the current running thread"); 908 LOG_ERROR(Kernel_SVC, "The thread handle specified is the current running thread");
882 return ERR_ALREADY_REGISTERED; 909 return ERR_BUSY;
883 } 910 }
884 911
885 Core::ARM_Interface::ThreadContext ctx = thread->GetContext(); 912 Core::ARM_Interface::ThreadContext ctx = thread->GetContext();
@@ -1157,7 +1184,10 @@ static ResultCode StartThread(Handle thread_handle) {
1157 ASSERT(thread->GetStatus() == ThreadStatus::Dormant); 1184 ASSERT(thread->GetStatus() == ThreadStatus::Dormant);
1158 1185
1159 thread->ResumeFromWait(); 1186 thread->ResumeFromWait();
1160 Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); 1187
1188 if (thread->GetStatus() == ThreadStatus::Ready) {
1189 Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
1190 }
1161 1191
1162 return RESULT_SUCCESS; 1192 return RESULT_SUCCESS;
1163} 1193}