kern: implement SvcDebugActiveProcess, svcGetDebugEvent, SvcWaitProcessWideKeyAtomic

This commit is contained in:
Michael Scire 2020-07-18 20:03:27 -07:00 committed by SciresM
parent 1c5b58ce66
commit 36eb78a3ce
17 changed files with 728 additions and 24 deletions

View file

@ -44,13 +44,14 @@ namespace ams::kern::svc {
R_UNLESS(thread_reservation.Succeeded(), svc::ResultLimitReached());
/* Create the thread. */
KScopedAutoObject thread = KThread::Create();
R_UNLESS(thread.IsNotNull(), svc::ResultOutOfResource());
KThread *thread = KThread::Create();
R_UNLESS(thread != nullptr, svc::ResultOutOfResource());
ON_SCOPE_EXIT { thread->Close(); };
/* Initialize the thread. */
{
KScopedLightLock lk(process.GetStateLock());
R_TRY(KThread::InitializeUserThread(thread.GetPointerUnsafe(), reinterpret_cast<KThreadFunction>(static_cast<uintptr_t>(f)), arg, stack_bottom, priority, core_id, std::addressof(process)));
R_TRY(KThread::InitializeUserThread(thread, reinterpret_cast<KThreadFunction>(static_cast<uintptr_t>(f)), arg, stack_bottom, priority, core_id, std::addressof(process)));
}
/* Commit the thread reservation. */
@ -60,10 +61,10 @@ namespace ams::kern::svc {
thread->GetContext().CloneFpuStatus();
/* Register the new thread. */
R_TRY(KThread::Register(thread.GetPointerUnsafe()));
R_TRY(KThread::Register(thread));
/* Add the thread to the handle table. */
R_TRY(process.GetHandleTable().Add(out, thread.GetPointerUnsafe()));
R_TRY(process.GetHandleTable().Add(out, thread));
return ResultSuccess();
}