From 92e5e3c505d674905ef9140e28ffebb1e4f9a57c Mon Sep 17 00:00:00 2001 From: Ac_K Date: Fri, 20 Sep 2019 06:42:32 +0200 Subject: [PATCH] am: IApplicationFunctions GetGpuErrorDetectedSystemEvent implementation (#775) --- .../ApplicationProxy/IApplicationFunctions.cs | 29 ++++++++++++++++++- .../IApplicationProxy.cs | 2 +- .../Am/AppletOE/IApplicationProxyService.cs | 1 - 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs index 798316be..f65509b5 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs @@ -1,12 +1,21 @@ using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Ipc; +using Ryujinx.HLE.HOS.Kernel.Common; +using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.HLE.HOS.Services.Am.AppletAE; using Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage; +using System; namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy { class IApplicationFunctions : IpcService { - public IApplicationFunctions() { } + private KEvent _gpuErrorDetectedSystemEvent; + + public IApplicationFunctions(Horizon system) + { + _gpuErrorDetectedSystemEvent = new KEvent(system); + } [Command(1)] // PopLaunchParameter(u32) -> object @@ -113,5 +122,23 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati return ResultCode.Success; } + + [Command(130)] // 8.0.0+ + // GetGpuErrorDetectedSystemEvent() -> handle + public ResultCode GetGpuErrorDetectedSystemEvent(ServiceCtx context) + { + if (context.Process.HandleTable.GenerateHandle(_gpuErrorDetectedSystemEvent.ReadableEvent, out int gpuErrorDetectedSystemEventHandle) != KernelResult.Success) + { + throw new InvalidOperationException("Out of handles!"); + } + + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(gpuErrorDetectedSystemEventHandle); + + // NOTE: This is used by "sdk" NSO during applet-application initialization. + // A seperate thread is setup where event-waiting is handled. + // When the Event is signaled, official sw will assert. + + return ResultCode.Success; + } } } \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs index 29ee2141..eda73e22 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs @@ -65,7 +65,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService // GetApplicationFunctions() -> object public ResultCode GetApplicationFunctions(ServiceCtx context) { - MakeObject(context, new IApplicationFunctions()); + MakeObject(context, new IApplicationFunctions(context.Device.System)); return ResultCode.Success; } diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletOE/IApplicationProxyService.cs b/Ryujinx.HLE/HOS/Services/Am/AppletOE/IApplicationProxyService.cs index fc74aa1f..0aee24fe 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletOE/IApplicationProxyService.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletOE/IApplicationProxyService.cs @@ -1,4 +1,3 @@ -using Ryujinx.HLE.HOS.Services.Am.AppletAE; using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService; namespace Ryujinx.HLE.HOS.Services.Am