From 35e561276648ecfd828cfa4883d95f26959100c6 Mon Sep 17 00:00:00 2001 From: jduncanator <1518948+jduncanator@users.noreply.github.com> Date: Thu, 14 Nov 2019 16:18:44 +1100 Subject: Implement a rudimentary applets system (#804) * Implement Player Select applet * Initialize the Horizon system reference * Tidy up namespaces * Resolve nits * Resolve nits * Rename stack to queue * Implement an applet FIFO * Remove debugging log * Log applet creation events * Reorganise AppletFifo * More reorganisation * Final changes --- .../LibraryAppletCreator/ILibraryAppletAccessor.cs | 42 +++++++++++++++------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator') diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs b/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs index 9d8e2a96..8c4d1008 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs @@ -1,19 +1,37 @@ using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Applets; using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Threading; -using Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage; using System; namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.LibraryAppletCreator { class ILibraryAppletAccessor : IpcService { + private IApplet _applet; + + private AppletFifo _inData; + private AppletFifo _outData; + private KEvent _stateChangedEvent; - public ILibraryAppletAccessor(Horizon system) + public ILibraryAppletAccessor(AppletId appletId, Horizon system) { _stateChangedEvent = new KEvent(system); + + _applet = AppletManager.Create(appletId, system); + _inData = new AppletFifo(); + _outData = new AppletFifo(); + + _applet.AppletStateChanged += OnAppletStateChanged; + + Logger.PrintInfo(LogClass.ServiceAm, $"Applet '{appletId}' created."); + } + + private void OnAppletStateChanged(object sender, EventArgs e) + { + _stateChangedEvent.ReadableEvent.Signal(); } [Command(0)] @@ -29,8 +47,6 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); - Logger.PrintStub(LogClass.ServiceAm); - return ResultCode.Success; } @@ -38,25 +54,23 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib // Start() public ResultCode Start(ServiceCtx context) { - Logger.PrintStub(LogClass.ServiceAm); - - return ResultCode.Success; + return (ResultCode)_applet.Start(_inData, _outData); } [Command(30)] // GetResult() public ResultCode GetResult(ServiceCtx context) { - Logger.PrintStub(LogClass.ServiceAm); - - return ResultCode.Success; + return (ResultCode)_applet.GetResult(); } [Command(100)] // PushInData(object) public ResultCode PushInData(ServiceCtx context) { - Logger.PrintStub(LogClass.ServiceAm); + IStorage data = GetObject(context, 0); + + _inData.Push(data.Data); return ResultCode.Success; } @@ -65,9 +79,11 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib // PopOutData() -> object public ResultCode PopOutData(ServiceCtx context) { - MakeObject(context, new IStorage(StorageHelper.MakeLaunchParams())); + byte[] data = _outData.Pop(); + MakeObject(context, new IStorage(data)); + return ResultCode.Success; } } -} \ No newline at end of file +} -- cgit v1.2.3