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

@ -28,4 +28,50 @@ namespace ams::kern {
MESOSPHERE_ASSERT_THIS();
}
Result KClientSession::SendSyncRequest(uintptr_t address, size_t size) {
MESOSPHERE_ASSERT_THIS();
/* Create a session request. */
KSessionRequest *request = KSessionRequest::Create();
R_UNLESS(request != nullptr, svc::ResultOutOfResource());
ON_SCOPE_EXIT { request->Close(); };
/* Initialize the request. */
request->Initialize(nullptr, address, size);
/* Send the request. */
{
KScopedSchedulerLock sl;
GetCurrentThread().SetSyncedObject(nullptr, ResultSuccess());
R_TRY(this->parent->OnRequest(request));
}
/* Get the result. */
KSynchronizationObject *dummy;
return GetCurrentThread().GetWaitResult(std::addressof(dummy));
}
Result KClientSession::SendAsyncRequest(KWritableEvent *event, uintptr_t address, size_t size) {
MESOSPHERE_ASSERT_THIS();
/* Create a session request. */
KSessionRequest *request = KSessionRequest::Create();
R_UNLESS(request != nullptr, svc::ResultOutOfResource());
ON_SCOPE_EXIT { request->Close(); };
/* Initialize the request. */
request->Initialize(event, address, size);
/* Send the request. */
{
KScopedSchedulerLock sl;
R_TRY(this->parent->OnRequest(request));
}
return ResultSuccess();
}
}