diff options
| author | Liam <byteslice@airmail.cc> | 2022-10-04 20:15:40 -0400 |
|---|---|---|
| committer | Liam <byteslice@airmail.cc> | 2023-02-04 22:37:43 -0500 |
| commit | 2d0892da7fbfb41a1f3ff9b8a3d3d5580ff7d2fd (patch) | |
| tree | be79f36453a4735088d9230e02f426792077eeb4 /src/core/hle/kernel/svc/svc_activity.cpp | |
| parent | 498483fbaf74fe4b8b47cf34aa996c4d789ec4f1 (diff) | |
kernel/svc: Split implementations into separate files
Diffstat (limited to 'src/core/hle/kernel/svc/svc_activity.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc/svc_activity.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/core/hle/kernel/svc/svc_activity.cpp b/src/core/hle/kernel/svc/svc_activity.cpp new file mode 100644 index 0000000000..8774a5c988 --- /dev/null +++ b/src/core/hle/kernel/svc/svc_activity.cpp @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/core.h" +#include "core/hle/kernel/k_process.h" +#include "core/hle/kernel/k_thread.h" +#include "core/hle/kernel/svc.h" +#include "core/hle/kernel/svc_results.h" + +namespace Kernel::Svc { + +/// Sets the thread activity +Result SetThreadActivity(Core::System& system, Handle thread_handle, + ThreadActivity thread_activity) { + LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", thread_handle, + thread_activity); + + // Validate the activity. + constexpr auto IsValidThreadActivity = [](ThreadActivity activity) { + return activity == ThreadActivity::Runnable || activity == ThreadActivity::Paused; + }; + R_UNLESS(IsValidThreadActivity(thread_activity), ResultInvalidEnumValue); + + // Get the thread from its handle. + KScopedAutoObject thread = + system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle); + R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); + + // Check that the activity is being set on a non-current thread for the current process. + R_UNLESS(thread->GetOwnerProcess() == system.Kernel().CurrentProcess(), ResultInvalidHandle); + R_UNLESS(thread.GetPointerUnsafe() != GetCurrentThreadPointer(system.Kernel()), ResultBusy); + + // Set the activity. + R_TRY(thread->SetActivity(thread_activity)); + + return ResultSuccess; +} + +Result SetThreadActivity32(Core::System& system, Handle thread_handle, + ThreadActivity thread_activity) { + return SetThreadActivity(system, thread_handle, thread_activity); +} + +} // namespace Kernel::Svc |
