blob: 97d7884ea67e3e917fc66aea530cc5addadc6e57 (
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
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
using Ryujinx.Common;
using Ryujinx.Cpu;
using Ryujinx.HLE.HOS.Services.Time.Clock;
namespace Ryujinx.HLE.HOS.Services.Time.StaticService
{
class ISteadyClock : IpcService
{
private SteadyClockCore _steadyClock;
private bool _writePermission;
private bool _bypassUninitializedClock;
public ISteadyClock(SteadyClockCore steadyClock, bool writePermission, bool bypassUninitializedClock)
{
_steadyClock = steadyClock;
_writePermission = writePermission;
_bypassUninitializedClock = bypassUninitializedClock;
}
[CommandCmif(0)]
// GetCurrentTimePoint() -> nn::time::SteadyClockTimePoint
public ResultCode GetCurrentTimePoint(ServiceCtx context)
{
if (!_bypassUninitializedClock && !_steadyClock.IsInitialized())
{
return ResultCode.UninitializedClock;
}
ITickSource tickSource = context.Device.System.TickSource;
SteadyClockTimePoint currentTimePoint = _steadyClock.GetCurrentTimePoint(tickSource);
context.ResponseData.WriteStruct(currentTimePoint);
return ResultCode.Success;
}
[CommandCmif(2)]
// GetTestOffset() -> nn::TimeSpanType
public ResultCode GetTestOffset(ServiceCtx context)
{
if (!_bypassUninitializedClock && !_steadyClock.IsInitialized())
{
return ResultCode.UninitializedClock;
}
context.ResponseData.WriteStruct(_steadyClock.GetTestOffset());
return ResultCode.Success;
}
[CommandCmif(3)]
// SetTestOffset(nn::TimeSpanType)
public ResultCode SetTestOffset(ServiceCtx context)
{
if (!_writePermission)
{
return ResultCode.PermissionDenied;
}
if (!_bypassUninitializedClock && !_steadyClock.IsInitialized())
{
return ResultCode.UninitializedClock;
}
TimeSpanType testOffset = context.RequestData.ReadStruct<TimeSpanType>();
_steadyClock.SetTestOffset(testOffset);
return ResultCode.Success;
}
[CommandCmif(100)] // 2.0.0+
// GetRtcValue() -> u64
public ResultCode GetRtcValue(ServiceCtx context)
{
if (!_bypassUninitializedClock && !_steadyClock.IsInitialized())
{
return ResultCode.UninitializedClock;
}
ResultCode result = _steadyClock.GetRtcValue(out ulong rtcValue);
if (result == ResultCode.Success)
{
context.ResponseData.Write(rtcValue);
}
return result;
}
[CommandCmif(101)] // 2.0.0+
// IsRtcResetDetected() -> bool
public ResultCode IsRtcResetDetected(ServiceCtx context)
{
if (!_bypassUninitializedClock && !_steadyClock.IsInitialized())
{
return ResultCode.UninitializedClock;
}
context.ResponseData.Write(_steadyClock.IsRtcResetDetected());
return ResultCode.Success;
}
[CommandCmif(102)] // 2.0.0+
// GetSetupResultValue() -> u32
public ResultCode GetSetupResultValue(ServiceCtx context)
{
if (!_bypassUninitializedClock && !_steadyClock.IsInitialized())
{
return ResultCode.UninitializedClock;
}
context.ResponseData.Write((uint)_steadyClock.GetSetupResultValue());
return ResultCode.Success;
}
[CommandCmif(200)] // 3.0.0+
// GetInternalOffset() -> nn::TimeSpanType
public ResultCode GetInternalOffset(ServiceCtx context)
{
if (!_bypassUninitializedClock && !_steadyClock.IsInitialized())
{
return ResultCode.UninitializedClock;
}
context.ResponseData.WriteStruct(_steadyClock.GetInternalOffset());
return ResultCode.Success;
}
[CommandCmif(201)] // 3.0.0-3.0.2
// SetInternalOffset(nn::TimeSpanType)
public ResultCode SetInternalOffset(ServiceCtx context)
{
if (!_writePermission)
{
return ResultCode.PermissionDenied;
}
if (!_bypassUninitializedClock && !_steadyClock.IsInitialized())
{
return ResultCode.UninitializedClock;
}
TimeSpanType internalOffset = context.RequestData.ReadStruct<TimeSpanType>();
_steadyClock.SetInternalOffset(internalOffset);
return ResultCode.Success;
}
}
}
|