diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2022-05-05 15:23:30 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-05 15:23:30 -0300 |
| commit | 42a2a80b876bfbaac212f4f485f3e4019893b8a0 (patch) | |
| tree | 1d57ab18a156b8a9cce526fbeae0716320b76fa8 /Ryujinx.HLE/HOS/Services | |
| parent | 54deded929203a64555d97424d5bb4b884fff69f (diff) | |
Enable JIT service LLE (#2959)
* Enable JIT service LLE
* Force disable PPTC when using the JIT service
PPTC does not support multiple guest processes
* Fix build
* Make SM service registration per emulation context rather than global
* Address PR feedback
Diffstat (limited to 'Ryujinx.HLE/HOS/Services')
6 files changed, 126 insertions, 20 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 efc1884f..b4a92d69 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs @@ -2,9 +2,12 @@ using LibHac; using LibHac.Account; using LibHac.Common; using LibHac.Fs; +using LibHac.FsSystem; +using LibHac.Ncm; using LibHac.Ns; using Ryujinx.Common; using Ryujinx.Common.Logging; +using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Memory; @@ -12,9 +15,11 @@ using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage; using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types; using Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService; +using Ryujinx.HLE.HOS.Services.Sm; using Ryujinx.HLE.HOS.SystemState; using System; using System.Numerics; +using System.Threading; using static LibHac.Fs.ApplicationSaveDataManagement; using AccountUid = Ryujinx.HLE.HOS.Services.Account.Acc.UserId; @@ -37,6 +42,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati private int _notificationStorageChannelEventHandle; private int _healthWarningDisappearedSystemEventHandle; + private int _jitLoaded; + private HorizonClient _horizon; public IApplicationFunctions(Horizon system) @@ -631,5 +638,31 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati return ResultCode.Success; } + + [CommandHipc(1001)] // 10.0.0+ + // PrepareForJit() + public ResultCode PrepareForJit(ServiceCtx context) + { + if (Interlocked.Exchange(ref _jitLoaded, 1) == 0) + { + string jitPath = context.Device.System.ContentManager.GetInstalledContentPath(0x010000000000003B, StorageId.BuiltInSystem, NcaContentType.Program); + string filePath = context.Device.FileSystem.SwitchPathToSystemPath(jitPath); + + if (string.IsNullOrWhiteSpace(filePath)) + { + throw new InvalidSystemResourceException($"JIT (010000000000003B) system title not found! The JIT will not work, provide the system archive to fix this error. (See https://github.com/Ryujinx/Ryujinx#requirements for more information)"); + } + + context.Device.Application.LoadServiceNca(filePath); + + // FIXME: Most likely not how this should be done? + while (!context.Device.System.SmRegistry.IsServiceRegistered("jit:u")) + { + context.Device.System.SmRegistry.WaitForServiceRegistration(); + } + } + + return ResultCode.Success; + } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs b/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs index d986bc41..5590bfdd 100644 --- a/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs @@ -579,6 +579,15 @@ namespace Ryujinx.HLE.HOS.Services.Ro return ResultCode.Success; } + [CommandHipc(10)] + // LoadNrr2(u64, u64, u64, pid) + public ResultCode LoadNrr2(ServiceCtx context) + { + context.Device.System.KernelContext.Syscall.CloseHandle(context.Request.HandleDesc.ToCopy[0]); + + return LoadNrr(context); + } + protected override void Dispose(bool isDisposing) { if (isDisposing) diff --git a/Ryujinx.HLE/HOS/Services/ServerBase.cs b/Ryujinx.HLE/HOS/Services/ServerBase.cs index 1a1e4a34..90783344 100644 --- a/Ryujinx.HLE/HOS/Services/ServerBase.cs +++ b/Ryujinx.HLE/HOS/Services/ServerBase.cs @@ -4,7 +4,6 @@ using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Ipc; using Ryujinx.HLE.HOS.Kernel.Process; using Ryujinx.HLE.HOS.Kernel.Threading; -using Ryujinx.HLE.HOS.Services.Sm; using System; using System.Buffers.Binary; using System.Collections.Generic; diff --git a/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs b/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs index 88888f34..1ce7bbfc 100644 --- a/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs +++ b/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs @@ -222,7 +222,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings return ResultCode.Success; } - [CommandHipc(60)] + [CommandHipc(60)] // IsUserSystemClockAutomaticCorrectionEnabled() -> bool public ResultCode IsUserSystemClockAutomaticCorrectionEnabled(ServiceCtx context) { @@ -234,6 +234,17 @@ namespace Ryujinx.HLE.HOS.Services.Settings return ResultCode.Success; } + [CommandHipc(62)] + // GetDebugModeFlag() -> bool + public ResultCode GetDebugModeFlag(ServiceCtx context) + { + context.ResponseData.Write(false); + + Logger.Stub?.PrintStub(LogClass.ServiceSet); + + return ResultCode.Success; + } + [CommandHipc(77)] // GetDeviceNickName() -> buffer<nn::settings::system::DeviceNickName, 0x16> public ResultCode GetDeviceNickName(ServiceCtx context) diff --git a/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs b/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs index a5595e31..8e66b28d 100644 --- a/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs @@ -1,11 +1,9 @@ using Ryujinx.Common.Logging; -using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Kernel; using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Ipc; using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; @@ -17,21 +15,19 @@ namespace Ryujinx.HLE.HOS.Services.Sm { private static Dictionary<string, Type> _services; - private static readonly ConcurrentDictionary<string, KPort> _registeredServices; - + private readonly SmRegistry _registry; private readonly ServerBase _commonServer; private bool _isInitialized; - public IUserInterface(KernelContext context) + public IUserInterface(KernelContext context, SmRegistry registry) { _commonServer = new ServerBase(context, "CommonServer"); + _registry = registry; } static IUserInterface() { - _registeredServices = new ConcurrentDictionary<string, KPort>(); - _services = Assembly.GetExecutingAssembly().GetTypes() .SelectMany(type => type.GetCustomAttributes(typeof(ServiceAttribute), true) .Select(service => (((ServiceAttribute)service).Name, type))) @@ -74,7 +70,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm KSession session = new KSession(context.Device.System.KernelContext); - if (_registeredServices.TryGetValue(name, out KPort port)) + if (_registry.TryGetService(name, out KPort port)) { KernelResult result = port.EnqueueIncomingSession(session.ServerSession); @@ -82,6 +78,15 @@ namespace Ryujinx.HLE.HOS.Services.Sm { throw new InvalidOperationException($"Session enqueue on port returned error \"{result}\"."); } + + if (context.Process.HandleTable.GenerateHandle(session.ClientSession, out int handle) != KernelResult.Success) + { + throw new InvalidOperationException("Out of handles!"); + } + + session.ClientSession.DecrementReferenceCount(); + + context.Response.HandleDesc = IpcHandleDesc.MakeMove(handle); } else { @@ -107,17 +112,17 @@ namespace Ryujinx.HLE.HOS.Services.Sm throw new NotImplementedException(name); } } - } - if (context.Process.HandleTable.GenerateHandle(session.ClientSession, out int handle) != KernelResult.Success) - { - throw new InvalidOperationException("Out of handles!"); - } + if (context.Process.HandleTable.GenerateHandle(session.ClientSession, out int handle) != KernelResult.Success) + { + throw new InvalidOperationException("Out of handles!"); + } - session.ServerSession.DecrementReferenceCount(); - session.ClientSession.DecrementReferenceCount(); + session.ServerSession.DecrementReferenceCount(); + session.ClientSession.DecrementReferenceCount(); - context.Response.HandleDesc = IpcHandleDesc.MakeMove(handle); + context.Response.HandleDesc = IpcHandleDesc.MakeMove(handle); + } return ResultCode.Success; } @@ -179,7 +184,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm KPort port = new KPort(context.Device.System.KernelContext, maxSessions, isLight, 0); - if (!_registeredServices.TryAdd(name, port)) + if (!_registry.TryRegister(name, port)) { return ResultCode.AlreadyRegistered; } @@ -219,7 +224,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm return ResultCode.InvalidName; } - if (!_registeredServices.TryRemove(name, out _)) + if (!_registry.Unregister(name)) { return ResultCode.NotRegistered; } diff --git a/Ryujinx.HLE/HOS/Services/Sm/SmRegistry.cs b/Ryujinx.HLE/HOS/Services/Sm/SmRegistry.cs new file mode 100644 index 00000000..e62e0eb5 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Sm/SmRegistry.cs @@ -0,0 +1,49 @@ +using Ryujinx.HLE.HOS.Kernel.Ipc; +using System.Collections.Concurrent; +using System.Threading; + +namespace Ryujinx.HLE.HOS.Services.Sm +{ + class SmRegistry + { + private readonly ConcurrentDictionary<string, KPort> _registeredServices; + private readonly AutoResetEvent _serviceRegistrationEvent; + + public SmRegistry() + { + _registeredServices = new ConcurrentDictionary<string, KPort>(); + _serviceRegistrationEvent = new AutoResetEvent(false); + } + + public bool TryGetService(string name, out KPort port) + { + return _registeredServices.TryGetValue(name, out port); + } + + public bool TryRegister(string name, KPort port) + { + if (_registeredServices.TryAdd(name, port)) + { + _serviceRegistrationEvent.Set(); + return true; + } + + return false; + } + + public bool Unregister(string name) + { + return _registeredServices.TryRemove(name, out _); + } + + public bool IsServiceRegistered(string name) + { + return _registeredServices.TryGetValue(name, out _); + } + + public void WaitForServiceRegistration() + { + _serviceRegistrationEvent.WaitOne(); + } + } +}
\ No newline at end of file |
