kern: implement SvcSendSyncRequest(WithUserBuffer)

This commit is contained in:
Michael Scire 2020-07-09 21:30:29 -07:00
parent 4f12449acf
commit 1b2203d102
8 changed files with 228 additions and 10 deletions

View file

@ -44,10 +44,6 @@ namespace ams::kern {
this->parent->Close();
}
Result KServerSession::OnRequest(KSessionRequest *request) {
MESOSPHERE_UNIMPLEMENTED();
}
Result KServerSession::ReceiveRequest(uintptr_t message, uintptr_t buffer_size, KPhysicalAddress message_paddr) {
MESOSPHERE_UNIMPLEMENTED();
}
@ -56,6 +52,35 @@ namespace ams::kern {
MESOSPHERE_UNIMPLEMENTED();
}
Result KServerSession::OnRequest(KSessionRequest *request) {
MESOSPHERE_ASSERT_THIS();
MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread());
/* Ensure that we can handle new requests. */
R_UNLESS(!this->parent->IsServerClosed(), svc::ResultSessionClosed());
/* If there's no event, this is synchronous, so we should check for thread termination. */
if (request->GetEvent() == nullptr) {
KThread *thread = request->GetThread();
R_UNLESS(!thread->IsTerminationRequested(), svc::ResultTerminationRequested());
thread->SetState(KThread::ThreadState_Waiting);
}
/* Get whether we're empty. */
const bool was_empty = this->request_list.empty();
/* Add the request to the list. */
request->Open();
this->request_list.push_back(*request);
/* If we were empty, signal. */
if (was_empty) {
this->NotifyAvailable();
}
return ResultSuccess();
}
bool KServerSession::IsSignaledImpl() const {
MESOSPHERE_ASSERT_THIS();
MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread());