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
This commit is contained in:
parent
4af3101b22
commit
a0720b5681
393 changed files with 2540 additions and 1299 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
|||
{
|
||||
class StandardNetworkSystemClockCore : SystemClockCore
|
||||
{
|
||||
private TimeSpanType _standardNetworkClockSufficientAccuracy;
|
||||
private TimeSpanType _standardNetworkClockSufficientAccuracy;
|
||||
|
||||
private static StandardNetworkSystemClockCore _instance;
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
41
Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs
Normal file
41
Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
32
Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs
Normal file
32
Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue