Refactoring commands handling (#728)
* Refactoring commands handling - Use Reflection to handle commands ID. - Add all symbols (from SwIPC so not all time accurate). - Re-sort some services commands methods. - Some cleanup. - Keep some empty constructor for consistency. * Fix order in IProfile
This commit is contained in:
parent
f723f6f39a
commit
560ccbeb2d
99 changed files with 1035 additions and 1983 deletions
|
@ -1,7 +1,6 @@
|
|||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Time
|
||||
{
|
||||
|
@ -12,39 +11,11 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
{
|
||||
private int _timeSharedMemoryNativeHandle = 0;
|
||||
|
||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
private static readonly DateTime StartupDate = DateTime.UtcNow;
|
||||
|
||||
public IStaticService(ServiceCtx context)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 0, GetStandardUserSystemClock },
|
||||
{ 1, GetStandardNetworkSystemClock },
|
||||
{ 2, GetStandardSteadyClock },
|
||||
{ 3, GetTimeZoneService },
|
||||
{ 4, GetStandardLocalSystemClock },
|
||||
//{ 5, GetEphemeralNetworkSystemClock }, // 4.0.0+
|
||||
{ 20, GetSharedMemoryNativeHandle }, // 6.0.0+
|
||||
//{ 30, GetStandardNetworkClockOperationEventReadableHandle }, // 6.0.0+
|
||||
//{ 31, GetEphemeralNetworkClockOperationEventReadableHandle }, // 6.0.0+
|
||||
//{ 50, SetStandardSteadyClockInternalOffset }, // 4.0.0+
|
||||
//{ 100, IsStandardUserSystemClockAutomaticCorrectionEnabled },
|
||||
//{ 101, SetStandardUserSystemClockAutomaticCorrectionEnabled },
|
||||
//{ 102, GetStandardUserSystemClockInitialYear }, // 5.0.0+
|
||||
//{ 200, IsStandardNetworkSystemClockAccuracySufficient }, // 3.0.0+
|
||||
//{ 201, GetStandardUserSystemClockAutomaticCorrectionUpdatedTime }, // 6.0.0+
|
||||
{ 300, CalculateMonotonicSystemClockBaseTimePoint }, // 4.0.0+
|
||||
//{ 400, GetClockSnapshot }, // 4.0.0+
|
||||
//{ 401, GetClockSnapshotFromSystemClockContext }, // 4.0.0+
|
||||
//{ 500, CalculateStandardUserSystemClockDifferenceByUser }, // 4.0.0+
|
||||
//{ 501, CalculateSpanBetween }, // 4.0.0+
|
||||
};
|
||||
}
|
||||
public IStaticService(ServiceCtx context) { }
|
||||
|
||||
[Command(0)]
|
||||
// GetStandardUserSystemClock() -> object<nn::timesrv::detail::service::ISystemClock>
|
||||
public long GetStandardUserSystemClock(ServiceCtx context)
|
||||
{
|
||||
|
@ -53,6 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// GetStandardNetworkSystemClock() -> object<nn::timesrv::detail::service::ISystemClock>
|
||||
public long GetStandardNetworkSystemClock(ServiceCtx context)
|
||||
{
|
||||
|
@ -61,6 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
// GetStandardSteadyClock() -> object<nn::timesrv::detail::service::ISteadyClock>
|
||||
public long GetStandardSteadyClock(ServiceCtx context)
|
||||
{
|
||||
|
@ -69,6 +42,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(3)]
|
||||
// GetTimeZoneService() -> object<nn::timesrv::detail::service::ITimeZoneService>
|
||||
public long GetTimeZoneService(ServiceCtx context)
|
||||
{
|
||||
|
@ -77,6 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
// GetStandardLocalSystemClock() -> object<nn::timesrv::detail::service::ISystemClock>
|
||||
public long GetStandardLocalSystemClock(ServiceCtx context)
|
||||
{
|
||||
|
@ -85,6 +60,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(20)] // 6.0.0+
|
||||
// GetSharedMemoryNativeHandle() -> handle<copy>
|
||||
public long GetSharedMemoryNativeHandle(ServiceCtx context)
|
||||
{
|
||||
|
@ -101,6 +77,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(300)] // 4.0.0+
|
||||
// CalculateMonotonicSystemClockBaseTimePoint(nn::time::SystemClockContext) -> u64
|
||||
public long CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx context)
|
||||
{
|
||||
|
|
|
@ -1,29 +1,18 @@
|
|||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Time
|
||||
{
|
||||
class ISteadyClock : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
private ulong _testOffset;
|
||||
|
||||
public ISteadyClock()
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 0, GetCurrentTimePoint },
|
||||
{ 1, GetTestOffset },
|
||||
{ 2, SetTestOffset }
|
||||
};
|
||||
|
||||
_testOffset = 0;
|
||||
}
|
||||
|
||||
[Command(0)]
|
||||
// GetCurrentTimePoint() -> nn::time::SteadyClockTimePoint
|
||||
public long GetCurrentTimePoint(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write((long)(System.Diagnostics.Process.GetCurrentProcess().StartTime - DateTime.Now).TotalSeconds);
|
||||
|
@ -36,6 +25,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// GetTestOffset() -> nn::TimeSpanType
|
||||
public long GetTestOffset(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write(_testOffset);
|
||||
|
@ -43,6 +34,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
// SetTestOffset(nn::TimeSpanType)
|
||||
public long SetTestOffset(ServiceCtx context)
|
||||
{
|
||||
_testOffset = context.RequestData.ReadUInt64();
|
||||
|
|
|
@ -1,38 +1,20 @@
|
|||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Time
|
||||
{
|
||||
class ISystemClock : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
private SystemClockType _clockType;
|
||||
|
||||
private DateTime _systemClockContextEpoch;
|
||||
|
||||
private long _systemClockTimePoint;
|
||||
|
||||
private byte[] _systemClockContextEnding;
|
||||
|
||||
private long _timeOffset;
|
||||
private DateTime _systemClockContextEpoch;
|
||||
private long _systemClockTimePoint;
|
||||
private byte[] _systemClockContextEnding;
|
||||
private long _timeOffset;
|
||||
|
||||
public ISystemClock(SystemClockType clockType)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 0, GetCurrentTime },
|
||||
{ 1, SetCurrentTime },
|
||||
{ 2, GetSystemClockContext },
|
||||
{ 3, SetSystemClockContext }
|
||||
};
|
||||
|
||||
_clockType = clockType;
|
||||
_clockType = clockType;
|
||||
_systemClockContextEpoch = System.Diagnostics.Process.GetCurrentProcess().StartTime;
|
||||
_systemClockContextEnding = new byte[0x10];
|
||||
_timeOffset = 0;
|
||||
|
@ -46,6 +28,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
_systemClockTimePoint = (long)(_systemClockContextEpoch - Epoch).TotalSeconds;
|
||||
}
|
||||
|
||||
[Command(0)]
|
||||
// GetCurrentTime() -> nn::time::PosixTime
|
||||
public long GetCurrentTime(ServiceCtx context)
|
||||
{
|
||||
DateTime currentTime = DateTime.Now;
|
||||
|
@ -61,6 +45,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// SetCurrentTime(nn::time::PosixTime)
|
||||
public long SetCurrentTime(ServiceCtx context)
|
||||
{
|
||||
DateTime currentTime = DateTime.Now;
|
||||
|
@ -76,6 +62,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
// GetSystemClockContext() -> nn::time::SystemClockContext
|
||||
public long GetSystemClockContext(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write((long)(_systemClockContextEpoch - Epoch).TotalSeconds);
|
||||
|
@ -92,6 +80,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(3)]
|
||||
// SetSystemClockContext(nn::time::SystemClockContext)
|
||||
public long SetSystemClockContext(ServiceCtx context)
|
||||
{
|
||||
long newSystemClockEpoch = context.RequestData.ReadInt64();
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
using ChocolArm64.Memory;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Services.Time.TimeZone;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using static Ryujinx.HLE.HOS.ErrorCode;
|
||||
|
@ -13,28 +11,9 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
{
|
||||
class ITimeZoneService : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
public ITimeZoneService()
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 0, GetDeviceLocationName },
|
||||
{ 1, SetDeviceLocationName },
|
||||
{ 2, GetTotalLocationNameCount },
|
||||
{ 3, LoadLocationNameList },
|
||||
{ 4, LoadTimeZoneRule },
|
||||
//{ 5, GetTimeZoneRuleVersion }, // 2.0.0+
|
||||
//{ 6, GetDeviceLocationNameAndUpdatedTime }, // 5.0.0+
|
||||
{ 100, ToCalendarTime },
|
||||
{ 101, ToCalendarTimeWithMyRule },
|
||||
{ 201, ToPosixTime },
|
||||
{ 202, ToPosixTimeWithMyRule }
|
||||
};
|
||||
}
|
||||
public ITimeZoneService() { }
|
||||
|
||||
[Command(0)]
|
||||
// GetDeviceLocationName() -> nn::time::LocationName
|
||||
public long GetDeviceLocationName(ServiceCtx context)
|
||||
{
|
||||
|
@ -57,6 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// SetDeviceLocationName(nn::time::LocationName)
|
||||
public long SetDeviceLocationName(ServiceCtx context)
|
||||
{
|
||||
|
@ -65,6 +45,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return TimeZoneManager.Instance.SetDeviceLocationName(locationName);
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
// GetTotalLocationNameCount() -> u32
|
||||
public long GetTotalLocationNameCount(ServiceCtx context)
|
||||
{
|
||||
|
@ -73,6 +54,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(3)]
|
||||
// LoadLocationNameList(u32 index) -> (u32 outCount, buffer<nn::time::LocationName, 6>)
|
||||
public long LoadLocationNameList(ServiceCtx context)
|
||||
{
|
||||
|
@ -108,6 +90,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return errorCode;
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
// LoadTimeZoneRule(nn::time::LocationName locationName) -> buffer<nn::time::TimeZoneRule, 0x16>
|
||||
public long LoadTimeZoneRule(ServiceCtx context)
|
||||
{
|
||||
|
@ -136,6 +119,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return resultCode;
|
||||
}
|
||||
|
||||
[Command(100)]
|
||||
// ToCalendarTime(nn::time::PosixTime time, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (nn::time::CalendarTime, nn::time::sf::CalendarAdditionalInfo)
|
||||
public long ToCalendarTime(ServiceCtx context)
|
||||
{
|
||||
|
@ -163,6 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return resultCode;
|
||||
}
|
||||
|
||||
[Command(101)]
|
||||
// ToCalendarTimeWithMyRule(nn::time::PosixTime) -> (nn::time::CalendarTime, nn::time::sf::CalendarAdditionalInfo)
|
||||
public long ToCalendarTimeWithMyRule(ServiceCtx context)
|
||||
{
|
||||
|
@ -178,6 +163,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return resultCode;
|
||||
}
|
||||
|
||||
[Command(201)]
|
||||
// ToPosixTime(nn::time::CalendarTime calendarTime, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (u32 outCount, buffer<nn::time::PosixTime, 0xa>)
|
||||
public long ToPosixTime(ServiceCtx context)
|
||||
{
|
||||
|
@ -210,6 +196,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return resultCode;
|
||||
}
|
||||
|
||||
[Command(202)]
|
||||
// ToPosixTimeWithMyRule(nn::time::CalendarTime calendarTime) -> (u32 outCount, buffer<nn::time::PosixTime, 0xa>)
|
||||
public long ToPosixTimeWithMyRule(ServiceCtx context)
|
||||
{
|
||||
|
@ -231,4 +218,4 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
return resultCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue