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 --- Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs | 28 ++++++++------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs') diff --git a/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs b/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs index d8f31faf..69bb3708 100644 --- a/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs @@ -1,5 +1,6 @@ using Ryujinx.Common.Logging; using Ryujinx.HLE.HOS.Ipc; +using Ryujinx.HLE.HOS.Kernel; using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Ipc; using System; @@ -11,18 +12,17 @@ using System.Reflection; namespace Ryujinx.HLE.HOS.Services.Sm { - [Service("sm:")] class IUserInterface : IpcService { private Dictionary _services; - private ConcurrentDictionary _registeredServices; + private readonly ConcurrentDictionary _registeredServices; private readonly ServerBase _commonServer; private bool _isInitialized; - public IUserInterface(ServiceCtx context = null) : base(new ServerBase("SmServer")) + public IUserInterface(KernelContext context) { _registeredServices = new ConcurrentDictionary(); @@ -31,18 +31,9 @@ namespace Ryujinx.HLE.HOS.Services.Sm .Select(service => (((ServiceAttribute)service).Name, type))) .ToDictionary(service => service.Name, service => service.type); - _commonServer = new ServerBase("CommonServer"); - } - - public static void InitializePort(Horizon system) - { - KPort port = new KPort(system.KernelContext, 256, false, 0); - - port.ClientPort.SetName("sm:"); - - IUserInterface smService = new IUserInterface(); + TrySetServer(new ServerBase(context, "SmServer") { SmObject = this }); - port.ClientPort.Service = smService; + _commonServer = new ServerBase(context, "CommonServer"); } [Command(0)] @@ -92,16 +83,13 @@ namespace Ryujinx.HLE.HOS.Services.Sm : (IpcService)Activator.CreateInstance(type, context); service.TrySetServer(_commonServer); - - session.ClientSession.Service = service; + service.Server.AddSessionObj(session.ServerSession, service); } else { if (ServiceConfiguration.IgnoreMissingServices) { Logger.Warning?.Print(LogClass.Service, $"Missing service {name} ignored"); - - session.ClientSession.Service = new DummyService(name); } else { @@ -142,7 +130,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm int maxSessions = context.RequestData.ReadInt32(); - if (name == string.Empty) + if (string.IsNullOrEmpty(name)) { return ResultCode.InvalidName; } @@ -185,7 +173,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm int maxSessions = context.RequestData.ReadInt32(); - if (name == string.Empty) + if (string.IsNullOrEmpty(name)) { return ResultCode.InvalidName; } -- cgit v1.2.3