2018-06-11 00:46:42 +00:00
|
|
|
using Ryujinx.HLE.OsHle.Ipc;
|
2018-07-02 00:03:05 +00:00
|
|
|
using System;
|
2018-02-25 04:34:16 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2018-06-11 00:46:42 +00:00
|
|
|
namespace Ryujinx.HLE.OsHle.Services.Time
|
2018-02-25 04:34:16 +00:00
|
|
|
{
|
2018-04-06 04:01:52 +00:00
|
|
|
class IStaticService : IpcService
|
2018-02-25 04:34:16 +00:00
|
|
|
{
|
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
|
|
|
|
2018-03-19 18:58:46 +00:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
2018-02-25 04:34:16 +00:00
|
|
|
|
2018-07-02 00:03:05 +00:00
|
|
|
private static readonly DateTime StartupDate = DateTime.UtcNow;
|
|
|
|
|
2018-04-06 04:01:52 +00:00
|
|
|
public IStaticService()
|
2018-02-25 04:34:16 +00:00
|
|
|
{
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
|
|
|
{
|
2018-07-02 00:03:05 +00:00
|
|
|
{ 0, GetStandardUserSystemClock },
|
|
|
|
{ 1, GetStandardNetworkSystemClock },
|
|
|
|
{ 2, GetStandardSteadyClock },
|
|
|
|
{ 3, GetTimeZoneService },
|
|
|
|
{ 4, GetStandardLocalSystemClock },
|
|
|
|
{ 300, CalculateMonotonicSystemClockBaseTimePoint }
|
2018-02-25 04:34:16 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public long GetStandardUserSystemClock(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
MakeObject(Context, new ISystemClock(SystemClockType.User));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long GetStandardNetworkSystemClock(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
MakeObject(Context, new ISystemClock(SystemClockType.Network));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long GetStandardSteadyClock(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
MakeObject(Context, new ISteadyClock());
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long GetTimeZoneService(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
MakeObject(Context, new ITimeZoneService());
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long GetStandardLocalSystemClock(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
MakeObject(Context, new ISystemClock(SystemClockType.Local));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-02 00:03:05 +00:00
|
|
|
public long CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
long TimeOffset = (long)(DateTime.UtcNow - StartupDate).TotalSeconds;
|
|
|
|
long SystemClockContextEpoch = Context.RequestData.ReadInt64();
|
|
|
|
|
|
|
|
Context.ResponseData.Write(TimeOffset + SystemClockContextEpoch);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-25 04:34:16 +00:00
|
|
|
}
|
|
|
|
}
|