From d17389d83df87605f50b0d7f9826b9073c2304cf Mon Sep 17 00:00:00 2001 From: Thog Date: Sun, 14 Jul 2019 19:25:56 +0200 Subject: [PATCH] Address comments --- .../HOS/Services/Time/Clock/ClockTypes.cs | 7 ++----- .../HOS/Services/Time/Clock/SteadyClockCore.cs | 1 + Ryujinx.HLE/HOS/Services/Time/IStaticService.cs | 13 ------------- Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs | 1 - Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs | 9 +++------ .../HOS/Services/Time/TimePermissions.cs | 17 +++++++++++++++++ 6 files changed, 23 insertions(+), 25 deletions(-) create mode 100644 Ryujinx.HLE/HOS/Services/Time/TimePermissions.cs diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/ClockTypes.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/ClockTypes.cs index c14fc92612..718d5be715 100644 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/ClockTypes.cs +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/ClockTypes.cs @@ -23,14 +23,13 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { return new TimeSpanType(ticks * 1000000000 / frequency); } - } [StructLayout(LayoutKind.Sequential)] public struct SteadyClockTimePoint { - public ulong TimePoint; - public UInt128 ClockSourceId; + public ulong TimePoint; + public UInt128 ClockSourceId; } [StructLayout(LayoutKind.Sequential)] @@ -39,6 +38,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock public ulong Offset; public SteadyClockTimePoint SteadyTimePoint; } - - } diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs index 15e96508cf..b69b7d3cbf 100644 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs @@ -43,6 +43,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.ThreadState.CntpctEl0, thread.Context.ThreadState.CntfrqEl0); result.TimePoint = _internalOffset.ToSeconds() + ticksTimeSpan.ToSeconds(); + return result; } diff --git a/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs b/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs index f188a6c1e9..10c659c5cc 100644 --- a/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs +++ b/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs @@ -5,19 +5,6 @@ using System; namespace Ryujinx.HLE.HOS.Services.Time { - [Flags] - enum TimePermissions - { - LocalSystemClockWritableMask = 0x1, - UserSystemClockWritableMask = 0x2, - NetworkSystemClockWritableMask = 0x4, - UnknwonPermissionMask = 0x8, - - User = 0, - Applet = LocalSystemClockWritableMask | UserSystemClockWritableMask | UnknwonPermissionMask, - System = NetworkSystemClockWritableMask - } - [Service("time:a", TimePermissions.Applet)] [Service("time:s", TimePermissions.System)] [Service("time:u", TimePermissions.User)] diff --git a/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs b/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs index e96954de35..d9f05f29cc 100644 --- a/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs +++ b/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs @@ -5,7 +5,6 @@ namespace Ryujinx.HLE.HOS.Services.Time { class ISteadyClock : IpcService { - [Command(0)] // GetCurrentTimePoint() -> nn::time::SteadyClockTimePoint public ResultCode GetCurrentTimePoint(ServiceCtx context) diff --git a/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs b/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs index c9a3a05c91..ddd67a4214 100644 --- a/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs +++ b/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs @@ -18,8 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Time // GetCurrentTime() -> nn::time::PosixTime public ResultCode GetCurrentTime(ServiceCtx context) { - SteadyClockCore steadyClockCore = _clockCore.GetSteadyClockCore(); - + SteadyClockCore steadyClockCore = _clockCore.GetSteadyClockCore(); SteadyClockTimePoint currentTimePoint = steadyClockCore.GetCurrentTimePoint(context.Thread); ResultCode result = _clockCore.GetSystemClockContext(context.Thread, out SystemClockContext clockContext); @@ -50,10 +49,8 @@ namespace Ryujinx.HLE.HOS.Services.Time return ResultCode.PermissionDenied; } - ulong posixTime = context.RequestData.ReadUInt64(); - - SteadyClockCore steadyClockCore = _clockCore.GetSteadyClockCore(); - + ulong posixTime = context.RequestData.ReadUInt64(); + SteadyClockCore steadyClockCore = _clockCore.GetSteadyClockCore(); SteadyClockTimePoint currentTimePoint = steadyClockCore.GetCurrentTimePoint(context.Thread); SystemClockContext clockContext = new SystemClockContext() diff --git a/Ryujinx.HLE/HOS/Services/Time/TimePermissions.cs b/Ryujinx.HLE/HOS/Services/Time/TimePermissions.cs new file mode 100644 index 0000000000..f0979de0b4 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Time/TimePermissions.cs @@ -0,0 +1,17 @@ +using System; + +namespace Ryujinx.HLE.HOS.Services.Time +{ + [Flags] + enum TimePermissions + { + LocalSystemClockWritableMask = 0x1, + UserSystemClockWritableMask = 0x2, + NetworkSystemClockWritableMask = 0x4, + UnknownPermissionMask = 0x8, + + User = 0, + Applet = LocalSystemClockWritableMask | UserSystemClockWritableMask | UnknownPermissionMask, + System = NetworkSystemClockWritableMask + } +}