aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Time/Clock/StandardLocalSystemClockCore.cs
blob: 16550199b353dcaffe299b68acf7274875061769 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Ryujinx.HLE.HOS.Kernel.Threading;

namespace Ryujinx.HLE.HOS.Services.Time.Clock
{
    class StandardLocalSystemClockCore : SystemClockCore
    {
        private SteadyClockCore    _steadyClockCore;
        private SystemClockContext _context;

        private static StandardLocalSystemClockCore instance;

        public static StandardLocalSystemClockCore Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new StandardLocalSystemClockCore(SteadyClockCore.Instance);
                }

                return instance;
            }
        }

        public StandardLocalSystemClockCore(SteadyClockCore steadyClockCore)
        {
            _steadyClockCore = steadyClockCore;
            _context         = new SystemClockContext();

            _context.SteadyTimePoint.ClockSourceId = steadyClockCore.GetClockSourceId();
        }

        public override ResultCode Flush(SystemClockContext context)
        {
            // TODO: set:sys SetUserSystemClockContext

            return ResultCode.Success;
        }

        public override SteadyClockCore GetSteadyClockCore()
        {
            return _steadyClockCore;
        }

        public override ResultCode GetSystemClockContext(KThread thread, out SystemClockContext context)
        {
            context = _context;

            return ResultCode.Success;
        }

        public override ResultCode SetSystemClockContext(SystemClockContext context)
        {
            _context = context;

            return ResultCode.Success;
        }
    }
}