mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-01-05 11:58:00 +00:00
kern: implement SvcCancelSynchronization
This commit is contained in:
parent
5b8a20dbf7
commit
26df56cd87
3 changed files with 35 additions and 2 deletions
|
@ -390,6 +390,8 @@ namespace ams::kern {
|
||||||
return this->wait_result;
|
return this->wait_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaitCancel();
|
||||||
|
|
||||||
bool IsWaitCancelled() const { return this->wait_cancelled; }
|
bool IsWaitCancelled() const { return this->wait_cancelled; }
|
||||||
void ClearWaitCancelled() { this->wait_cancelled = false; }
|
void ClearWaitCancelled() { this->wait_cancelled = false; }
|
||||||
|
|
||||||
|
|
|
@ -439,6 +439,27 @@ namespace ams::kern {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KThread::WaitCancel() {
|
||||||
|
MESOSPHERE_ASSERT_THIS();
|
||||||
|
|
||||||
|
KScopedSchedulerLock sl;
|
||||||
|
|
||||||
|
/* Check if we're waiting and cancellable. */
|
||||||
|
if (this->GetState() == ThreadState_Waiting && this->cancellable) {
|
||||||
|
if (this->sleeping_queue != nullptr) {
|
||||||
|
/* TODO: Cancel light IPC. */
|
||||||
|
MESOSPHERE_UNIMPLEMENTED();
|
||||||
|
} else {
|
||||||
|
this->SetSyncedObject(nullptr, svc::ResultCancelled());
|
||||||
|
this->SetState(ThreadState_Runnable);
|
||||||
|
this->wait_cancelled = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Otherwise, note that we cancelled a wait. */
|
||||||
|
this->wait_cancelled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void KThread::TrySuspend() {
|
void KThread::TrySuspend() {
|
||||||
MESOSPHERE_ASSERT_THIS();
|
MESOSPHERE_ASSERT_THIS();
|
||||||
MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread());
|
MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread());
|
||||||
|
|
|
@ -102,6 +102,16 @@ namespace ams::kern::svc {
|
||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result CancelSynchronization(ams::svc::Handle handle) {
|
||||||
|
/* Get the thread from its handle. */
|
||||||
|
KScopedAutoObject thread = GetCurrentProcess().GetHandleTable().GetObject<KThread>(handle);
|
||||||
|
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
|
||||||
|
|
||||||
|
/* Cancel the thread's wait. */
|
||||||
|
thread->WaitCancel();
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================= 64 ABI ============================= */
|
/* ============================= 64 ABI ============================= */
|
||||||
|
@ -119,7 +129,7 @@ namespace ams::kern::svc {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result CancelSynchronization64(ams::svc::Handle handle) {
|
Result CancelSynchronization64(ams::svc::Handle handle) {
|
||||||
MESOSPHERE_PANIC("Stubbed SvcCancelSynchronization64 was called.");
|
return CancelSynchronization(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynchronizePreemptionState64() {
|
void SynchronizePreemptionState64() {
|
||||||
|
@ -141,7 +151,7 @@ namespace ams::kern::svc {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result CancelSynchronization64From32(ams::svc::Handle handle) {
|
Result CancelSynchronization64From32(ams::svc::Handle handle) {
|
||||||
MESOSPHERE_PANIC("Stubbed SvcCancelSynchronization64From32 was called.");
|
return CancelSynchronization(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynchronizePreemptionState64From32() {
|
void SynchronizePreemptionState64From32() {
|
||||||
|
|
Loading…
Reference in a new issue