static.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include "common/common_types.h"
  5. #include "core/hle/service/cmif_types.h"
  6. #include "core/hle/service/glue/time/manager.h"
  7. #include "core/hle/service/glue/time/time_zone.h"
  8. #include "core/hle/service/psc/time/common.h"
  9. namespace Core {
  10. class System;
  11. }
  12. namespace Service::Set {
  13. class ISystemSettingsServer;
  14. }
  15. namespace Service::PSC::Time {
  16. class StaticService;
  17. class SystemClock;
  18. class SteadyClock;
  19. class TimeZoneService;
  20. class ServiceManager;
  21. } // namespace Service::PSC::Time
  22. namespace Service::Glue::Time {
  23. class FileTimestampWorker;
  24. class StandardSteadyClockResource;
  25. class StaticService final : public ServiceFramework<StaticService> {
  26. using InClockSnapshot = InLargeData<Service::PSC::Time::ClockSnapshot, BufferAttr_HipcPointer>;
  27. using OutClockSnapshot =
  28. OutLargeData<Service::PSC::Time::ClockSnapshot, BufferAttr_HipcPointer>;
  29. public:
  30. explicit StaticService(Core::System& system,
  31. Service::PSC::Time::StaticServiceSetupInfo setup_info,
  32. std::shared_ptr<TimeManager> time, const char* name);
  33. ~StaticService() override = default;
  34. Result GetStandardUserSystemClock(OutInterface<Service::PSC::Time::SystemClock> out_service);
  35. Result GetStandardNetworkSystemClock(OutInterface<Service::PSC::Time::SystemClock> out_service);
  36. Result GetStandardSteadyClock(OutInterface<Service::PSC::Time::SteadyClock> out_service);
  37. Result GetTimeZoneService(OutInterface<TimeZoneService> out_service);
  38. Result GetStandardLocalSystemClock(OutInterface<Service::PSC::Time::SystemClock> out_service);
  39. Result GetEphemeralNetworkSystemClock(
  40. OutInterface<Service::PSC::Time::SystemClock> out_service);
  41. Result GetSharedMemoryNativeHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory);
  42. Result SetStandardSteadyClockInternalOffset(s64 offset_ns);
  43. Result GetStandardSteadyClockRtcValue(Out<s64> out_rtc_value);
  44. Result IsStandardUserSystemClockAutomaticCorrectionEnabled(Out<bool> out_is_enabled);
  45. Result SetStandardUserSystemClockAutomaticCorrectionEnabled(bool automatic_correction);
  46. Result GetStandardUserSystemClockInitialYear(Out<s32> out_year);
  47. Result IsStandardNetworkSystemClockAccuracySufficient(Out<bool> out_is_sufficient);
  48. Result GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
  49. Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
  50. Result CalculateMonotonicSystemClockBaseTimePoint(
  51. Out<s64> out_time, Service::PSC::Time::SystemClockContext& context);
  52. Result GetClockSnapshot(OutClockSnapshot out_snapshot, Service::PSC::Time::TimeType type);
  53. Result GetClockSnapshotFromSystemClockContext(
  54. Service::PSC::Time::TimeType type, OutClockSnapshot out_snapshot,
  55. Service::PSC::Time::SystemClockContext& user_context,
  56. Service::PSC::Time::SystemClockContext& network_context);
  57. Result CalculateStandardUserSystemClockDifferenceByUser(Out<s64> out_difference,
  58. InClockSnapshot a, InClockSnapshot b);
  59. Result CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a, InClockSnapshot b);
  60. private:
  61. Core::System& m_system;
  62. std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
  63. std::shared_ptr<Service::PSC::Time::ServiceManager> m_time_m;
  64. std::shared_ptr<Service::PSC::Time::StaticService> m_wrapped_service;
  65. Service::PSC::Time::StaticServiceSetupInfo m_setup_info;
  66. std::shared_ptr<Service::PSC::Time::StaticService> m_time_sm;
  67. std::shared_ptr<Service::PSC::Time::TimeZoneService> m_time_zone;
  68. FileTimestampWorker& m_file_timestamp_worker;
  69. StandardSteadyClockResource& m_standard_steady_clock_resource;
  70. };
  71. } // namespace Service::Glue::Time