From 78f977c980e125e92b86261335447d0a254f18ee Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 22 Dec 2019 17:49:51 -0500 Subject: service: time: Rewrite implementation of glue services. --- src/core/hle/service/time/time_sharedmemory.h | 35 ++++++++++++--------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src/core/hle/service/time/time_sharedmemory.h') diff --git a/src/core/hle/service/time/time_sharedmemory.h b/src/core/hle/service/time/time_sharedmemory.h index 904a96430..5976b2046 100644 --- a/src/core/hle/service/time/time_sharedmemory.h +++ b/src/core/hle/service/time/time_sharedmemory.h @@ -5,11 +5,14 @@ #pragma once #include "common/common_types.h" +#include "common/uuid.h" #include "core/hle/kernel/shared_memory.h" -#include "core/hle/service/time/time.h" +#include "core/hle/kernel/thread.h" +#include "core/hle/service/time/clock_types.h" namespace Service::Time { -class SharedMemory { + +class SharedMemory final { public: explicit SharedMemory(Core::System& system); ~SharedMemory(); @@ -17,22 +20,10 @@ public: // Return the shared memory handle std::shared_ptr GetSharedMemoryHolder() const; - // Set memory barriers in shared memory and update them - void SetStandardSteadyClockTimepoint(const SteadyClockTimePoint& timepoint); - void SetStandardLocalSystemClockContext(const SystemClockContext& context); - void SetStandardNetworkSystemClockContext(const SystemClockContext& context); - void SetStandardUserSystemClockAutomaticCorrectionEnabled(bool enabled); - - // Pull from memory barriers in the shared memory - SteadyClockTimePoint GetStandardSteadyClockTimepoint(); - SystemClockContext GetStandardLocalSystemClockContext(); - SystemClockContext GetStandardNetworkSystemClockContext(); - bool GetStandardUserSystemClockAutomaticCorrectionEnabled(); - // TODO(ogniK): We have to properly simulate memory barriers, how are we going to do this? template struct MemoryBarrier { - static_assert(std::is_trivially_constructible_v, "T must be trivially constructable"); + static_assert(std::is_trivially_copyable_v, "T must be trivially copyable"); u32_le read_attempt{}; std::array data{}; @@ -57,16 +48,22 @@ public: // Shared memory format struct Format { - MemoryBarrier standard_steady_clock_timepoint; - MemoryBarrier standard_local_system_clock_context; - MemoryBarrier standard_network_system_clock_context; + MemoryBarrier standard_steady_clock_timepoint; + MemoryBarrier standard_local_system_clock_context; + MemoryBarrier standard_network_system_clock_context; MemoryBarrier standard_user_system_clock_automatic_correction; u32_le format_version; }; static_assert(sizeof(Format) == 0xd8, "Format is an invalid size"); + void SetupStandardSteadyClock(Core::System& system, const Common::UUID& clock_source_id, + Clock::TimeSpanType currentTimePoint); + void UpdateLocalSystemClockContext(const Clock::SystemClockContext& context); + void UpdateNetworkSystemClockContext(const Clock::SystemClockContext& context); + void SetAutomaticCorrectionEnabled(bool is_enabled); + private: - std::shared_ptr shared_memory_holder{}; + std::shared_ptr shared_memory_holder; Core::System& system; Format shared_memory_format{}; }; -- cgit v1.2.3