diff options
| -rw-r--r-- | src/core/hle/service/time/interface.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/time/time.cpp | 29 | ||||
| -rw-r--r-- | src/core/hle/service/time/time.h | 1 |
3 files changed, 31 insertions, 1 deletions
diff --git a/src/core/hle/service/time/interface.cpp b/src/core/hle/service/time/interface.cpp index 1660bbdb8..f509653a3 100644 --- a/src/core/hle/service/time/interface.cpp +++ b/src/core/hle/service/time/interface.cpp | |||
| @@ -30,7 +30,7 @@ Time::Time(std::shared_ptr<Module> module, Core::System& system, const char* nam | |||
| 30 | {400, &Time::GetClockSnapshot, "GetClockSnapshot"}, | 30 | {400, &Time::GetClockSnapshot, "GetClockSnapshot"}, |
| 31 | {401, &Time::GetClockSnapshotFromSystemClockContext, "GetClockSnapshotFromSystemClockContext"}, | 31 | {401, &Time::GetClockSnapshotFromSystemClockContext, "GetClockSnapshotFromSystemClockContext"}, |
| 32 | {500, nullptr, "CalculateStandardUserSystemClockDifferenceByUser"}, | 32 | {500, nullptr, "CalculateStandardUserSystemClockDifferenceByUser"}, |
| 33 | {501, nullptr, "CalculateSpanBetween"}, | 33 | {501, &Time::CalculateSpanBetween, "CalculateSpanBetween"}, |
| 34 | }; | 34 | }; |
| 35 | // clang-format on | 35 | // clang-format on |
| 36 | 36 | ||
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 749b7be70..ce859f18d 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp | |||
| @@ -308,6 +308,35 @@ void Module::Interface::GetClockSnapshotFromSystemClockContext(Kernel::HLEReques | |||
| 308 | ctx.WriteBuffer(&clock_snapshot, sizeof(Clock::ClockSnapshot)); | 308 | ctx.WriteBuffer(&clock_snapshot, sizeof(Clock::ClockSnapshot)); |
| 309 | } | 309 | } |
| 310 | 310 | ||
| 311 | void Module::Interface::CalculateSpanBetween(Kernel::HLERequestContext& ctx) { | ||
| 312 | LOG_DEBUG(Service_Time, "called"); | ||
| 313 | |||
| 314 | IPC::RequestParser rp{ctx}; | ||
| 315 | const auto snapshot_a = rp.PopRaw<Clock::ClockSnapshot>(); | ||
| 316 | const auto snapshot_b = rp.PopRaw<Clock::ClockSnapshot>(); | ||
| 317 | |||
| 318 | Clock::TimeSpanType time_span_type{}; | ||
| 319 | s64 span{}; | ||
| 320 | if (const ResultCode result{snapshot_a.steady_clock_time_point.GetSpanBetween( | ||
| 321 | snapshot_b.steady_clock_time_point, span)}; | ||
| 322 | result != RESULT_SUCCESS) { | ||
| 323 | if (snapshot_a.network_time && snapshot_b.network_time) { | ||
| 324 | time_span_type = | ||
| 325 | Clock::TimeSpanType::FromSeconds(snapshot_b.network_time - snapshot_a.network_time); | ||
| 326 | } else { | ||
| 327 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 328 | rb.Push(ERROR_TIME_NOT_FOUND); | ||
| 329 | return; | ||
| 330 | } | ||
| 331 | } else { | ||
| 332 | time_span_type = Clock::TimeSpanType::FromSeconds(span); | ||
| 333 | } | ||
| 334 | |||
| 335 | IPC::ResponseBuilder rb{ctx, (sizeof(s64) / 4) + 2}; | ||
| 336 | rb.Push(RESULT_SUCCESS); | ||
| 337 | rb.PushRaw(time_span_type.nanoseconds); | ||
| 338 | } | ||
| 339 | |||
| 311 | void Module::Interface::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { | 340 | void Module::Interface::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { |
| 312 | LOG_DEBUG(Service_Time, "called"); | 341 | LOG_DEBUG(Service_Time, "called"); |
| 313 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 342 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h index aadc2df60..351988468 100644 --- a/src/core/hle/service/time/time.h +++ b/src/core/hle/service/time/time.h | |||
| @@ -32,6 +32,7 @@ public: | |||
| 32 | void CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx); | 32 | void CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx); |
| 33 | void GetClockSnapshot(Kernel::HLERequestContext& ctx); | 33 | void GetClockSnapshot(Kernel::HLERequestContext& ctx); |
| 34 | void GetClockSnapshotFromSystemClockContext(Kernel::HLERequestContext& ctx); | 34 | void GetClockSnapshotFromSystemClockContext(Kernel::HLERequestContext& ctx); |
| 35 | void CalculateSpanBetween(Kernel::HLERequestContext& ctx); | ||
| 35 | void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx); | 36 | void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx); |
| 36 | 37 | ||
| 37 | private: | 38 | private: |