diff options
author | bunnei <bunneidev@gmail.com> | 2020-03-29 06:03:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-29 06:03:55 +0200 |
commit | 2c9879d2ebb9790676363a6ea165b3aa9287f39f (patch) | |
tree | 8f8a5083dd1138d1cd21e80daf74d11bb3d4c185 /src | |
parent | Merge pull request #3545 from FearlessTobi/audren-rev (diff) | |
parent | services: time: Implement CalculateSpanBetween. (diff) | |
download | yuzu-2c9879d2ebb9790676363a6ea165b3aa9287f39f.tar yuzu-2c9879d2ebb9790676363a6ea165b3aa9287f39f.tar.gz yuzu-2c9879d2ebb9790676363a6ea165b3aa9287f39f.tar.bz2 yuzu-2c9879d2ebb9790676363a6ea165b3aa9287f39f.tar.lz yuzu-2c9879d2ebb9790676363a6ea165b3aa9287f39f.tar.xz yuzu-2c9879d2ebb9790676363a6ea165b3aa9287f39f.tar.zst yuzu-2c9879d2ebb9790676363a6ea165b3aa9287f39f.zip |
Diffstat (limited to 'src')
-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 {400, &Time::GetClockSnapshot, "GetClockSnapshot"}, {401, &Time::GetClockSnapshotFromSystemClockContext, "GetClockSnapshotFromSystemClockContext"}, {500, nullptr, "CalculateStandardUserSystemClockDifferenceByUser"}, - {501, nullptr, "CalculateSpanBetween"}, + {501, &Time::CalculateSpanBetween, "CalculateSpanBetween"}, }; // clang-format on 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 ctx.WriteBuffer(&clock_snapshot, sizeof(Clock::ClockSnapshot)); } +void Module::Interface::CalculateSpanBetween(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_Time, "called"); + + IPC::RequestParser rp{ctx}; + const auto snapshot_a = rp.PopRaw<Clock::ClockSnapshot>(); + const auto snapshot_b = rp.PopRaw<Clock::ClockSnapshot>(); + + Clock::TimeSpanType time_span_type{}; + s64 span{}; + if (const ResultCode result{snapshot_a.steady_clock_time_point.GetSpanBetween( + snapshot_b.steady_clock_time_point, span)}; + result != RESULT_SUCCESS) { + if (snapshot_a.network_time && snapshot_b.network_time) { + time_span_type = + Clock::TimeSpanType::FromSeconds(snapshot_b.network_time - snapshot_a.network_time); + } else { + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ERROR_TIME_NOT_FOUND); + return; + } + } else { + time_span_type = Clock::TimeSpanType::FromSeconds(span); + } + + IPC::ResponseBuilder rb{ctx, (sizeof(s64) / 4) + 2}; + rb.Push(RESULT_SUCCESS); + rb.PushRaw(time_span_type.nanoseconds); +} + void Module::Interface::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); 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: void CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx); void GetClockSnapshot(Kernel::HLERequestContext& ctx); void GetClockSnapshotFromSystemClockContext(Kernel::HLERequestContext& ctx); + void CalculateSpanBetween(Kernel::HLERequestContext& ctx); void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx); private: |