summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/time/clock_types.h12
-rw-r--r--src/core/hle/service/time/time_sharedmemory.cpp19
-rw-r--r--src/core/hle/service/time/time_sharedmemory.h5
3 files changed, 34 insertions, 2 deletions
diff --git a/src/core/hle/service/time/clock_types.h b/src/core/hle/service/time/clock_types.h
index ed1eb5b2d..e6293ffb9 100644
--- a/src/core/hle/service/time/clock_types.h
+++ b/src/core/hle/service/time/clock_types.h
@@ -59,6 +59,18 @@ static_assert(sizeof(SystemClockContext) == 0x20, "SystemClockContext is incorre
59static_assert(std::is_trivially_copyable_v<SystemClockContext>, 59static_assert(std::is_trivially_copyable_v<SystemClockContext>,
60 "SystemClockContext must be trivially copyable"); 60 "SystemClockContext must be trivially copyable");
61 61
62struct ContinuousAdjustmentTimePoint {
63 s64 measurement_offset;
64 s64 diff_scale;
65 u32 shift_amount;
66 s64 lower;
67 s64 upper;
68 Common::UUID clock_source_id;
69};
70static_assert(sizeof(ContinuousAdjustmentTimePoint) == 0x38);
71static_assert(std::is_trivially_copyable_v<ContinuousAdjustmentTimePoint>,
72 "ContinuousAdjustmentTimePoint must be trivially copyable");
73
62/// https://switchbrew.org/wiki/Glue_services#TimeSpanType 74/// https://switchbrew.org/wiki/Glue_services#TimeSpanType
63struct TimeSpanType { 75struct TimeSpanType {
64 s64 nanoseconds{}; 76 s64 nanoseconds{};
diff --git a/src/core/hle/service/time/time_sharedmemory.cpp b/src/core/hle/service/time/time_sharedmemory.cpp
index ff53a7d6f..ce1c85bcc 100644
--- a/src/core/hle/service/time/time_sharedmemory.cpp
+++ b/src/core/hle/service/time/time_sharedmemory.cpp
@@ -30,6 +30,25 @@ void SharedMemory::SetupStandardSteadyClock(const Common::UUID& clock_source_id,
30} 30}
31 31
32void SharedMemory::UpdateLocalSystemClockContext(const Clock::SystemClockContext& context) { 32void SharedMemory::UpdateLocalSystemClockContext(const Clock::SystemClockContext& context) {
33 // lower and upper are related to the measurement point for the steady time point,
34 // and compare equal on boot
35 const s64 time_point_ns = context.steady_time_point.time_point * 1'000'000'000LL;
36
37 // This adjusts for some sort of time skew
38 // Both 0 on boot
39 const s64 diff_scale = 0;
40 const u32 shift_amount = 0;
41
42 const Clock::ContinuousAdjustmentTimePoint adjustment{
43 .measurement_offset = system.CoreTiming().GetGlobalTimeNs().count(),
44 .diff_scale = diff_scale,
45 .shift_amount = shift_amount,
46 .lower = time_point_ns,
47 .upper = time_point_ns,
48 .clock_source_id = context.steady_time_point.clock_source_id,
49 };
50
51 StoreToLockFreeAtomicType(&GetFormat()->continuous_adjustment_timepoint, adjustment);
33 StoreToLockFreeAtomicType(&GetFormat()->standard_local_system_clock_context, context); 52 StoreToLockFreeAtomicType(&GetFormat()->standard_local_system_clock_context, context);
34} 53}
35 54
diff --git a/src/core/hle/service/time/time_sharedmemory.h b/src/core/hle/service/time/time_sharedmemory.h
index 044a4d24e..c89be9765 100644
--- a/src/core/hle/service/time/time_sharedmemory.h
+++ b/src/core/hle/service/time/time_sharedmemory.h
@@ -65,14 +65,15 @@ public:
65 LockFreeAtomicType<Clock::SystemClockContext> standard_local_system_clock_context; 65 LockFreeAtomicType<Clock::SystemClockContext> standard_local_system_clock_context;
66 LockFreeAtomicType<Clock::SystemClockContext> standard_network_system_clock_context; 66 LockFreeAtomicType<Clock::SystemClockContext> standard_network_system_clock_context;
67 LockFreeAtomicType<bool> is_standard_user_system_clock_automatic_correction_enabled; 67 LockFreeAtomicType<bool> is_standard_user_system_clock_automatic_correction_enabled;
68 u32 format_version; 68 LockFreeAtomicType<Clock::ContinuousAdjustmentTimePoint> continuous_adjustment_timepoint;
69 }; 69 };
70 static_assert(offsetof(Format, standard_steady_clock_timepoint) == 0x0); 70 static_assert(offsetof(Format, standard_steady_clock_timepoint) == 0x0);
71 static_assert(offsetof(Format, standard_local_system_clock_context) == 0x38); 71 static_assert(offsetof(Format, standard_local_system_clock_context) == 0x38);
72 static_assert(offsetof(Format, standard_network_system_clock_context) == 0x80); 72 static_assert(offsetof(Format, standard_network_system_clock_context) == 0x80);
73 static_assert(offsetof(Format, is_standard_user_system_clock_automatic_correction_enabled) == 73 static_assert(offsetof(Format, is_standard_user_system_clock_automatic_correction_enabled) ==
74 0xc8); 74 0xc8);
75 static_assert(sizeof(Format) == 0xd8, "Format is an invalid size"); 75 static_assert(offsetof(Format, continuous_adjustment_timepoint) == 0xd0);
76 static_assert(sizeof(Format) == 0x148, "Format is an invalid size");
76 77
77 void SetupStandardSteadyClock(const Common::UUID& clock_source_id, 78 void SetupStandardSteadyClock(const Common::UUID& clock_source_id,
78 Clock::TimeSpanType current_time_point); 79 Clock::TimeSpanType current_time_point);