diff options
| author | Ac_K <Acoustik666@gmail.com> | 2019-09-19 02:45:11 +0200 |
|---|---|---|
| committer | jduncanator <1518948+jduncanator@users.noreply.github.com> | 2019-09-19 10:45:11 +1000 |
| commit | a0720b5681852f3d786d77bd3793b0359dea321c (patch) | |
| tree | 9d8f61e540d1d1d827999902dad95e5c0c1e076e /Ryujinx.HLE/HOS/Services/Time/Clock | |
| parent | 4af3101b22e6957d6aa48a2768566d658699f4ed (diff) | |
Refactoring HOS folder structure (#771)
* Refactoring HOS folder structure
Refactoring HOS folder structure:
- Added some subfolders when needed (Following structure decided in private).
- Added some `Types` folders when needed.
- Little cleanup here and there.
- Add services placeholders for every HOS services (close #766 and #753).
* Remove Types namespaces
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Time/Clock')
8 files changed, 121 insertions, 109 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/ClockTypes.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/ClockTypes.cs deleted file mode 100644 index c70819c0..00000000 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/ClockTypes.cs +++ /dev/null @@ -1,105 +0,0 @@ -using Ryujinx.HLE.Utilities; -using System; -using System.Runtime.InteropServices; - -namespace Ryujinx.HLE.HOS.Services.Time.Clock -{ - [StructLayout(LayoutKind.Sequential)] - struct TimeSpanType - { - private const long NanoSecondsPerSecond = 1000000000; - - public long NanoSeconds; - - public TimeSpanType(long nanoSeconds) - { - NanoSeconds = nanoSeconds; - } - - public long ToSeconds() - { - return NanoSeconds / NanoSecondsPerSecond; - } - - public static TimeSpanType FromSeconds(long seconds) - { - return new TimeSpanType(seconds * NanoSecondsPerSecond); - } - - public static TimeSpanType FromTicks(ulong ticks, ulong frequency) - { - return FromSeconds((long)ticks / (long)frequency); - } - } - - [StructLayout(LayoutKind.Sequential)] - struct SteadyClockTimePoint - { - public long TimePoint; - public UInt128 ClockSourceId; - - public ResultCode GetSpanBetween(SteadyClockTimePoint other, out long outSpan) - { - outSpan = 0; - - if (ClockSourceId == other.ClockSourceId) - { - try - { - outSpan = checked(other.TimePoint - TimePoint); - - return ResultCode.Success; - } - catch (OverflowException) - { - return ResultCode.Overflow; - } - } - - return ResultCode.Overflow; - } - } - - [StructLayout(LayoutKind.Sequential)] - struct SystemClockContext - { - public long Offset; - public SteadyClockTimePoint SteadyTimePoint; - } - - [StructLayout(LayoutKind.Sequential, Size = 0xD0)] - struct ClockSnapshot - { - public SystemClockContext UserContext; - public SystemClockContext NetworkContext; - public long UserTime; - public long NetworkTime; - public CalendarTime UserCalendarTime; - public CalendarTime NetworkCalendarTime; - public CalendarAdditionalInfo UserCalendarAdditionalTime; - public CalendarAdditionalInfo NetworkCalendarAdditionalTime; - public SteadyClockTimePoint SteadyClockTimePoint; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x24)] - public char[] LocationName; - - [MarshalAs(UnmanagedType.I1)] - public bool IsAutomaticCorrectionEnabled; - public byte Type; - public ushort Unknown; - - public static ResultCode GetCurrentTime(out long currentTime, SteadyClockTimePoint steadyClockTimePoint, SystemClockContext context) - { - currentTime = 0; - - if (steadyClockTimePoint.ClockSourceId == context.SteadyTimePoint.ClockSourceId) - { - currentTime = steadyClockTimePoint.TimePoint + context.Offset; - - return ResultCode.Success; - } - - return ResultCode.TimeMismatch; - } - } -} diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs index 5037fb60..cc21dd9a 100644 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs @@ -4,7 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { class StandardNetworkSystemClockCore : SystemClockCore { - private TimeSpanType _standardNetworkClockSufficientAccuracy; + private TimeSpanType _standardNetworkClockSufficientAccuracy; private static StandardNetworkSystemClockCore _instance; diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs index 5b2d6c84..1bc5bee7 100644 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs @@ -1,5 +1,5 @@ using Ryujinx.HLE.HOS.Kernel.Threading; -using Ryujinx.HLE.HOS.Services.Bpc; +using Ryujinx.HLE.HOS.Services.Pcv.Bpc; namespace Ryujinx.HLE.HOS.Services.Time.Clock { diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs index 6cd4c80b..e5baba25 100644 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs @@ -1,5 +1,4 @@ -using Ryujinx.Common; -using Ryujinx.HLE.HOS.Kernel.Threading; +using Ryujinx.HLE.HOS.Kernel.Threading; namespace Ryujinx.HLE.HOS.Services.Time.Clock { diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs new file mode 100644 index 00000000..df1f151f --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs @@ -0,0 +1,41 @@ +using Ryujinx.HLE.HOS.Services.Time.TimeZone; +using System.Runtime.InteropServices; + +namespace Ryujinx.HLE.HOS.Services.Time.Clock +{ + [StructLayout(LayoutKind.Sequential, Size = 0xD0)] + struct ClockSnapshot + { + public SystemClockContext UserContext; + public SystemClockContext NetworkContext; + public long UserTime; + public long NetworkTime; + public CalendarTime UserCalendarTime; + public CalendarTime NetworkCalendarTime; + public CalendarAdditionalInfo UserCalendarAdditionalTime; + public CalendarAdditionalInfo NetworkCalendarAdditionalTime; + public SteadyClockTimePoint SteadyClockTimePoint; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x24)] + public char[] LocationName; + + [MarshalAs(UnmanagedType.I1)] + public bool IsAutomaticCorrectionEnabled; + public byte Type; + public ushort Unknown; + + public static ResultCode GetCurrentTime(out long currentTime, SteadyClockTimePoint steadyClockTimePoint, SystemClockContext context) + { + currentTime = 0; + + if (steadyClockTimePoint.ClockSourceId == context.SteadyTimePoint.ClockSourceId) + { + currentTime = steadyClockTimePoint.TimePoint + context.Offset; + + return ResultCode.Success; + } + + return ResultCode.TimeMismatch; + } + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs new file mode 100644 index 00000000..0055b5ea --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs @@ -0,0 +1,34 @@ +using Ryujinx.HLE.Utilities; +using System; +using System.Runtime.InteropServices; + +namespace Ryujinx.HLE.HOS.Services.Time.Clock +{ + [StructLayout(LayoutKind.Sequential)] + struct SteadyClockTimePoint + { + public long TimePoint; + public UInt128 ClockSourceId; + + public ResultCode GetSpanBetween(SteadyClockTimePoint other, out long outSpan) + { + outSpan = 0; + + if (ClockSourceId == other.ClockSourceId) + { + try + { + outSpan = checked(other.TimePoint - TimePoint); + + return ResultCode.Success; + } + catch (OverflowException) + { + return ResultCode.Overflow; + } + } + + return ResultCode.Overflow; + } + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs new file mode 100644 index 00000000..38e10480 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace Ryujinx.HLE.HOS.Services.Time.Clock +{ + [StructLayout(LayoutKind.Sequential)] + struct SystemClockContext + { + public long Offset; + public SteadyClockTimePoint SteadyTimePoint; + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs new file mode 100644 index 00000000..93579709 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs @@ -0,0 +1,32 @@ +using System.Runtime.InteropServices; + +namespace Ryujinx.HLE.HOS.Services.Time.Clock +{ + [StructLayout(LayoutKind.Sequential)] + struct TimeSpanType + { + private const long NanoSecondsPerSecond = 1000000000; + + public long NanoSeconds; + + public TimeSpanType(long nanoSeconds) + { + NanoSeconds = nanoSeconds; + } + + public long ToSeconds() + { + return NanoSeconds / NanoSecondsPerSecond; + } + + public static TimeSpanType FromSeconds(long seconds) + { + return new TimeSpanType(seconds * NanoSecondsPerSecond); + } + + public static TimeSpanType FromTicks(ulong ticks, ulong frequency) + { + return FromSeconds((long)ticks / (long)frequency); + } + } +}
\ No newline at end of file |
