2020-02-08 19:53:27 +00:00
|
|
|
/*
|
2021-10-04 20:59:10 +01:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2020-02-08 19:53:27 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include <mesosphere.hpp>
|
|
|
|
|
|
|
|
namespace ams::kern::svc {
|
|
|
|
|
|
|
|
/* ============================= Common ============================= */
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2021-02-05 22:59:03 +00:00
|
|
|
constexpr bool IsValidVirtualCoreId(int32_t core_id) {
|
|
|
|
return (0 <= core_id && core_id < static_cast<int32_t>(cpu::NumVirtualCores));
|
2020-07-10 02:54:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Result CreateThread(ams::svc::Handle *out, ams::svc::ThreadFunc f, uintptr_t arg, uintptr_t stack_bottom, int32_t priority, int32_t core_id) {
|
|
|
|
/* Adjust core id, if it's the default magic. */
|
|
|
|
KProcess &process = GetCurrentProcess();
|
|
|
|
if (core_id == ams::svc::IdealCoreUseProcessValue) {
|
|
|
|
core_id = process.GetIdealCoreId();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate arguments. */
|
2021-02-05 22:59:03 +00:00
|
|
|
R_UNLESS(IsValidVirtualCoreId(core_id), svc::ResultInvalidCoreId());
|
2020-07-10 02:54:09 +01:00
|
|
|
R_UNLESS(((1ul << core_id) & process.GetCoreMask()) != 0, svc::ResultInvalidCoreId());
|
|
|
|
|
|
|
|
R_UNLESS(ams::svc::HighestThreadPriority <= priority && priority <= ams::svc::LowestThreadPriority, svc::ResultInvalidPriority());
|
|
|
|
R_UNLESS(process.CheckThreadPriority(priority), svc::ResultInvalidPriority());
|
|
|
|
|
2020-07-14 10:45:06 +01:00
|
|
|
/* Reserve a new thread from the process resource limit (waiting up to 100ms). */
|
2020-07-10 02:54:09 +01:00
|
|
|
KScopedResourceReservation thread_reservation(std::addressof(process), ams::svc::LimitableResource_ThreadCountMax, 1, KHardwareTimer::GetTick() + ams::svc::Tick(TimeSpan::FromMilliSeconds(100)));
|
|
|
|
R_UNLESS(thread_reservation.Succeeded(), svc::ResultLimitReached());
|
|
|
|
|
|
|
|
/* Create the thread. */
|
2020-07-19 04:03:27 +01:00
|
|
|
KThread *thread = KThread::Create();
|
|
|
|
R_UNLESS(thread != nullptr, svc::ResultOutOfResource());
|
|
|
|
ON_SCOPE_EXIT { thread->Close(); };
|
2020-07-10 02:54:09 +01:00
|
|
|
|
|
|
|
/* Initialize the thread. */
|
|
|
|
{
|
|
|
|
KScopedLightLock lk(process.GetStateLock());
|
2020-07-19 04:03:27 +01:00
|
|
|
R_TRY(KThread::InitializeUserThread(thread, reinterpret_cast<KThreadFunction>(static_cast<uintptr_t>(f)), arg, stack_bottom, priority, core_id, std::addressof(process)));
|
2020-07-10 02:54:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Commit the thread reservation. */
|
|
|
|
thread_reservation.Commit();
|
|
|
|
|
|
|
|
/* Clone the current fpu status to the new thread. */
|
|
|
|
thread->GetContext().CloneFpuStatus();
|
|
|
|
|
|
|
|
/* Register the new thread. */
|
2020-12-01 21:49:30 +00:00
|
|
|
KThread::Register(thread);
|
2020-07-10 02:54:09 +01:00
|
|
|
|
|
|
|
/* Add the thread to the handle table. */
|
2020-07-19 04:03:27 +01:00
|
|
|
R_TRY(process.GetHandleTable().Add(out, thread));
|
2020-07-10 02:54:09 +01:00
|
|
|
|
2022-02-14 22:45:32 +00:00
|
|
|
R_SUCCEED();
|
2020-07-10 02:54:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Result StartThread(ams::svc::Handle thread_handle) {
|
|
|
|
/* Get the thread from its handle. */
|
|
|
|
KScopedAutoObject thread = GetCurrentProcess().GetHandleTable().GetObject<KThread>(thread_handle);
|
|
|
|
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
|
|
|
|
|
|
|
|
/* Try to start the thread. */
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(thread->Run());
|
2020-07-10 02:54:09 +01:00
|
|
|
}
|
|
|
|
|
2020-07-10 23:31:23 +01:00
|
|
|
void ExitThread() {
|
|
|
|
GetCurrentThread().Exit();
|
2020-07-23 07:52:29 +01:00
|
|
|
MESOSPHERE_PANIC("Thread survived call to exit");
|
2020-07-10 23:31:23 +01:00
|
|
|
}
|
|
|
|
|
2020-07-11 07:30:15 +01:00
|
|
|
void SleepThread(int64_t ns) {
|
|
|
|
/* When the input tick is positive, sleep. */
|
|
|
|
if (AMS_LIKELY(ns > 0)) {
|
|
|
|
/* Convert the timeout from nanoseconds to ticks. */
|
|
|
|
/* NOTE: Nintendo does not use this conversion logic in WaitSynchronization... */
|
|
|
|
s64 timeout;
|
|
|
|
|
|
|
|
const ams::svc::Tick offset_tick(TimeSpan::FromNanoSeconds(ns));
|
|
|
|
if (AMS_LIKELY(offset_tick > 0)) {
|
|
|
|
timeout = KHardwareTimer::GetTick() + offset_tick + 2;
|
|
|
|
if (AMS_UNLIKELY(timeout <= 0)) {
|
|
|
|
timeout = std::numeric_limits<s64>::max();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
timeout = std::numeric_limits<s64>::max();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sleep. */
|
|
|
|
/* NOTE: Nintendo does not check the result of this sleep. */
|
|
|
|
GetCurrentThread().Sleep(timeout);
|
|
|
|
} else if (ns == ams::svc::YieldType_WithoutCoreMigration) {
|
|
|
|
KScheduler::YieldWithoutCoreMigration();
|
|
|
|
} else if (ns == ams::svc::YieldType_WithCoreMigration) {
|
|
|
|
KScheduler::YieldWithCoreMigration();
|
|
|
|
} else if (ns == ams::svc::YieldType_ToAnyThread) {
|
|
|
|
KScheduler::YieldToAnyThread();
|
|
|
|
} else {
|
|
|
|
/* Nintendo does nothing at all if an otherwise invalid value is passed. */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-09 21:07:38 +01:00
|
|
|
Result GetThreadPriority(int32_t *out_priority, ams::svc::Handle thread_handle) {
|
|
|
|
/* Get the thread from its handle. */
|
|
|
|
KScopedAutoObject thread = GetCurrentProcess().GetHandleTable().GetObject<KThread>(thread_handle);
|
|
|
|
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
|
2020-02-08 19:53:27 +00:00
|
|
|
|
2020-07-09 21:07:38 +01:00
|
|
|
/* Get the thread's priority. */
|
|
|
|
*out_priority = thread->GetPriority();
|
2022-02-14 22:45:32 +00:00
|
|
|
R_SUCCEED();
|
2020-07-09 21:07:38 +01:00
|
|
|
}
|
|
|
|
|
2020-07-18 06:25:01 +01:00
|
|
|
Result SetThreadPriority(ams::svc::Handle thread_handle, int32_t priority) {
|
|
|
|
/* Get the current process. */
|
|
|
|
KProcess &process = GetCurrentProcess();
|
|
|
|
|
|
|
|
/* Get the thread from its handle. */
|
|
|
|
KScopedAutoObject thread = process.GetHandleTable().GetObject<KThread>(thread_handle);
|
|
|
|
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
|
|
|
|
|
2021-04-07 09:11:17 +01:00
|
|
|
/* Validate the thread is owned by the current process. */
|
|
|
|
R_UNLESS(thread->GetOwnerProcess() == GetCurrentProcessPointer(), svc::ResultInvalidHandle());
|
|
|
|
|
|
|
|
/* Validate the priority. */
|
|
|
|
R_UNLESS(ams::svc::HighestThreadPriority <= priority && priority <= ams::svc::LowestThreadPriority, svc::ResultInvalidPriority());
|
|
|
|
R_UNLESS(process.CheckThreadPriority(priority), svc::ResultInvalidPriority());
|
|
|
|
|
2020-07-18 06:25:01 +01:00
|
|
|
/* Set the thread priority. */
|
2020-07-20 10:11:49 +01:00
|
|
|
thread->SetBasePriority(priority);
|
2022-02-14 22:45:32 +00:00
|
|
|
R_SUCCEED();
|
2020-07-18 06:25:01 +01:00
|
|
|
}
|
|
|
|
|
2020-07-23 09:25:59 +01:00
|
|
|
Result GetThreadCoreMask(int32_t *out_core_id, uint64_t *out_affinity_mask, ams::svc::Handle thread_handle) {
|
|
|
|
/* Get the thread from its handle. */
|
|
|
|
KScopedAutoObject thread = GetCurrentProcess().GetHandleTable().GetObject<KThread>(thread_handle);
|
|
|
|
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
|
|
|
|
|
|
|
|
/* Get the core mask. */
|
|
|
|
R_TRY(thread->GetCoreMask(out_core_id, out_affinity_mask));
|
|
|
|
|
2022-02-14 22:45:32 +00:00
|
|
|
R_SUCCEED();
|
2020-07-23 09:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Result SetThreadCoreMask(ams::svc::Handle thread_handle, int32_t core_id, uint64_t affinity_mask) {
|
2021-04-07 09:11:17 +01:00
|
|
|
/* Get the thread from its handle. */
|
|
|
|
KScopedAutoObject thread = GetCurrentProcess().GetHandleTable().GetObject<KThread>(thread_handle);
|
|
|
|
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
|
|
|
|
|
|
|
|
/* Validate the thread is owned by the current process. */
|
|
|
|
R_UNLESS(thread->GetOwnerProcess() == GetCurrentProcessPointer(), svc::ResultInvalidHandle());
|
|
|
|
|
2020-07-23 09:25:59 +01:00
|
|
|
/* Determine the core id/affinity mask. */
|
|
|
|
if (core_id == ams::svc::IdealCoreUseProcessValue) {
|
|
|
|
core_id = GetCurrentProcess().GetIdealCoreId();
|
|
|
|
affinity_mask = (1ul << core_id);
|
|
|
|
} else {
|
|
|
|
/* Validate the affinity mask. */
|
|
|
|
const u64 process_core_mask = GetCurrentProcess().GetCoreMask();
|
|
|
|
R_UNLESS((affinity_mask | process_core_mask) == process_core_mask, svc::ResultInvalidCoreId());
|
|
|
|
R_UNLESS(affinity_mask != 0, svc::ResultInvalidCombination());
|
|
|
|
|
|
|
|
/* Validate the core id. */
|
2021-02-05 22:59:03 +00:00
|
|
|
if (IsValidVirtualCoreId(core_id)) {
|
2020-07-23 09:25:59 +01:00
|
|
|
R_UNLESS(((1ul << core_id) & affinity_mask) != 0, svc::ResultInvalidCombination());
|
|
|
|
} else {
|
|
|
|
R_UNLESS(core_id == ams::svc::IdealCoreNoUpdate || core_id == ams::svc::IdealCoreDontCare, svc::ResultInvalidCoreId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the core mask. */
|
|
|
|
R_TRY(thread->SetCoreMask(core_id, affinity_mask));
|
|
|
|
|
2022-02-14 22:45:32 +00:00
|
|
|
R_SUCCEED();
|
2020-07-23 09:25:59 +01:00
|
|
|
}
|
|
|
|
|
2020-07-09 21:07:38 +01:00
|
|
|
Result GetThreadId(uint64_t *out_thread_id, ams::svc::Handle thread_handle) {
|
|
|
|
/* Get the thread from its handle. */
|
|
|
|
KScopedAutoObject thread = GetCurrentProcess().GetHandleTable().GetObject<KThread>(thread_handle);
|
|
|
|
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
|
|
|
|
|
|
|
|
/* Get the thread's id. */
|
|
|
|
*out_thread_id = thread->GetId();
|
2022-02-14 22:45:32 +00:00
|
|
|
R_SUCCEED();
|
2020-07-09 21:07:38 +01:00
|
|
|
}
|
2020-02-08 19:53:27 +00:00
|
|
|
|
2020-07-28 11:56:47 +01:00
|
|
|
Result GetThreadContext3(KUserPointer<ams::svc::ThreadContext *> out_context, ams::svc::Handle thread_handle) {
|
|
|
|
/* Get the thread from its handle. */
|
|
|
|
KScopedAutoObject thread = GetCurrentProcess().GetHandleTable().GetObject<KThread>(thread_handle);
|
|
|
|
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
|
|
|
|
|
|
|
|
/* Require the handle be to a non-current thread in the current process. */
|
|
|
|
R_UNLESS(thread->GetOwnerProcess() == GetCurrentProcessPointer(), svc::ResultInvalidHandle());
|
|
|
|
R_UNLESS(thread.GetPointerUnsafe() != GetCurrentThreadPointer(), svc::ResultBusy());
|
|
|
|
|
|
|
|
/* Get the thread context. */
|
|
|
|
ams::svc::ThreadContext context = {};
|
|
|
|
R_TRY(thread->GetThreadContext3(std::addressof(context)));
|
|
|
|
|
|
|
|
/* Copy the thread context to user space. */
|
|
|
|
R_TRY(out_context.CopyFrom(std::addressof(context)));
|
|
|
|
|
2022-02-14 22:45:32 +00:00
|
|
|
R_SUCCEED();
|
2020-07-28 11:56:47 +01:00
|
|
|
}
|
|
|
|
|
2020-07-31 00:52:11 +01:00
|
|
|
Result GetThreadList(int32_t *out_num_threads, KUserPointer<uint64_t *> out_thread_ids, int32_t max_out_count, ams::svc::Handle debug_handle) {
|
2024-10-10 00:50:20 +01:00
|
|
|
/* Only allow invoking the svc on development hardware. */
|
|
|
|
R_UNLESS(KTargetSystem::IsDebugMode(), svc::ResultNotImplemented());
|
|
|
|
|
2020-07-31 00:52:11 +01:00
|
|
|
/* Validate that the out count is valid. */
|
|
|
|
R_UNLESS((0 <= max_out_count && max_out_count <= static_cast<int32_t>(std::numeric_limits<int32_t>::max() / sizeof(u64))), svc::ResultOutOfRange());
|
|
|
|
|
|
|
|
/* Validate that the pointer is in range. */
|
|
|
|
if (max_out_count > 0) {
|
|
|
|
R_UNLESS(GetCurrentProcess().GetPageTable().Contains(KProcessAddress(out_thread_ids.GetUnsafePointer()), max_out_count * sizeof(u64)), svc::ResultInvalidCurrentMemory());
|
|
|
|
}
|
|
|
|
|
2024-10-10 00:50:20 +01:00
|
|
|
/* Get the handle table. */
|
|
|
|
auto &handle_table = GetCurrentProcess().GetHandleTable();
|
2020-07-31 00:52:11 +01:00
|
|
|
|
2024-10-10 00:50:20 +01:00
|
|
|
/* Try to get as a debug object. */
|
|
|
|
KScopedAutoObject debug = handle_table.GetObject<KDebug>(debug_handle);
|
|
|
|
if (debug.IsNotNull()) {
|
|
|
|
/* Check that the debug object has a process. */
|
|
|
|
R_UNLESS(debug->IsAttached(), svc::ResultProcessTerminated());
|
|
|
|
R_UNLESS(debug->OpenProcess(), svc::ResultProcessTerminated());
|
|
|
|
ON_SCOPE_EXIT { debug->CloseProcess(); };
|
2020-07-31 00:52:11 +01:00
|
|
|
|
2024-10-10 00:50:20 +01:00
|
|
|
/* Get the thread list. */
|
|
|
|
R_TRY(debug->GetProcessUnsafe()->GetThreadList(out_num_threads, out_thread_ids, max_out_count));
|
|
|
|
} else {
|
|
|
|
/* Only allow getting as a process (or global) if the caller does not have ForceDebugProd. */
|
|
|
|
R_UNLESS(!GetCurrentProcess().CanForceDebugProd(), svc::ResultInvalidHandle());
|
2020-07-31 00:52:11 +01:00
|
|
|
|
2024-10-10 00:50:20 +01:00
|
|
|
/* Try to get as a process. */
|
|
|
|
KScopedAutoObject process = handle_table.GetObjectWithoutPseudoHandle<KProcess>(debug_handle);
|
|
|
|
if (process.IsNotNull()) {
|
2020-07-31 00:52:11 +01:00
|
|
|
/* Get the thread list. */
|
|
|
|
R_TRY(process->GetThreadList(out_num_threads, out_thread_ids, max_out_count));
|
2024-10-10 00:50:20 +01:00
|
|
|
} else {
|
|
|
|
/* If the object is not a process, the caller may want the global thread list. */
|
|
|
|
R_UNLESS(debug_handle == ams::svc::InvalidHandle, svc::ResultInvalidHandle());
|
|
|
|
|
|
|
|
/* If passed invalid handle, we should return the global thread list. */
|
|
|
|
R_TRY(KThread::GetThreadList(out_num_threads, out_thread_ids, max_out_count));
|
2020-07-31 00:52:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-14 22:45:32 +00:00
|
|
|
R_SUCCEED();
|
2020-07-31 00:52:11 +01:00
|
|
|
}
|
|
|
|
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ============================= 64 ABI ============================= */
|
|
|
|
|
|
|
|
Result CreateThread64(ams::svc::Handle *out_handle, ams::svc::ThreadFunc func, ams::svc::Address arg, ams::svc::Address stack_bottom, int32_t priority, int32_t core_id) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(CreateThread(out_handle, func, arg, stack_bottom, priority, core_id));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result StartThread64(ams::svc::Handle thread_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(StartThread(thread_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ExitThread64() {
|
2020-07-10 23:31:23 +01:00
|
|
|
return ExitThread();
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SleepThread64(int64_t ns) {
|
2020-07-11 07:30:15 +01:00
|
|
|
return SleepThread(ns);
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result GetThreadPriority64(int32_t *out_priority, ams::svc::Handle thread_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(GetThreadPriority(out_priority, thread_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result SetThreadPriority64(ams::svc::Handle thread_handle, int32_t priority) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(SetThreadPriority(thread_handle, priority));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result GetThreadCoreMask64(int32_t *out_core_id, uint64_t *out_affinity_mask, ams::svc::Handle thread_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(GetThreadCoreMask(out_core_id, out_affinity_mask, thread_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result SetThreadCoreMask64(ams::svc::Handle thread_handle, int32_t core_id, uint64_t affinity_mask) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(SetThreadCoreMask(thread_handle, core_id, affinity_mask));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result GetThreadId64(uint64_t *out_thread_id, ams::svc::Handle thread_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(GetThreadId(out_thread_id, thread_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result GetThreadContext364(KUserPointer<ams::svc::ThreadContext *> out_context, ams::svc::Handle thread_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(GetThreadContext3(out_context, thread_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result GetThreadList64(int32_t *out_num_threads, KUserPointer<uint64_t *> out_thread_ids, int32_t max_out_count, ams::svc::Handle debug_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(GetThreadList(out_num_threads, out_thread_ids, max_out_count, debug_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ============================= 64From32 ABI ============================= */
|
|
|
|
|
|
|
|
Result CreateThread64From32(ams::svc::Handle *out_handle, ams::svc::ThreadFunc func, ams::svc::Address arg, ams::svc::Address stack_bottom, int32_t priority, int32_t core_id) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(CreateThread(out_handle, func, arg, stack_bottom, priority, core_id));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result StartThread64From32(ams::svc::Handle thread_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(StartThread(thread_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ExitThread64From32() {
|
2020-07-10 23:31:23 +01:00
|
|
|
return ExitThread();
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SleepThread64From32(int64_t ns) {
|
2020-07-11 07:30:15 +01:00
|
|
|
return SleepThread(ns);
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result GetThreadPriority64From32(int32_t *out_priority, ams::svc::Handle thread_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(GetThreadPriority(out_priority, thread_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result SetThreadPriority64From32(ams::svc::Handle thread_handle, int32_t priority) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(SetThreadPriority(thread_handle, priority));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result GetThreadCoreMask64From32(int32_t *out_core_id, uint64_t *out_affinity_mask, ams::svc::Handle thread_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(GetThreadCoreMask(out_core_id, out_affinity_mask, thread_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result SetThreadCoreMask64From32(ams::svc::Handle thread_handle, int32_t core_id, uint64_t affinity_mask) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(SetThreadCoreMask(thread_handle, core_id, affinity_mask));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result GetThreadId64From32(uint64_t *out_thread_id, ams::svc::Handle thread_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(GetThreadId(out_thread_id, thread_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result GetThreadContext364From32(KUserPointer<ams::svc::ThreadContext *> out_context, ams::svc::Handle thread_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(GetThreadContext3(out_context, thread_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result GetThreadList64From32(int32_t *out_num_threads, KUserPointer<uint64_t *> out_thread_ids, int32_t max_out_count, ams::svc::Handle debug_handle) {
|
2022-02-14 22:45:32 +00:00
|
|
|
R_RETURN(GetThreadList(out_num_threads, out_thread_ids, max_out_count, debug_handle));
|
2020-02-08 19:53:27 +00:00
|
|
|
}
|
|
|
|
|
2020-02-08 19:56:13 +00:00
|
|
|
}
|