summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-12-26 15:54:14 -0500
committerGravatar GitHub2018-12-26 15:54:14 -0500
commitae582b6669eed99e66829b1941152f0b8b073128 (patch)
tree5aa768c110f6876823a61d31193cca58c103ddc6 /src/core/hle/kernel/svc.cpp
parentMerge pull request #1943 from ReinUsesLisp/fixup-texs (diff)
parentdebugger: Set paused thread color (diff)
downloadyuzu-ae582b6669eed99e66829b1941152f0b8b073128.tar.gz
yuzu-ae582b6669eed99e66829b1941152f0b8b073128.tar.xz
yuzu-ae582b6669eed99e66829b1941152f0b8b073128.zip
Merge pull request #1849 from encounter/svcSetThreadActivity
svc: Implement SetThreadActivity (thread suspension)
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 28268e112..2e80b48c2 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -932,8 +932,35 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
932} 932}
933 933
934/// Sets the thread activity 934/// Sets the thread activity
935static ResultCode SetThreadActivity(Handle handle, u32 unknown) { 935static ResultCode SetThreadActivity(Handle handle, u32 activity) {
936 LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, unknown=0x{:08X}", handle, unknown); 936 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", handle, activity);
937 if (activity > static_cast<u32>(ThreadActivity::Paused)) {
938 return ERR_INVALID_ENUM_VALUE;
939 }
940
941 const auto* current_process = Core::CurrentProcess();
942 const SharedPtr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle);
943 if (!thread) {
944 LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle);
945 return ERR_INVALID_HANDLE;
946 }
947
948 if (thread->GetOwnerProcess() != current_process) {
949 LOG_ERROR(Kernel_SVC,
950 "The current process does not own the current thread, thread_handle={:08X} "
951 "thread_pid={}, "
952 "current_process_pid={}",
953 handle, thread->GetOwnerProcess()->GetProcessID(),
954 current_process->GetProcessID());
955 return ERR_INVALID_HANDLE;
956 }
957
958 if (thread == GetCurrentThread()) {
959 LOG_ERROR(Kernel_SVC, "The thread handle specified is the current running thread");
960 return ERR_BUSY;
961 }
962
963 thread->SetActivity(static_cast<ThreadActivity>(activity));
937 return RESULT_SUCCESS; 964 return RESULT_SUCCESS;
938} 965}
939 966
@@ -960,7 +987,7 @@ static ResultCode GetThreadContext(VAddr thread_context, Handle handle) {
960 987
961 if (thread == GetCurrentThread()) { 988 if (thread == GetCurrentThread()) {
962 LOG_ERROR(Kernel_SVC, "The thread handle specified is the current running thread"); 989 LOG_ERROR(Kernel_SVC, "The thread handle specified is the current running thread");
963 return ERR_ALREADY_REGISTERED; 990 return ERR_BUSY;
964 } 991 }
965 992
966 Core::ARM_Interface::ThreadContext ctx = thread->GetContext(); 993 Core::ARM_Interface::ThreadContext ctx = thread->GetContext();
@@ -1245,7 +1272,10 @@ static ResultCode StartThread(Handle thread_handle) {
1245 ASSERT(thread->GetStatus() == ThreadStatus::Dormant); 1272 ASSERT(thread->GetStatus() == ThreadStatus::Dormant);
1246 1273
1247 thread->ResumeFromWait(); 1274 thread->ResumeFromWait();
1248 Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); 1275
1276 if (thread->GetStatus() == ThreadStatus::Ready) {
1277 Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
1278 }
1249 1279
1250 return RESULT_SUCCESS; 1280 return RESULT_SUCCESS;
1251} 1281}