aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs')
-rw-r--r--Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs79
1 files changed, 79 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs b/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs
new file mode 100644
index 00000000..1bbe24f1
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs
@@ -0,0 +1,79 @@
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel.Common;
+using Ryujinx.HLE.HOS.Services.Account.Acc.AsyncContext;
+using System;
+
+namespace Ryujinx.HLE.HOS.Services.Account.Acc
+{
+ class IAsyncContext : IpcService
+ {
+ AsyncExecution _asyncExecution;
+
+ public IAsyncContext(AsyncExecution asyncExecution)
+ {
+ _asyncExecution = asyncExecution;
+ }
+
+ [Command(0)]
+ // GetSystemEvent() -> handle<copy>
+ public ResultCode GetSystemEvent(ServiceCtx context)
+ {
+ if (context.Process.HandleTable.GenerateHandle(_asyncExecution.SystemEvent.ReadableEvent, out int _systemEventHandle) != KernelResult.Success)
+ {
+ throw new InvalidOperationException("Out of handles!");
+ }
+
+ context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_systemEventHandle);
+
+ return ResultCode.Success;
+ }
+
+ [Command(1)]
+ // Cancel()
+ public ResultCode Cancel(ServiceCtx context)
+ {
+ if (!_asyncExecution.IsInitialized)
+ {
+ return ResultCode.AsyncExecutionNotInitialized;
+ }
+
+ if (_asyncExecution.IsRunning)
+ {
+ _asyncExecution.Cancel();
+ }
+
+ return ResultCode.Success;
+ }
+
+ [Command(2)]
+ // HasDone() -> b8
+ public ResultCode HasDone(ServiceCtx context)
+ {
+ if (!_asyncExecution.IsInitialized)
+ {
+ return ResultCode.AsyncExecutionNotInitialized;
+ }
+
+ context.ResponseData.Write(_asyncExecution.SystemEvent.ReadableEvent.IsSignaled());
+
+ return ResultCode.Success;
+ }
+
+ [Command(3)]
+ // GetResult()
+ public ResultCode GetResult(ServiceCtx context)
+ {
+ if (!_asyncExecution.IsInitialized)
+ {
+ return ResultCode.AsyncExecutionNotInitialized;
+ }
+
+ if (!_asyncExecution.SystemEvent.ReadableEvent.IsSignaled())
+ {
+ return ResultCode.Unknown41;
+ }
+
+ return ResultCode.Success;
+ }
+ }
+} \ No newline at end of file