mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-28 13:44:11 -04:00
kern SvcGetCurrentProcessorNumber, SvcSetProcessActivity, half of SvcSetThreadActivity
This commit is contained in:
parent
23eed522d3
commit
1d4d637818
6 changed files with 148 additions and 7 deletions
|
@ -21,28 +21,81 @@ namespace ams::kern::svc {
|
|||
|
||||
namespace {
|
||||
|
||||
constexpr bool IsValidThreadActivity(ams::svc::ThreadActivity thread_activity) {
|
||||
switch (thread_activity) {
|
||||
case ams::svc::ThreadActivity_Runnable:
|
||||
case ams::svc::ThreadActivity_Paused:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr bool IsValidProcessActivity(ams::svc::ProcessActivity process_activity) {
|
||||
switch (process_activity) {
|
||||
case ams::svc::ProcessActivity_Runnable:
|
||||
case ams::svc::ProcessActivity_Paused:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Result SetThreadActivity(ams::svc::Handle thread_handle, ams::svc::ThreadActivity thread_activity) {
|
||||
/* Validate the activity. */
|
||||
R_UNLESS(IsValidThreadActivity(thread_activity), svc::ResultInvalidEnumValue());
|
||||
|
||||
/* Get the thread from its handle. */
|
||||
KScopedAutoObject thread = GetCurrentProcess().GetHandleTable().GetObject<KThread>(thread_handle);
|
||||
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
|
||||
|
||||
/* Check that the activity is being set on a non-current thread for the current process. */
|
||||
R_UNLESS(thread->GetOwnerProcess() == GetCurrentProcessPointer(), svc::ResultInvalidHandle());
|
||||
R_UNLESS(thread.GetPointerUnsafe() != GetCurrentThreadPointer(), svc::ResultBusy());
|
||||
|
||||
/* Set the activity. */
|
||||
R_TRY(thread->SetActivity(thread_activity));
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SetProcessActivity(ams::svc::Handle process_handle, ams::svc::ProcessActivity process_activity) {
|
||||
/* Validate the activity. */
|
||||
R_UNLESS(IsValidProcessActivity(process_activity), svc::ResultInvalidEnumValue());
|
||||
|
||||
/* Get the process from its handle. */
|
||||
KScopedAutoObject process = GetCurrentProcess().GetHandleTable().GetObject<KProcess>(process_handle);
|
||||
R_UNLESS(process.IsNotNull(), svc::ResultInvalidHandle());
|
||||
|
||||
/* Check that the activity isn't being set on the current process. */
|
||||
R_UNLESS(process.GetPointerUnsafe() != GetCurrentProcessPointer(), svc::ResultBusy());
|
||||
|
||||
/* Set the activity. */
|
||||
R_TRY(process->SetActivity(process_activity));
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ============================= 64 ABI ============================= */
|
||||
|
||||
Result SetThreadActivity64(ams::svc::Handle thread_handle, ams::svc::ThreadActivity thread_activity) {
|
||||
MESOSPHERE_PANIC("Stubbed SvcSetThreadActivity64 was called.");
|
||||
return SetThreadActivity(thread_handle, thread_activity);
|
||||
}
|
||||
|
||||
Result SetProcessActivity64(ams::svc::Handle process_handle, ams::svc::ProcessActivity process_activity) {
|
||||
MESOSPHERE_PANIC("Stubbed SvcSetProcessActivity64 was called.");
|
||||
return SetProcessActivity(process_handle, process_activity);
|
||||
}
|
||||
|
||||
/* ============================= 64From32 ABI ============================= */
|
||||
|
||||
Result SetThreadActivity64From32(ams::svc::Handle thread_handle, ams::svc::ThreadActivity thread_activity) {
|
||||
MESOSPHERE_PANIC("Stubbed SvcSetThreadActivity64From32 was called.");
|
||||
return SetThreadActivity(thread_handle, thread_activity);
|
||||
}
|
||||
|
||||
Result SetProcessActivity64From32(ams::svc::Handle process_handle, ams::svc::ProcessActivity process_activity) {
|
||||
MESOSPHERE_PANIC("Stubbed SvcSetProcessActivity64From32 was called.");
|
||||
return SetProcessActivity(process_handle, process_activity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue