diff --git a/Ryujinx.HLE/HOS/Services/Settings/NxSettings.cs b/Ryujinx.HLE/HOS/Services/Settings/NxSettings.cs index b679005e6b..ca3853e8b8 100644 --- a/Ryujinx.HLE/HOS/Services/Settings/NxSettings.cs +++ b/Ryujinx.HLE/HOS/Services/Settings/NxSettings.cs @@ -1704,6 +1704,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings { "time!standard_steady_clock_test_offset_minutes", 0 }, { "time!standard_steady_clock_rtc_update_interval_minutes", 5 }, { "time!standard_network_clock_sufficient_accuracy_minutes", 43200 }, + { "time!standard_user_clock_initial_year", 2019 }, { "usb!usb30_force_enabled", false }, { "wlan_debug!skip_wlan_boot", false } }; diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs index c68e8e4a32..370e7d73c9 100644 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs @@ -5,8 +5,6 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock class StandardSteadyClockCore : SteadyClockCore { private TimeSpanType _setupValue; - // TODO: move this to glue when we will have psc fully done - private ResultCode _setupResultCode; private TimeSpanType _testOffset; private TimeSpanType _internalOffset; private TimeSpanType _cachedRawTimePoint; diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs index 350dd89e3b..83ace9814f 100644 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs @@ -39,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock public virtual void SetTestOffset(TimeSpanType testOffset) {} - public virtual ResultCode GetRtcValue(out ulong rtcValue) + public ResultCode GetRtcValue(out ulong rtcValue) { rtcValue = 0; diff --git a/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs b/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs new file mode 100644 index 0000000000..c52cf43ef9 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs @@ -0,0 +1,181 @@ +using Ryujinx.Common; +using Ryujinx.HLE.HOS.Services.Pcv.Bpc; +using Ryujinx.HLE.HOS.Services.Settings; +using Ryujinx.HLE.HOS.Services.Time.Clock; + +namespace Ryujinx.HLE.HOS.Services.Time +{ + [Service("time:a", TimePermissions.Admin)] + [Service("time:r", TimePermissions.Repair)] + [Service("time:u", TimePermissions.User)] + class IStaticServiceForGlue : IpcService + { + private IStaticServiceForPsc _inner; + private TimePermissions _permissions; + + public IStaticServiceForGlue(ServiceCtx context, TimePermissions permissions) + { + _permissions = permissions; + _inner = new IStaticServiceForPsc(context, permissions); + } + + [Command(0)] + // GetStandardUserSystemClock() -> object + public ResultCode GetStandardUserSystemClock(ServiceCtx context) + { + return _inner.GetStandardUserSystemClock(context); + } + + [Command(1)] + // GetStandardNetworkSystemClock() -> object + public ResultCode GetStandardNetworkSystemClock(ServiceCtx context) + { + return _inner.GetStandardNetworkSystemClock(context); + } + + [Command(2)] + // GetStandardSteadyClock() -> object + public ResultCode GetStandardSteadyClock(ServiceCtx context) + { + return _inner.GetStandardSteadyClock(context); + } + + [Command(3)] + // GetTimeZoneService() -> object + public ResultCode GetTimeZoneService(ServiceCtx context) + { + // TODO: ITimeZoneService is wrapped, apply 9.0.0 ITimeZoneService separation. + return _inner.GetTimeZoneService(context); + } + + [Command(4)] + // GetStandardLocalSystemClock() -> object + public ResultCode GetStandardLocalSystemClock(ServiceCtx context) + { + return _inner.GetStandardLocalSystemClock(context); + } + + [Command(5)] // 4.0.0+ + // GetEphemeralNetworkSystemClock() -> object + public ResultCode GetEphemeralNetworkSystemClock(ServiceCtx context) + { + return _inner.GetEphemeralNetworkSystemClock(context); + } + + [Command(20)] // 6.0.0+ + // GetSharedMemoryNativeHandle() -> handle + public ResultCode GetSharedMemoryNativeHandle(ServiceCtx context) + { + return _inner.GetSharedMemoryNativeHandle(context); + } + + [Command(50)] // 4.0.0+ + // SetStandardSteadyClockInternalOffset(nn::TimeSpanType internal_offset) + public ResultCode SetStandardSteadyClockInternalOffset(ServiceCtx context) + { + if ((_permissions & TimePermissions.BypassUninitialized) == 0) + { + return ResultCode.PermissionDenied; + } + + TimeSpanType internalOffset = context.RequestData.ReadStruct(); + + // TODO: set:sys SetExternalSteadyClockInternalOffset(internalOffset.ToSeconds()) + + return ResultCode.Success; + } + + [Command(51)] // 9.0.0+ + // GetStandardSteadyClockRtcValue() -> u64 + public ResultCode GetStandardSteadyClockRtcValue(ServiceCtx context) + { + ResultCode result = (ResultCode)IRtcManager.GetExternalRtcValue(out ulong rtcValue); + + if (result == ResultCode.Success) + { + context.ResponseData.Write(rtcValue); + } + + return result; + } + + [Command(100)] + // IsStandardUserSystemClockAutomaticCorrectionEnabled() -> bool + public ResultCode IsStandardUserSystemClockAutomaticCorrectionEnabled(ServiceCtx context) + { + return _inner.IsStandardUserSystemClockAutomaticCorrectionEnabled(context); + } + + [Command(101)] + // SetStandardUserSystemClockAutomaticCorrectionEnabled(b8) + public ResultCode SetStandardUserSystemClockAutomaticCorrectionEnabled(ServiceCtx context) + { + return _inner.SetStandardUserSystemClockAutomaticCorrectionEnabled(context); + } + + [Command(102)] // 5.0.0+ + // GetStandardUserSystemClockInitialYear() -> u32 + public ResultCode GetStandardUserSystemClockInitialYear(ServiceCtx context) + { + if (!NxSettings.Settings.TryGetValue("time!standard_user_clock_initial_year", out object standardUserSystemClockInitialYear)) + { + // Fallback if not found in settings (nintendo actually abort here) + standardUserSystemClockInitialYear = 2019; + //throw new System.InvalidOperationException("standard_user_clock_initial_year isn't defined in system settings!"); + } + + context.ResponseData.Write((int)standardUserSystemClockInitialYear); + + return ResultCode.Success; + } + + [Command(200)] // 3.0.0+ + // IsStandardNetworkSystemClockAccuracySufficient() -> bool + public ResultCode IsStandardNetworkSystemClockAccuracySufficient(ServiceCtx context) + { + return _inner.IsStandardNetworkSystemClockAccuracySufficient(context); + } + + [Command(201)] // 6.0.0+ + // GetStandardUserSystemClockAutomaticCorrectionUpdatedTime() -> nn::time::SteadyClockTimePoint + public ResultCode GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(ServiceCtx context) + { + return _inner.GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(context); + } + + [Command(300)] // 4.0.0+ + // CalculateMonotonicSystemClockBaseTimePoint(nn::time::SystemClockContext) -> s64 + public ResultCode CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx context) + { + return _inner.CalculateMonotonicSystemClockBaseTimePoint(context); + } + + [Command(400)] // 4.0.0+ + // GetClockSnapshot(u8) -> buffer + public ResultCode GetClockSnapshot(ServiceCtx context) + { + return _inner.GetClockSnapshot(context); + } + + [Command(401)] // 4.0.0+ + // GetClockSnapshotFromSystemClockContext(u8, nn::time::SystemClockContext, nn::time::SystemClockContext) -> buffer + public ResultCode GetClockSnapshotFromSystemClockContext(ServiceCtx context) + { + return _inner.GetClockSnapshotFromSystemClockContext(context); + } + + [Command(500)] // 4.0.0+ + // CalculateStandardUserSystemClockDifferenceByUser(buffer, buffer) -> nn::TimeSpanType + public ResultCode CalculateStandardUserSystemClockDifferenceByUser(ServiceCtx context) + { + return _inner.CalculateStandardUserSystemClockDifferenceByUser(context); + } + + [Command(501)] // 4.0.0+ + // CalculateSpanBetween(buffer, buffer) -> nn::TimeSpanType + public ResultCode CalculateSpanBetween(ServiceCtx context) + { + return _inner.CalculateSpanBetween(context); + } + } +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs b/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs similarity index 98% rename from Ryujinx.HLE/HOS/Services/Time/IStaticService.cs rename to Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs index 4141cc0b58..725107b284 100644 --- a/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs +++ b/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs @@ -12,20 +12,18 @@ using System.Runtime.InteropServices; namespace Ryujinx.HLE.HOS.Services.Time { - //[Service("time:a", TimePermissions.Admin)] [Service("time:s", TimePermissions.System)] - //[Service("time:u", TimePermissions.User)] [Service("time:su", TimePermissions.SystemUpdate)] - class IStaticService : IpcService + class IStaticServiceForPsc : IpcService { private TimeManager _timeManager; private TimePermissions _permissions; private int _timeSharedMemoryNativeHandle = 0; - public IStaticService(ServiceCtx context, TimePermissions permissions) : this(TimeManager.Instance, permissions) {} + public IStaticServiceForPsc(ServiceCtx context, TimePermissions permissions) : this(TimeManager.Instance, permissions) {} - public IStaticService(TimeManager manager, TimePermissions permissions) + public IStaticServiceForPsc(TimeManager manager, TimePermissions permissions) { _permissions = permissions; _timeManager = manager; diff --git a/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs b/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs index 372f55dd7e..e7460acb61 100644 --- a/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs +++ b/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs @@ -24,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.Time // GetUserStaticService() -> object public ResultCode GetUserStaticService(ServiceCtx context) { - MakeObject(context, new IStaticService(_timeManager, TimePermissions.User)); + MakeObject(context, new IStaticServiceForPsc(_timeManager, TimePermissions.User)); return ResultCode.Success; } @@ -33,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.Time // GetAdminStaticService() -> object public ResultCode GetAdminStaticService(ServiceCtx context) { - MakeObject(context, new IStaticService(_timeManager, TimePermissions.Admin)); + MakeObject(context, new IStaticServiceForPsc(_timeManager, TimePermissions.Admin)); return ResultCode.Success; } @@ -42,7 +42,7 @@ namespace Ryujinx.HLE.HOS.Services.Time // GetRepairStaticService() -> object public ResultCode GetRepairStaticService(ServiceCtx context) { - MakeObject(context, new IStaticService(_timeManager, TimePermissions.Repair)); + MakeObject(context, new IStaticServiceForPsc(_timeManager, TimePermissions.Repair)); return ResultCode.Success; } @@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Time // GetManufactureStaticService() -> object public ResultCode GetManufactureStaticService(ServiceCtx context) { - MakeObject(context, new IStaticService(_timeManager, TimePermissions.Manufacture)); + MakeObject(context, new IStaticServiceForPsc(_timeManager, TimePermissions.Manufacture)); return ResultCode.Success; }