summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/time/time.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index e722886de..67f1bbcf3 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -20,8 +20,8 @@ namespace Service::Time {
20 20
21class ISystemClock final : public ServiceFramework<ISystemClock> { 21class ISystemClock final : public ServiceFramework<ISystemClock> {
22public: 22public:
23 ISystemClock(Clock::SystemClockCore& clock_core) 23 explicit ISystemClock(Clock::SystemClockCore& clock_core, Core::System& system)
24 : ServiceFramework("ISystemClock"), clock_core{clock_core} { 24 : ServiceFramework("ISystemClock"), clock_core{clock_core}, system{system} {
25 // clang-format off 25 // clang-format off
26 static const FunctionInfo functions[] = { 26 static const FunctionInfo functions[] = {
27 {0, &ISystemClock::GetCurrentTime, "GetCurrentTime"}, 27 {0, &ISystemClock::GetCurrentTime, "GetCurrentTime"},
@@ -46,9 +46,8 @@ private:
46 } 46 }
47 47
48 s64 posix_time{}; 48 s64 posix_time{};
49 if (const ResultCode result{ 49 if (const ResultCode result{clock_core.GetCurrentTime(system, posix_time)};
50 clock_core.GetCurrentTime(Core::System::GetInstance(), posix_time)}; 50 result.IsError()) {
51 result != RESULT_SUCCESS) {
52 IPC::ResponseBuilder rb{ctx, 2}; 51 IPC::ResponseBuilder rb{ctx, 2};
53 rb.Push(result); 52 rb.Push(result);
54 return; 53 return;
@@ -69,9 +68,8 @@ private:
69 } 68 }
70 69
71 Clock::SystemClockContext system_clock_context{}; 70 Clock::SystemClockContext system_clock_context{};
72 if (const ResultCode result{ 71 if (const ResultCode result{clock_core.GetClockContext(system, system_clock_context)};
73 clock_core.GetClockContext(Core::System::GetInstance(), system_clock_context)}; 72 result.IsError()) {
74 result != RESULT_SUCCESS) {
75 IPC::ResponseBuilder rb{ctx, 2}; 73 IPC::ResponseBuilder rb{ctx, 2};
76 rb.Push(result); 74 rb.Push(result);
77 return; 75 return;
@@ -83,12 +81,13 @@ private:
83 } 81 }
84 82
85 Clock::SystemClockCore& clock_core; 83 Clock::SystemClockCore& clock_core;
84 Core::System& system;
86}; 85};
87 86
88class ISteadyClock final : public ServiceFramework<ISteadyClock> { 87class ISteadyClock final : public ServiceFramework<ISteadyClock> {
89public: 88public:
90 ISteadyClock(Clock::SteadyClockCore& clock_core) 89 explicit ISteadyClock(Clock::SteadyClockCore& clock_core, Core::System& system)
91 : ServiceFramework("ISteadyClock"), clock_core{clock_core} { 90 : ServiceFramework("ISteadyClock"), clock_core{clock_core}, system{system} {
92 static const FunctionInfo functions[] = { 91 static const FunctionInfo functions[] = {
93 {0, &ISteadyClock::GetCurrentTimePoint, "GetCurrentTimePoint"}, 92 {0, &ISteadyClock::GetCurrentTimePoint, "GetCurrentTimePoint"},
94 }; 93 };
@@ -105,14 +104,14 @@ private:
105 return; 104 return;
106 } 105 }
107 106
108 const Clock::SteadyClockTimePoint time_point{ 107 const Clock::SteadyClockTimePoint time_point{clock_core.GetCurrentTimePoint(system)};
109 clock_core.GetCurrentTimePoint(Core::System::GetInstance())};
110 IPC::ResponseBuilder rb{ctx, (sizeof(Clock::SteadyClockTimePoint) / 4) + 2}; 108 IPC::ResponseBuilder rb{ctx, (sizeof(Clock::SteadyClockTimePoint) / 4) + 2};
111 rb.Push(RESULT_SUCCESS); 109 rb.Push(RESULT_SUCCESS);
112 rb.PushRaw(time_point); 110 rb.PushRaw(time_point);
113 } 111 }
114 112
115 Clock::SteadyClockCore& clock_core; 113 Clock::SteadyClockCore& clock_core;
114 Core::System& system;
116}; 115};
117 116
118ResultCode Module::Interface::GetClockSnapshotFromSystemClockContextInternal( 117ResultCode Module::Interface::GetClockSnapshotFromSystemClockContextInternal(
@@ -134,7 +133,7 @@ ResultCode Module::Interface::GetClockSnapshotFromSystemClockContextInternal(
134 } 133 }
135 134
136 const auto current_time_point{ 135 const auto current_time_point{
137 time_manager.GetStandardSteadyClockCore().GetCurrentTimePoint(Core::System::GetInstance())}; 136 time_manager.GetStandardSteadyClockCore().GetCurrentTimePoint(system)};
138 if (const ResultCode result{Clock::ClockSnapshot::GetCurrentTime( 137 if (const ResultCode result{Clock::ClockSnapshot::GetCurrentTime(
139 clock_snapshot.user_time, current_time_point, clock_snapshot.user_context)}; 138 clock_snapshot.user_time, current_time_point, clock_snapshot.user_context)};
140 result != RESULT_SUCCESS) { 139 result != RESULT_SUCCESS) {
@@ -176,21 +175,24 @@ void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ct
176 LOG_DEBUG(Service_Time, "called"); 175 LOG_DEBUG(Service_Time, "called");
177 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 176 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
178 rb.Push(RESULT_SUCCESS); 177 rb.Push(RESULT_SUCCESS);
179 rb.PushIpcInterface<ISystemClock>(module->GetTimeManager().GetStandardUserSystemClockCore()); 178 rb.PushIpcInterface<ISystemClock>(module->GetTimeManager().GetStandardUserSystemClockCore(),
179 system);
180} 180}
181 181
182void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) { 182void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
183 LOG_DEBUG(Service_Time, "called"); 183 LOG_DEBUG(Service_Time, "called");
184 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 184 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
185 rb.Push(RESULT_SUCCESS); 185 rb.Push(RESULT_SUCCESS);
186 rb.PushIpcInterface<ISystemClock>(module->GetTimeManager().GetStandardNetworkSystemClockCore()); 186 rb.PushIpcInterface<ISystemClock>(module->GetTimeManager().GetStandardNetworkSystemClockCore(),
187 system);
187} 188}
188 189
189void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { 190void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
190 LOG_DEBUG(Service_Time, "called"); 191 LOG_DEBUG(Service_Time, "called");
191 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 192 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
192 rb.Push(RESULT_SUCCESS); 193 rb.Push(RESULT_SUCCESS);
193 rb.PushIpcInterface<ISteadyClock>(module->GetTimeManager().GetStandardSteadyClockCore()); 194 rb.PushIpcInterface<ISteadyClock>(module->GetTimeManager().GetStandardSteadyClockCore(),
195 system);
194} 196}
195 197
196void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { 198void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
@@ -204,7 +206,8 @@ void Module::Interface::GetStandardLocalSystemClock(Kernel::HLERequestContext& c
204 LOG_DEBUG(Service_Time, "called"); 206 LOG_DEBUG(Service_Time, "called");
205 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 207 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
206 rb.Push(RESULT_SUCCESS); 208 rb.Push(RESULT_SUCCESS);
207 rb.PushIpcInterface<ISystemClock>(module->GetTimeManager().GetStandardLocalSystemClockCore()); 209 rb.PushIpcInterface<ISystemClock>(module->GetTimeManager().GetStandardLocalSystemClockCore(),
210 system);
208} 211}
209 212
210void Module::Interface::IsStandardNetworkSystemClockAccuracySufficient( 213void Module::Interface::IsStandardNetworkSystemClockAccuracySufficient(
@@ -228,8 +231,7 @@ void Module::Interface::CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERe
228 231
229 IPC::RequestParser rp{ctx}; 232 IPC::RequestParser rp{ctx};
230 const auto context{rp.PopRaw<Clock::SystemClockContext>()}; 233 const auto context{rp.PopRaw<Clock::SystemClockContext>()};
231 const auto current_time_point{ 234 const auto current_time_point{steady_clock_core.GetCurrentTimePoint(system)};
232 steady_clock_core.GetCurrentTimePoint(Core::System::GetInstance())};
233 235
234 if (current_time_point.clock_source_id == context.steady_time_point.clock_source_id) { 236 if (current_time_point.clock_source_id == context.steady_time_point.clock_source_id) {
235 const auto ticks{Clock::TimeSpanType::FromTicks( 237 const auto ticks{Clock::TimeSpanType::FromTicks(
@@ -255,8 +257,8 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
255 Clock::SystemClockContext user_context{}; 257 Clock::SystemClockContext user_context{};
256 if (const ResultCode result{ 258 if (const ResultCode result{
257 module->GetTimeManager().GetStandardUserSystemClockCore().GetClockContext( 259 module->GetTimeManager().GetStandardUserSystemClockCore().GetClockContext(
258 Core::System::GetInstance(), user_context)}; 260 system, user_context)};
259 result != RESULT_SUCCESS) { 261 result.IsError()) {
260 IPC::ResponseBuilder rb{ctx, 2}; 262 IPC::ResponseBuilder rb{ctx, 2};
261 rb.Push(result); 263 rb.Push(result);
262 return; 264 return;
@@ -264,8 +266,8 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
264 Clock::SystemClockContext network_context{}; 266 Clock::SystemClockContext network_context{};
265 if (const ResultCode result{ 267 if (const ResultCode result{
266 module->GetTimeManager().GetStandardNetworkSystemClockCore().GetClockContext( 268 module->GetTimeManager().GetStandardNetworkSystemClockCore().GetClockContext(
267 Core::System::GetInstance(), network_context)}; 269 system, network_context)};
268 result != RESULT_SUCCESS) { 270 result.IsError()) {
269 IPC::ResponseBuilder rb{ctx, 2}; 271 IPC::ResponseBuilder rb{ctx, 2};
270 rb.Push(result); 272 rb.Push(result);
271 return; 273 return;
@@ -274,7 +276,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
274 Clock::ClockSnapshot clock_snapshot{}; 276 Clock::ClockSnapshot clock_snapshot{};
275 if (const ResultCode result{GetClockSnapshotFromSystemClockContextInternal( 277 if (const ResultCode result{GetClockSnapshotFromSystemClockContextInternal(
276 &ctx.GetThread(), user_context, network_context, type, clock_snapshot)}; 278 &ctx.GetThread(), user_context, network_context, type, clock_snapshot)};
277 result != RESULT_SUCCESS) { 279 result.IsError()) {
278 IPC::ResponseBuilder rb{ctx, 2}; 280 IPC::ResponseBuilder rb{ctx, 2};
279 rb.Push(result); 281 rb.Push(result);
280 return; 282 return;