2019-10-08 05:48:49 +02:00
|
|
|
|
using Ryujinx.Common;
|
|
|
|
|
using Ryujinx.HLE.HOS.Services.Pcv.Bpc;
|
|
|
|
|
using Ryujinx.HLE.HOS.Services.Settings;
|
|
|
|
|
using Ryujinx.HLE.HOS.Services.Time.Clock;
|
|
|
|
|
using Ryujinx.HLE.HOS.Services.Time.StaticService;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2020-12-02 13:14:44 +01:00
|
|
|
|
public IStaticServiceForGlue(ServiceCtx context, TimePermissions permissions) : base(context.Device.System.TimeServer)
|
2019-10-08 05:48:49 +02:00
|
|
|
|
{
|
|
|
|
|
_permissions = permissions;
|
|
|
|
|
_inner = new IStaticServiceForPsc(context, permissions);
|
2020-12-02 00:23:43 +01:00
|
|
|
|
_inner.TrySetServer(Server);
|
|
|
|
|
_inner.SetParent(this);
|
2019-10-08 05:48:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(0)]
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetStandardUserSystemClock() -> object<nn::timesrv::detail::service::ISystemClock>
|
|
|
|
|
public ResultCode GetStandardUserSystemClock(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.GetStandardUserSystemClock(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(1)]
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetStandardNetworkSystemClock() -> object<nn::timesrv::detail::service::ISystemClock>
|
|
|
|
|
public ResultCode GetStandardNetworkSystemClock(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.GetStandardNetworkSystemClock(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(2)]
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetStandardSteadyClock() -> object<nn::timesrv::detail::service::ISteadyClock>
|
|
|
|
|
public ResultCode GetStandardSteadyClock(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.GetStandardSteadyClock(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(3)]
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetTimeZoneService() -> object<nn::timesrv::detail::service::ITimeZoneService>
|
|
|
|
|
public ResultCode GetTimeZoneService(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
MakeObject(context, new ITimeZoneServiceForGlue(TimeManager.Instance.TimeZone, (_permissions & TimePermissions.TimeZoneWritableMask) != 0));
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(4)]
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetStandardLocalSystemClock() -> object<nn::timesrv::detail::service::ISystemClock>
|
|
|
|
|
public ResultCode GetStandardLocalSystemClock(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.GetStandardLocalSystemClock(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(5)] // 4.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetEphemeralNetworkSystemClock() -> object<nn::timesrv::detail::service::ISystemClock>
|
|
|
|
|
public ResultCode GetEphemeralNetworkSystemClock(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.GetEphemeralNetworkSystemClock(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(20)] // 6.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetSharedMemoryNativeHandle() -> handle<copy>
|
|
|
|
|
public ResultCode GetSharedMemoryNativeHandle(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.GetSharedMemoryNativeHandle(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(50)] // 4.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// SetStandardSteadyClockInternalOffset(nn::TimeSpanType internal_offset)
|
|
|
|
|
public ResultCode SetStandardSteadyClockInternalOffset(ServiceCtx context)
|
|
|
|
|
{
|
2021-03-04 11:58:21 +01:00
|
|
|
|
if ((_permissions & TimePermissions.SteadyClockWritableMask) == 0)
|
2019-10-08 05:48:49 +02:00
|
|
|
|
{
|
|
|
|
|
return ResultCode.PermissionDenied;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimeSpanType internalOffset = context.RequestData.ReadStruct<TimeSpanType>();
|
|
|
|
|
|
|
|
|
|
// TODO: set:sys SetExternalSteadyClockInternalOffset(internalOffset.ToSeconds())
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(51)] // 9.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(100)]
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// IsStandardUserSystemClockAutomaticCorrectionEnabled() -> bool
|
|
|
|
|
public ResultCode IsStandardUserSystemClockAutomaticCorrectionEnabled(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.IsStandardUserSystemClockAutomaticCorrectionEnabled(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(101)]
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// SetStandardUserSystemClockAutomaticCorrectionEnabled(b8)
|
|
|
|
|
public ResultCode SetStandardUserSystemClockAutomaticCorrectionEnabled(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.SetStandardUserSystemClockAutomaticCorrectionEnabled(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(102)] // 5.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetStandardUserSystemClockInitialYear() -> u32
|
|
|
|
|
public ResultCode GetStandardUserSystemClockInitialYear(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
if (!NxSettings.Settings.TryGetValue("time!standard_user_clock_initial_year", out object standardUserSystemClockInitialYear))
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("standard_user_clock_initial_year isn't defined in system settings!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context.ResponseData.Write((int)standardUserSystemClockInitialYear);
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(200)] // 3.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// IsStandardNetworkSystemClockAccuracySufficient() -> bool
|
|
|
|
|
public ResultCode IsStandardNetworkSystemClockAccuracySufficient(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.IsStandardNetworkSystemClockAccuracySufficient(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(201)] // 6.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetStandardUserSystemClockAutomaticCorrectionUpdatedTime() -> nn::time::SteadyClockTimePoint
|
|
|
|
|
public ResultCode GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(300)] // 4.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// CalculateMonotonicSystemClockBaseTimePoint(nn::time::SystemClockContext) -> s64
|
|
|
|
|
public ResultCode CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.CalculateMonotonicSystemClockBaseTimePoint(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(400)] // 4.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetClockSnapshot(u8) -> buffer<nn::time::sf::ClockSnapshot, 0x1a>
|
|
|
|
|
public ResultCode GetClockSnapshot(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.GetClockSnapshot(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(401)] // 4.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// GetClockSnapshotFromSystemClockContext(u8, nn::time::SystemClockContext, nn::time::SystemClockContext) -> buffer<nn::time::sf::ClockSnapshot, 0x1a>
|
|
|
|
|
public ResultCode GetClockSnapshotFromSystemClockContext(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.GetClockSnapshotFromSystemClockContext(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(500)] // 4.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// CalculateStandardUserSystemClockDifferenceByUser(buffer<nn::time::sf::ClockSnapshot, 0x19>, buffer<nn::time::sf::ClockSnapshot, 0x19>) -> nn::TimeSpanType
|
|
|
|
|
public ResultCode CalculateStandardUserSystemClockDifferenceByUser(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.CalculateStandardUserSystemClockDifferenceByUser(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(501)] // 4.0.0+
|
2019-10-08 05:48:49 +02:00
|
|
|
|
// CalculateSpanBetween(buffer<nn::time::sf::ClockSnapshot, 0x19>, buffer<nn::time::sf::ClockSnapshot, 0x19>) -> nn::TimeSpanType
|
|
|
|
|
public ResultCode CalculateSpanBetween(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
return _inner.CalculateSpanBetween(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-04 11:58:21 +01:00
|
|
|
|
}
|