diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/time/clock_types.h | 20 | ||||
| -rw-r--r-- | src/core/hle/service/time/interface.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/time/standard_network_system_clock_core.h | 20 | ||||
| -rw-r--r-- | src/core/hle/service/time/time.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/time/time.h | 1 |
5 files changed, 51 insertions, 1 deletions
diff --git a/src/core/hle/service/time/clock_types.h b/src/core/hle/service/time/clock_types.h index f2ef3ec53..3d5b0ff1e 100644 --- a/src/core/hle/service/time/clock_types.h +++ b/src/core/hle/service/time/clock_types.h | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <boost/safe_numerics/safe_integer.hpp> | ||
| 8 | |||
| 7 | #include "common/common_funcs.h" | 9 | #include "common/common_funcs.h" |
| 8 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 9 | #include "common/uuid.h" | 11 | #include "common/uuid.h" |
| @@ -17,6 +19,24 @@ struct SteadyClockTimePoint { | |||
| 17 | s64 time_point; | 19 | s64 time_point; |
| 18 | Common::UUID clock_source_id; | 20 | Common::UUID clock_source_id; |
| 19 | 21 | ||
| 22 | ResultCode GetSpanBetween(SteadyClockTimePoint other, s64& span) const { | ||
| 23 | span = 0; | ||
| 24 | |||
| 25 | if (clock_source_id != other.clock_source_id) { | ||
| 26 | return ERROR_TIME_MISMATCH; | ||
| 27 | } | ||
| 28 | |||
| 29 | const boost::safe_numerics::safe<s64> this_time_point{time_point}; | ||
| 30 | const boost::safe_numerics::safe<s64> other_time_point{other.time_point}; | ||
| 31 | try { | ||
| 32 | span = other_time_point - this_time_point; | ||
| 33 | } catch (const std::exception&) { | ||
| 34 | return ERROR_OVERFLOW; | ||
| 35 | } | ||
| 36 | |||
| 37 | return RESULT_SUCCESS; | ||
| 38 | } | ||
| 39 | |||
| 20 | static SteadyClockTimePoint GetRandom() { | 40 | static SteadyClockTimePoint GetRandom() { |
| 21 | return {0, Common::UUID::Generate()}; | 41 | return {0, Common::UUID::Generate()}; |
| 22 | } | 42 | } |
diff --git a/src/core/hle/service/time/interface.cpp b/src/core/hle/service/time/interface.cpp index b1307a434..0bc90b183 100644 --- a/src/core/hle/service/time/interface.cpp +++ b/src/core/hle/service/time/interface.cpp | |||
| @@ -24,7 +24,7 @@ Time::Time(std::shared_ptr<Module> module, Core::System& system, const char* nam | |||
| 24 | {100, nullptr, "IsStandardUserSystemClockAutomaticCorrectionEnabled"}, | 24 | {100, nullptr, "IsStandardUserSystemClockAutomaticCorrectionEnabled"}, |
| 25 | {101, nullptr, "SetStandardUserSystemClockAutomaticCorrectionEnabled"}, | 25 | {101, nullptr, "SetStandardUserSystemClockAutomaticCorrectionEnabled"}, |
| 26 | {102, nullptr, "GetStandardUserSystemClockInitialYear"}, | 26 | {102, nullptr, "GetStandardUserSystemClockInitialYear"}, |
| 27 | {200, nullptr, "IsStandardNetworkSystemClockAccuracySufficient"}, | 27 | {200, &Time::IsStandardNetworkSystemClockAccuracySufficient, "IsStandardNetworkSystemClockAccuracySufficient"}, |
| 28 | {201, nullptr, "GetStandardUserSystemClockAutomaticCorrectionUpdatedTime"}, | 28 | {201, nullptr, "GetStandardUserSystemClockAutomaticCorrectionUpdatedTime"}, |
| 29 | {300, &Time::CalculateMonotonicSystemClockBaseTimePoint, "CalculateMonotonicSystemClockBaseTimePoint"}, | 29 | {300, &Time::CalculateMonotonicSystemClockBaseTimePoint, "CalculateMonotonicSystemClockBaseTimePoint"}, |
| 30 | {400, &Time::GetClockSnapshot, "GetClockSnapshot"}, | 30 | {400, &Time::GetClockSnapshot, "GetClockSnapshot"}, |
diff --git a/src/core/hle/service/time/standard_network_system_clock_core.h b/src/core/hle/service/time/standard_network_system_clock_core.h index 467285160..3f505c37c 100644 --- a/src/core/hle/service/time/standard_network_system_clock_core.h +++ b/src/core/hle/service/time/standard_network_system_clock_core.h | |||
| @@ -8,6 +8,10 @@ | |||
| 8 | #include "core/hle/service/time/steady_clock_core.h" | 8 | #include "core/hle/service/time/steady_clock_core.h" |
| 9 | #include "core/hle/service/time/system_clock_core.h" | 9 | #include "core/hle/service/time/system_clock_core.h" |
| 10 | 10 | ||
| 11 | namespace Core { | ||
| 12 | class System; | ||
| 13 | } | ||
| 14 | |||
| 11 | namespace Service::Time::Clock { | 15 | namespace Service::Time::Clock { |
| 12 | 16 | ||
| 13 | class StandardNetworkSystemClockCore final : public SystemClockCore { | 17 | class StandardNetworkSystemClockCore final : public SystemClockCore { |
| @@ -19,6 +23,22 @@ public: | |||
| 19 | standard_network_clock_sufficient_accuracy = value; | 23 | standard_network_clock_sufficient_accuracy = value; |
| 20 | } | 24 | } |
| 21 | 25 | ||
| 26 | bool IsStandardNetworkSystemClockAccuracySufficient(Core::System& system) { | ||
| 27 | SystemClockContext context{}; | ||
| 28 | if (GetClockContext(system, context) != RESULT_SUCCESS) { | ||
| 29 | return {}; | ||
| 30 | } | ||
| 31 | |||
| 32 | s64 span{}; | ||
| 33 | if (context.steady_time_point.GetSpanBetween( | ||
| 34 | GetSteadyClockCore().GetCurrentTimePoint(system), span) != RESULT_SUCCESS) { | ||
| 35 | return {}; | ||
| 36 | } | ||
| 37 | |||
| 38 | return TimeSpanType{span}.nanoseconds < | ||
| 39 | standard_network_clock_sufficient_accuracy.nanoseconds; | ||
| 40 | } | ||
| 41 | |||
| 22 | private: | 42 | private: |
| 23 | TimeSpanType standard_network_clock_sufficient_accuracy{}; | 43 | TimeSpanType standard_network_clock_sufficient_accuracy{}; |
| 24 | }; | 44 | }; |
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 970aed0bb..2053fa078 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp | |||
| @@ -199,6 +199,15 @@ void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { | |||
| 199 | rb.PushIpcInterface<ITimeZoneService>(module->GetTimeManager().GetTimeZoneContentManager()); | 199 | rb.PushIpcInterface<ITimeZoneService>(module->GetTimeManager().GetTimeZoneContentManager()); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | void Module::Interface::IsStandardNetworkSystemClockAccuracySufficient( | ||
| 203 | Kernel::HLERequestContext& ctx) { | ||
| 204 | LOG_DEBUG(Service_Time, "called"); | ||
| 205 | auto& clock_core{module->GetTimeManager().GetStandardNetworkSystemClockCore()}; | ||
| 206 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 207 | rb.Push(RESULT_SUCCESS); | ||
| 208 | rb.Push<u32>(clock_core.IsStandardNetworkSystemClockAccuracySufficient(system)); | ||
| 209 | } | ||
| 210 | |||
| 202 | void Module::Interface::CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx) { | 211 | void Module::Interface::CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx) { |
| 203 | LOG_DEBUG(Service_Time, "called"); | 212 | LOG_DEBUG(Service_Time, "called"); |
| 204 | 213 | ||
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h index 7b77ac7ea..0b3cda6aa 100644 --- a/src/core/hle/service/time/time.h +++ b/src/core/hle/service/time/time.h | |||
| @@ -27,6 +27,7 @@ public: | |||
| 27 | void GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx); | 27 | void GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx); |
| 28 | void GetStandardSteadyClock(Kernel::HLERequestContext& ctx); | 28 | void GetStandardSteadyClock(Kernel::HLERequestContext& ctx); |
| 29 | void GetTimeZoneService(Kernel::HLERequestContext& ctx); | 29 | void GetTimeZoneService(Kernel::HLERequestContext& ctx); |
| 30 | void IsStandardNetworkSystemClockAccuracySufficient(Kernel::HLERequestContext& ctx); | ||
| 30 | void CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx); | 31 | void CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx); |
| 31 | void GetClockSnapshot(Kernel::HLERequestContext& ctx); | 32 | void GetClockSnapshot(Kernel::HLERequestContext& ctx); |
| 32 | void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx); | 33 | void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx); |