IRtcManager.cs 929 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. namespace Ryujinx.HLE.HOS.Services.Pcv.Bpc
  3. {
  4. [Service("bpc:r")] // 1.0.0 - 8.1.0
  5. class IRtcManager : IpcService
  6. {
  7. public IRtcManager(ServiceCtx context) { }
  8. [CommandHipc(0)]
  9. // GetRtcTime() -> u64
  10. public ResultCode GetRtcTime(ServiceCtx context)
  11. {
  12. ResultCode result = GetExternalRtcValue(out ulong rtcValue);
  13. if (result == ResultCode.Success)
  14. {
  15. context.ResponseData.Write(rtcValue);
  16. }
  17. return result;
  18. }
  19. public static ResultCode GetExternalRtcValue(out ulong rtcValue)
  20. {
  21. // TODO: emulate MAX77620/MAX77812 RTC
  22. DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
  23. rtcValue = (ulong)(DateTime.Now.ToUniversalTime() - unixEpoch).TotalSeconds;
  24. return ResultCode.Success;
  25. }
  26. }
  27. }