aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs
blob: 6cd4c80b47e605fc6d718ad7b1275dc926594216 (plain)
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
35
36
37
38
39
40
using Ryujinx.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;

namespace Ryujinx.HLE.HOS.Services.Time.Clock
{
    class TickBasedSteadyClockCore : SteadyClockCore
    {
        private static TickBasedSteadyClockCore _instance;

        public static TickBasedSteadyClockCore Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new TickBasedSteadyClockCore();
                }

                return _instance;
            }
        }

        private TickBasedSteadyClockCore() {}

        public override SteadyClockTimePoint GetTimePoint(KThread thread)
        {
            SteadyClockTimePoint result = new SteadyClockTimePoint
            {
                TimePoint     = 0,
                ClockSourceId = GetClockSourceId()
            };

            TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.CntpctEl0, thread.Context.CntfrqEl0);

            result.TimePoint = ticksTimeSpan.ToSeconds();

            return result;
        }
    }
}