aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Pcv/Bpc/IRtcManager.cs
blob: f1808923fc0d206a8f99b3acb8ed80566d6c0f40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;

namespace Ryujinx.HLE.HOS.Services.Pcv.Bpc
{
    [Service("bpc:r")] //  1.0.0 - 8.1.0
    class IRtcManager : IpcService
    {
        public IRtcManager(ServiceCtx context) { }

        [CommandHipc(0)]
        // 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;
        }
    }
}