From cf6cd714884c41e9550757e364c2f4f5b04fc7f3 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 1 Dec 2020 20:23:43 -0300 Subject: IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel (#1458) * IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel * Fix for applet transfer memory + some nits * Keep handles if possible to avoid server handle table exhaustion * Fix IPC ZeroFill bug * am: Correctly implement CreateManagedDisplayLayer and implement CreateManagedDisplaySeparableLayer CreateManagedDisplaySeparableLayer is requires since 10.x+ when appletResourceUserId != 0 * Make it exit properly * Make ServiceNotImplementedException show the full message again * Allow yielding execution to avoid starving other threads * Only wait if active * Merge IVirtualMemoryManager and IAddressSpaceManager * Fix Ro loading data from the wrong process Co-authored-by: Thog --- .../HOS/Services/Nifm/StaticService/IRequest.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/Nifm/StaticService') diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs index 2f6be8bf..51f9487f 100644 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs +++ b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs @@ -11,6 +11,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService private KEvent _event0; private KEvent _event1; + private int _event0Handle; + private int _event1Handle; + private uint _version; public IRequest(Horizon system, uint version) @@ -50,17 +53,23 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService // GetSystemEventReadableHandles() -> (handle, handle) public ResultCode GetSystemEventReadableHandles(ServiceCtx context) { - if (context.Process.HandleTable.GenerateHandle(_event0.ReadableEvent, out int handle0) != KernelResult.Success) + if (_event0Handle == 0) { - throw new InvalidOperationException("Out of handles!"); + if (context.Process.HandleTable.GenerateHandle(_event0.ReadableEvent, out _event0Handle) != KernelResult.Success) + { + throw new InvalidOperationException("Out of handles!"); + } } - if (context.Process.HandleTable.GenerateHandle(_event1.ReadableEvent, out int handle1) != KernelResult.Success) + if (_event1Handle == 0) { - throw new InvalidOperationException("Out of handles!"); + if (context.Process.HandleTable.GenerateHandle(_event1.ReadableEvent, out _event1Handle) != KernelResult.Success) + { + throw new InvalidOperationException("Out of handles!"); + } } - context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle0, handle1); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_event0Handle, _event1Handle); return ResultCode.Success; } @@ -107,7 +116,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService return ResultCode.Unknown180; } - // Returns appletId, libraryAppletMode, outSize and a buffer. + // Returns appletId, libraryAppletMode, outSize and a buffer. // Returned applet ids- (0x19, 0xf, 0xe) // libraryAppletMode seems to be 0 for all applets supported. -- cgit v1.2.3