diff options
| author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
|---|---|---|
| committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
| commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
| tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.HLE/HOS/Services/Nim | |
| parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) | |
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/Nim')
10 files changed, 251 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/INetworkInstallManager.cs b/src/Ryujinx.HLE/HOS/Services/Nim/INetworkInstallManager.cs new file mode 100644 index 00000000..ad79ca0d --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Nim/INetworkInstallManager.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Nim +{ + [Service("nim")] + class INetworkInstallManager : IpcService + { + public INetworkInstallManager(ServiceCtx context) { } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServer.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServer.cs new file mode 100644 index 00000000..ab17871f --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServer.cs @@ -0,0 +1,21 @@ +using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Services.Nim.ShopServiceAccessServerInterface.ShopServiceAccessServer; + +namespace Ryujinx.HLE.HOS.Services.Nim.ShopServiceAccessServerInterface +{ + class IShopServiceAccessServer : IpcService + { + public IShopServiceAccessServer() { } + + [CommandCmif(0)] + // CreateAccessorInterface(u8) -> object<nn::ec::IShopServiceAccessor> + public ResultCode CreateAccessorInterface(ServiceCtx context) + { + MakeObject(context, new IShopServiceAccessor(context.Device.System)); + + Logger.Stub?.PrintStub(LogClass.ServiceNim); + + return ResultCode.Success; + } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServerInterface.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServerInterface.cs new file mode 100644 index 00000000..950004fa --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServerInterface.cs @@ -0,0 +1,44 @@ +using LibHac.Ncm; +using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Services.Arp; +using Ryujinx.HLE.HOS.Services.Nim.ShopServiceAccessServerInterface; + +namespace Ryujinx.HLE.HOS.Services.Nim +{ + [Service("nim:eca")] // 5.0.0+ + class IShopServiceAccessServerInterface : IpcService + { + public IShopServiceAccessServerInterface(ServiceCtx context) { } + + [CommandCmif(0)] + // CreateServerInterface(pid, handle<unknown>, u64) -> object<nn::ec::IShopServiceAccessServer> + public ResultCode CreateServerInterface(ServiceCtx context) + { + // Close transfer memory immediately as we don't use it. + context.Device.System.KernelContext.Syscall.CloseHandle(context.Request.HandleDesc.ToCopy[0]); + + MakeObject(context, new IShopServiceAccessServer()); + + Logger.Stub?.PrintStub(LogClass.ServiceNim); + + return ResultCode.Success; + } + + [CommandCmif(4)] // 10.0.0+ + // IsLargeResourceAvailable(pid) -> b8 + public ResultCode IsLargeResourceAvailable(ServiceCtx context) + { + // TODO: Service calls arp:r GetApplicationInstanceId (10.0.0+) then if it fails it calls arp:r GetMicroApplicationInstanceId (10.0.0+) + // then if it fails it returns the arp:r result code. + + // NOTE: Firmare 10.0.0+ don't use the Pid here anymore, but the returned InstanceId. We don't support that for now so we can just use the Pid instead. + StorageId baseStorageId = (StorageId)ApplicationLaunchProperty.GetByPid(context).BaseGameStorageId; + + // NOTE: Service returns ResultCode.InvalidArgument if baseStorageId is null, doesn't occur in our case. + + context.ResponseData.Write(baseStorageId == StorageId.Host); + + return ResultCode.Success; + } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessSystemInterface.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessSystemInterface.cs new file mode 100644 index 00000000..bf201b98 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessSystemInterface.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Nim +{ + [Service("nim:ecas")] // 7.0.0+ + class IShopServiceAccessSystemInterface : IpcService + { + public IShopServiceAccessSystemInterface(ServiceCtx context) { } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessor.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessor.cs new file mode 100644 index 00000000..3c0136fa --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessor.cs @@ -0,0 +1,42 @@ +using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Ipc; +using Ryujinx.HLE.HOS.Kernel.Threading; +using Ryujinx.HLE.HOS.Services.Nim.ShopServiceAccessServerInterface.ShopServiceAccessServer.ShopServiceAccessor; +using Ryujinx.Horizon.Common; +using System; + +namespace Ryujinx.HLE.HOS.Services.Nim.ShopServiceAccessServerInterface.ShopServiceAccessServer +{ + class IShopServiceAccessor : IpcService + { + private readonly KEvent _event; + + private int _eventHandle; + + public IShopServiceAccessor(Horizon system) + { + _event = new KEvent(system.KernelContext); + } + + [CommandCmif(0)] + // CreateAsyncInterface(u64) -> (handle<copy>, object<nn::ec::IShopServiceAsync>) + public ResultCode CreateAsyncInterface(ServiceCtx context) + { + MakeObject(context, new IShopServiceAsync()); + + if (_eventHandle == 0) + { + if (context.Process.HandleTable.GenerateHandle(_event.ReadableEvent, out _eventHandle) != Result.Success) + { + throw new InvalidOperationException("Out of handles!"); + } + } + + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_eventHandle); + + Logger.Stub?.PrintStub(LogClass.ServiceNim); + + return ResultCode.Success; + } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAsync.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAsync.cs new file mode 100644 index 00000000..81d892c5 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAsync.cs @@ -0,0 +1,7 @@ +namespace Ryujinx.HLE.HOS.Services.Nim.ShopServiceAccessServerInterface.ShopServiceAccessServer.ShopServiceAccessor +{ + class IShopServiceAsync : IpcService + { + public IShopServiceAsync() { } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceManager.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceManager.cs new file mode 100644 index 00000000..2420615a --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceManager.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Nim +{ + [Service("nim:shp")] + class IShopServiceManager : IpcService + { + public IShopServiceManager(ServiceCtx context) { } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/IStaticService.cs b/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/IStaticService.cs new file mode 100644 index 00000000..4a63615b --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/IStaticService.cs @@ -0,0 +1,24 @@ +using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Services.Nim.Ntc.StaticService; + +namespace Ryujinx.HLE.HOS.Services.Nim.Ntc +{ + [Service("ntc")] + class IStaticService : IpcService + { + public IStaticService(ServiceCtx context) { } + + [CommandCmif(0)] + // OpenEnsureNetworkClockAvailabilityService(u64) -> object<nn::ntc::detail::service::IEnsureNetworkClockAvailabilityService> + public ResultCode CreateAsyncInterface(ServiceCtx context) + { + ulong unknown = context.RequestData.ReadUInt64(); + + MakeObject(context, new IEnsureNetworkClockAvailabilityService(context)); + + Logger.Stub?.PrintStub(LogClass.ServiceNtc, new { unknown }); + + return ResultCode.Success; + } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/StaticService/IEnsureNetworkClockAvailabilityService.cs b/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/StaticService/IEnsureNetworkClockAvailabilityService.cs new file mode 100644 index 00000000..82d0b5a8 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/StaticService/IEnsureNetworkClockAvailabilityService.cs @@ -0,0 +1,77 @@ +using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Ipc; +using Ryujinx.HLE.HOS.Kernel.Threading; +using Ryujinx.Horizon.Common; +using System; + +namespace Ryujinx.HLE.HOS.Services.Nim.Ntc.StaticService +{ + class IEnsureNetworkClockAvailabilityService : IpcService + { + private KEvent _finishNotificationEvent; + private ResultCode _taskResultCode; + + public IEnsureNetworkClockAvailabilityService(ServiceCtx context) + { + _finishNotificationEvent = new KEvent(context.Device.System.KernelContext); + _taskResultCode = ResultCode.Success; + + // NOTE: The service starts a thread that polls Nintendo NTP server and syncs the time with it. + // Additionnally it gets and uses some settings too: + // autonomic_correction_interval_seconds, autonomic_correction_failed_retry_interval_seconds, + // autonomic_correction_immediate_try_count_max, autonomic_correction_immediate_try_interval_milliseconds + } + + [CommandCmif(0)] + // StartTask() + public ResultCode StartTask(ServiceCtx context) + { + if (!context.Device.Configuration.EnableInternetAccess) + { + return (ResultCode)Time.ResultCode.NetworkTimeNotAvailable; + } + + // NOTE: Since we don't support the Nintendo NTP server, we can signal the event now to confirm the update task is done. + _finishNotificationEvent.ReadableEvent.Signal(); + + Logger.Stub?.PrintStub(LogClass.ServiceNtc); + + return ResultCode.Success; + } + + [CommandCmif(1)] + // GetFinishNotificationEvent() -> handle<copy> + public ResultCode GetFinishNotificationEvent(ServiceCtx context) + { + if (context.Process.HandleTable.GenerateHandle(_finishNotificationEvent.ReadableEvent, out int finishNotificationEventHandle) != Result.Success) + { + throw new InvalidOperationException("Out of handles!"); + } + + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(finishNotificationEventHandle); + + return ResultCode.Success; + } + + [CommandCmif(2)] + // GetResult() + public ResultCode GetResult(ServiceCtx context) + { + return _taskResultCode; + } + + [CommandCmif(3)] + // Cancel() + public ResultCode Cancel(ServiceCtx context) + { + // NOTE: The update task should be canceled here. + _finishNotificationEvent.ReadableEvent.Signal(); + + _taskResultCode = (ResultCode)Time.ResultCode.NetworkTimeTaskCanceled; + + Logger.Stub?.PrintStub(LogClass.ServiceNtc); + + return ResultCode.Success; + } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Nim/ResultCode.cs new file mode 100644 index 00000000..166e39a3 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Nim/ResultCode.cs @@ -0,0 +1,12 @@ +namespace Ryujinx.HLE.HOS.Services.Nim +{ + enum ResultCode + { + ModuleId = 137, + ErrorCodeShift = 9, + + Success = 0, + + NullArgument = (90 << ErrorCodeShift) | ModuleId + } +}
\ No newline at end of file |
