2019-07-15 10:52:35 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
2019-09-18 17:45:11 -07:00
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Pcv.Bpc
|
2019-07-15 10:52:35 -07:00
|
|
|
|
{
|
2019-09-18 17:45:11 -07:00
|
|
|
|
[Service("bpc:r")] // 1.0.0 - 8.1.0
|
2019-07-15 10:52:35 -07:00
|
|
|
|
class IRtcManager : IpcService
|
|
|
|
|
{
|
|
|
|
|
public IRtcManager(ServiceCtx context) { }
|
|
|
|
|
|
2021-04-13 15:01:24 -07:00
|
|
|
|
[CommandHipc(0)]
|
2019-07-15 10:52:35 -07:00
|
|
|
|
// GetRtcTime() -> u64
|
|
|
|
|
public ResultCode GetRtcTime(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
ResultCode result = GetExternalRtcValue(out ulong rtcValue);
|
|
|
|
|
|
|
|
|
|
if (result == ResultCode.Success)
|
|
|
|
|
{
|
|
|
|
|
context.ResponseData.Write(rtcValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ResultCode GetExternalRtcValue(out ulong rtcValue)
|
|
|
|
|
{
|
|
|
|
|
// TODO: emulate MAX77620/MAX77812 RTC
|
|
|
|
|
DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
|
|
|
|
|
|
|
|
|
rtcValue = (ulong)(DateTime.Now.ToUniversalTime() - unixEpoch).TotalSeconds;
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|