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:
Ac_K 2019-09-19 02:45:11 +02:00 committed by jduncanator
parent 4af3101b22
commit a0720b5681
393 changed files with 2540 additions and 1299 deletions

View file

@ -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;
}
}
}

View file

@ -4,7 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
{
class StandardNetworkSystemClockCore : SystemClockCore
{
private TimeSpanType _standardNetworkClockSufficientAccuracy;
private TimeSpanType _standardNetworkClockSufficientAccuracy;
private static StandardNetworkSystemClockCore _instance;

View file

@ -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
{

View file

@ -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
{

View 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;
}
}
}

View file

@ -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;
}
}
}

View file

@ -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;
}
}

View 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);
}
}
}

View file

@ -0,0 +1,8 @@
namespace Ryujinx.HLE.HOS.Services.Time
{
[Service("time:al")] // 9.0.0+
class IAlarmService : IpcService
{
public IAlarmService(ServiceCtx context) { }
}
}

View file

@ -0,0 +1,8 @@
namespace Ryujinx.HLE.HOS.Services.Time
{
[Service("time:m")] // 9.0.0+
class IPowerStateRequestHandler : IpcService
{
public IPowerStateRequestHandler(ServiceCtx context) { }
}
}

View file

@ -3,6 +3,7 @@ using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Time.Clock;
using Ryujinx.HLE.HOS.Services.Time.StaticService;
using Ryujinx.HLE.HOS.Services.Time.TimeZone;
using System;
using System.Diagnostics;
@ -14,6 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Service("time:a", TimePermissions.Applet)]
[Service("time:s", TimePermissions.System)]
[Service("time:u", TimePermissions.User)]
[Service("time:p", TimePermissions.System)] // 9.0.0+ - TODO: Fix the permission.
class IStaticService : IpcService
{
private TimePermissions _permissions;

View file

@ -0,0 +1,8 @@
namespace Ryujinx.HLE.HOS.Services.Time
{
[Service("time:su")] // 9.0.0+
class ITimeServiceManager : IpcService
{
public ITimeServiceManager(ServiceCtx context) { }
}
}

View file

@ -1,128 +0,0 @@
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Time
{
[StructLayout(LayoutKind.Sequential, Size = 0x10, Pack = 4)]
struct TimeTypeInfo
{
public int GmtOffset;
[MarshalAs(UnmanagedType.I1)]
public bool IsDaySavingTime;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
char[] Padding1;
public int AbbreviationListIndex;
[MarshalAs(UnmanagedType.I1)]
public bool IsStandardTimeDaylight;
[MarshalAs(UnmanagedType.I1)]
public bool IsGMT;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
char[] Padding2;
}
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 0x4000, CharSet = CharSet.Ansi)]
struct TimeZoneRule
{
public const int TzMaxTypes = 128;
public const int TzMaxChars = 50;
public const int TzMaxLeaps = 50;
public const int TzMaxTimes = 1000;
public const int TzNameMax = 255;
public const int TzCharsArraySize = 2 * (TzNameMax + 1);
public int TimeCount;
public int TypeCount;
public int CharCount;
[MarshalAs(UnmanagedType.I1)]
public bool GoBack;
[MarshalAs(UnmanagedType.I1)]
public bool GoAhead;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTimes)]
public long[] Ats;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTimes)]
public byte[] Types;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTypes)]
public TimeTypeInfo[] Ttis;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzCharsArraySize)]
public char[] Chars;
public int DefaultType;
}
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x2C)]
struct TzifHeader
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public char[] Magic;
public char Version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
public byte[] Reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] TtisGMTCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] TtisSTDCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] LeapCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] TimeCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] TypeCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] CharCount;
}
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x8)]
struct CalendarTime
{
public short Year;
public sbyte Month;
public sbyte Day;
public sbyte Hour;
public sbyte Minute;
public sbyte Second;
}
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x18, CharSet = CharSet.Ansi)]
struct CalendarAdditionalInfo
{
public uint DayOfWeek;
public uint DayOfYear;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public char[] TimezoneName;
[MarshalAs(UnmanagedType.I1)]
public bool IsDaySavingTime;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
char[] Padding;
public int GmtOffset;
}
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x20, CharSet = CharSet.Ansi)]
struct CalendarInfo
{
public CalendarTime Time;
public CalendarAdditionalInfo AdditionalInfo;
}
}

View file

