From 05f7878699b0c5412c120f6f0d04e08dc05a4156 Mon Sep 17 00:00:00 2001 From: LotP <22-lotp@users.noreply.git.ryujinx.app> Date: Wed, 1 Apr 2026 11:08:10 -0500 Subject: [PATCH] Accurate Service Names - Services now use their actual names when creating processes instead of the generic "Service". - Services now use their names encapsulated in curly brackets for threads, e.g. {HID}, instead of the default "HLE.OsThread", making it easier to see what is actually happening behind the scenes. Client threads should use <> and host threads should use {}. - Fixed a bug where initiating services would create extra unneeded servers. This is part 1 of a series of service and Horizon changes i'm working on. More will follow at a later date. --- src/Ryujinx.HLE/HOS/Horizon.cs | 22 +++++++++---------- src/Ryujinx.HLE/HOS/Services/ServerBase.cs | 10 +++++++-- .../HOS/Services/Sm/IUserInterface.cs | 10 ++++++--- src/Ryujinx.Horizon/ServiceEntry.cs | 4 +++- src/Ryujinx.Horizon/ServiceTable.cs | 2 +- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/Horizon.cs b/src/Ryujinx.HLE/HOS/Horizon.cs index c97b6511e..3006187d1 100644 --- a/src/Ryujinx.HLE/HOS/Horizon.cs +++ b/src/Ryujinx.HLE/HOS/Horizon.cs @@ -241,21 +241,21 @@ namespace Ryujinx.HLE.HOS public void InitializeServices() { SmRegistry = new SmRegistry(); - SmServer = new ServerBase(KernelContext, "SmServer", () => new IUserInterface(KernelContext, SmRegistry)); + SmServer = new ServerBase(KernelContext, "Sm", () => new IUserInterface(KernelContext, SmRegistry)); // Wait until SM server thread is done with initialization, // only then doing connections to SM is safe. SmServer.InitDone.WaitOne(); - BsdServer = new ServerBase(KernelContext, "BsdServer"); - FsServer = new ServerBase(KernelContext, "FsServer"); - HidServer = new ServerBase(KernelContext, "HidServer"); - NvDrvServer = new ServerBase(KernelContext, "NvservicesServer"); - TimeServer = new ServerBase(KernelContext, "TimeServer"); - ViServer = new ServerBase(KernelContext, "ViServerU"); - ViServerM = new ServerBase(KernelContext, "ViServerM"); - ViServerS = new ServerBase(KernelContext, "ViServerS"); - LdnServer = new ServerBase(KernelContext, "LdnServer"); + BsdServer = new ServerBase(KernelContext, "Bsd"); + FsServer = new ServerBase(KernelContext, "Fs"); + HidServer = new ServerBase(KernelContext, "Hid"); + NvDrvServer = new ServerBase(KernelContext, "Nv"); + TimeServer = new ServerBase(KernelContext, "Time"); + ViServer = new ServerBase(KernelContext, "Vi:u"); + ViServerM = new ServerBase(KernelContext, "Vi:m"); + ViServerS = new ServerBase(KernelContext, "Vi:s"); + LdnServer = new ServerBase(KernelContext, "Ldn"); StartNewServices(); } @@ -281,7 +281,7 @@ namespace Ryujinx.HLE.HOS ProcessCreationFlags.Is64Bit | ProcessCreationFlags.PoolPartitionSystem; - ProcessCreationInfo creationInfo = new("Service", 1, 0, 0x8000000, 1, Flags, 0, 0); + ProcessCreationInfo creationInfo = new(service.Name, 1, 0, 0x8000000, 1, Flags, 0, 0); uint[] defaultCapabilities = [ diff --git a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs index 2af1ef20a..baff40225 100644 --- a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs @@ -78,9 +78,15 @@ namespace Ryujinx.HLE.HOS.Services ProcessCreationFlags.Is64Bit | ProcessCreationFlags.PoolPartitionSystem; - ProcessCreationInfo creationInfo = new("Service", 1, 0, 0x8000000, 1, Flags, 0, 0); + ProcessCreationInfo creationInfo = new(Name, 1, 0, 0x8000000, 1, Flags, 0, 0); - KernelStatic.StartInitialProcess(context, creationInfo, _defaultCapabilities, 44, Main); + KernelStatic.StartInitialProcess(context, creationInfo, _defaultCapabilities, 44, () => + { + var currentThread = KernelStatic.GetCurrentThread(); + currentThread.HostThread.Name = $"{{{Name}}}"; + + Main(); + }); } private void AddPort(int serverPortHandle, Func objectFactory) diff --git a/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs b/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs index 94ee5e8b4..249e926ba 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs @@ -17,13 +17,12 @@ namespace Ryujinx.HLE.HOS.Services.Sm private static readonly Dictionary _services; private readonly SmRegistry _registry; - private readonly ServerBase _commonServer; + private ServerBase _commonServer; private bool _isInitialized; public IUserInterface(KernelContext context, SmRegistry registry) { - _commonServer = new ServerBase(context, "CommonServer"); _registry = registry; } @@ -97,6 +96,11 @@ namespace Ryujinx.HLE.HOS.Services.Sm IpcService service = GetServiceInstance(type, context, serviceAttribute.Parameter); + if (_commonServer is null) + { + _commonServer = new ServerBase(context.Device.System.KernelContext, "Common"); + } + service?.TrySetServer(_commonServer); service?.Server.AddSessionObj(session.ServerSession, service); } @@ -253,7 +257,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm public override void DestroyAtExit() { - _commonServer.Dispose(); + _commonServer?.Dispose(); base.DestroyAtExit(); } diff --git a/src/Ryujinx.Horizon/ServiceEntry.cs b/src/Ryujinx.Horizon/ServiceEntry.cs index edf76fcd8..8cdeeff21 100644 --- a/src/Ryujinx.Horizon/ServiceEntry.cs +++ b/src/Ryujinx.Horizon/ServiceEntry.cs @@ -9,12 +9,14 @@ namespace Ryujinx.Horizon private readonly Action _entrypoint; private readonly ServiceTable _serviceTable; private readonly HorizonOptions _options; + public readonly string Name; - internal ServiceEntry(Action entrypoint, ServiceTable serviceTable, HorizonOptions options) + internal ServiceEntry(Action entrypoint, ServiceTable serviceTable, HorizonOptions options, string name) { _entrypoint = entrypoint; _serviceTable = serviceTable; _options = options; + Name = name; } public void Start(ISyscallApi syscallApi, IVirtualMemoryManager addressSpace, IThreadContext threadContext) diff --git a/src/Ryujinx.Horizon/ServiceTable.cs b/src/Ryujinx.Horizon/ServiceTable.cs index db24c193d..172d2919b 100644 --- a/src/Ryujinx.Horizon/ServiceTable.cs +++ b/src/Ryujinx.Horizon/ServiceTable.cs @@ -37,7 +37,7 @@ namespace Ryujinx.Horizon void RegisterService() where T : IService { - entries.Add(new ServiceEntry(T.Main, this, options)); + entries.Add(new ServiceEntry(T.Main, this, options, typeof(T).Name)); } RegisterService();