@ -1,7 +1,7 @@
using Ryujinx.Common;
using Ryujinx.HLE.HOS.Services.Time.Clock;
namespace Ryujinx.HLE.HOS.Services.Time
namespace Ryujinx.HLE.HOS.Services.Time.StaticService
{
class ISteadyClock : IpcService
{

View file

@ -1,7 +1,7 @@
using Ryujinx.Common;
using Ryujinx.HLE.HOS.Services.Time.Clock;
namespace Ryujinx.HLE.HOS.Services.Time
namespace Ryujinx.HLE.HOS.Services.Time.StaticService
{
class ISystemClock : IpcService
{

View file

@ -5,7 +5,7 @@ using Ryujinx.HLE.HOS.Services.Time.TimeZone;
using System;
using System.Text;
namespace Ryujinx.HLE.HOS.Services.Time
namespace Ryujinx.HLE.HOS.Services.Time.StaticService
{
class ITimeZoneService : IpcService
{

View file

@ -1,10 +1,11 @@
using System;
using Ryujinx.Common;
using Ryujinx.HLE.Utilities;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using Ryujinx.Common;
using Ryujinx.HLE.Utilities;
using static Ryujinx.HLE.HOS.Services.Time.TimeZoneRule;
using static Ryujinx.HLE.HOS.Services.Time.TimeZone.TimeZoneRule;
namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
@ -238,9 +239,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
seconds = 0;
int num;
bool isValid = GetNum(name, ref namePosition, out num, 0, HoursPerDays * DaysPerWekk - 1);
bool isValid = GetNum(name, ref namePosition, out int num, 0, HoursPerDays * DaysPerWekk - 1);
if (!isValid)
{
return false;

View file

@ -1,15 +1,15 @@
using LibHac.Fs.NcaUtils;
using LibHac.Fs;
using LibHac.Fs.NcaUtils;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.FileSystem;
using System;
using System.Collections.ObjectModel;
using LibHac.Fs;
using System.IO;
using System.Collections.Generic;
using TimeZoneConverter.Posix;
using System.Collections.ObjectModel;
using System.IO;
using TimeZoneConverter;
using TimeZoneConverter.Posix;
using static Ryujinx.HLE.HOS.Services.Time.TimeZoneRule;
using static Ryujinx.HLE.HOS.Services.Time.TimeZone.TimeZoneRule;
namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{

View file

@ -0,0 +1,22 @@
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x18, CharSet = CharSet.Ansi)]
struct CalendarAdditionalInfo
{
public uint DayOfWeek;
public uint DayOfYear;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public char[] TimezoneName;
[MarshalAs(UnmanagedType.I1)]
public bool IsDaySavingTime;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public char[] Padding;
public int GmtOffset;
}
}

View file

@ -0,0 +1,11 @@
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x20, CharSet = CharSet.Ansi)]
struct CalendarInfo
{
public CalendarTime Time;
public CalendarAdditionalInfo AdditionalInfo;
}
}

View file

@ -0,0 +1,15 @@
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x8)]
struct CalendarTime
{
public short Year;
public sbyte Month;
public sbyte Day;
public sbyte Hour;
public sbyte Minute;
public sbyte Second;
}
}

View file

@ -0,0 +1,27 @@
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
[StructLayout(LayoutKind.Sequential, Size = 0x10, Pack = 4)]
struct TimeTypeInfo
{
public int GmtOffset;
[MarshalAs(UnmanagedType.I1)]
public bool IsDaySavingTime;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public char[] Padding1;
public int AbbreviationListIndex;
[MarshalAs(UnmanagedType.I1)]
public bool IsStandardTimeDaylight;
[MarshalAs(UnmanagedType.I1)]
public bool IsGMT;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public char[] Padding2;
}
}

View file

@ -0,0 +1,39 @@
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 0x4000, CharSet = CharSet.Ansi)]
struct TimeZoneRule
{
public const int TzMaxTypes = 128;
public const int TzMaxChars = 50;
public const int TzMaxLeaps = 50;
public const int TzMaxTimes = 1000;
public const int TzNameMax = 255;
public const int TzCharsArraySize = 2 * (TzNameMax + 1);
public int TimeCount;
public int TypeCount;
public int CharCount;
[MarshalAs(UnmanagedType.I1)]
public bool GoBack;
[MarshalAs(UnmanagedType.I1)]
public bool GoAhead;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTimes)]
public long[] Ats;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTimes)]
public byte[] Types;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTypes)]
public TimeTypeInfo[] Ttis;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzCharsArraySize)]
public char[] Chars;
public int DefaultType;
}
}

View file

@ -0,0 +1,34 @@
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x2C)]
struct TzifHeader
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public char[] Magic;
public char Version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
public byte[] Reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] TtisGMTCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] TtisSTDCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] LeapCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] TimeCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] TypeCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] CharCount;
}
}