diff --git a/README.md b/README.md index b1a773ccf..189a58b85 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 4053. +This is the source code for early-access 4056. ## Legal Notice diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index fbde3abca..cd7d10a7e 100755 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -178,9 +178,6 @@ if (NOT TARGET stb::headers) add_library(stb::headers ALIAS stb) endif() -add_library(tz tz/tz/tz.cpp) -target_include_directories(tz PUBLIC ./tz) - add_library(bc_decoder bc_decoder/bc_decoder.cpp) target_include_directories(bc_decoder PUBLIC ./bc_decoder) diff --git a/src/common/arm64/native_clock.cpp b/src/common/arm64/native_clock.cpp index 55147f0f2..f437d7187 100755 --- a/src/common/arm64/native_clock.cpp +++ b/src/common/arm64/native_clock.cpp @@ -29,32 +29,28 @@ NativeClock::NativeClock() { gputick_cntfrq_factor = GetFixedPointFactor(GPUTickFreq, host_cntfrq); } -void NativeClock::Reset() { - start_ticks = GetUptime(); -} - std::chrono::nanoseconds NativeClock::GetTimeNS() const { - return std::chrono::nanoseconds{MultiplyHigh(GetUptime(), ns_cntfrq_factor)}; + return std::chrono::nanoseconds{MultiplyHigh(GetHostTicksElapsed(), ns_cntfrq_factor)}; } std::chrono::microseconds NativeClock::GetTimeUS() const { - return std::chrono::microseconds{MultiplyHigh(GetUptime(), us_cntfrq_factor)}; + return std::chrono::microseconds{MultiplyHigh(GetHostTicksElapsed(), us_cntfrq_factor)}; } std::chrono::milliseconds NativeClock::GetTimeMS() const { - return std::chrono::milliseconds{MultiplyHigh(GetUptime(), ms_cntfrq_factor)}; + return std::chrono::milliseconds{MultiplyHigh(GetHostTicksElapsed(), ms_cntfrq_factor)}; } -s64 NativeClock::GetCNTPCT() const { - return MultiplyHigh(GetUptime() - start_ticks, guest_cntfrq_factor); +u64 NativeClock::GetCNTPCT() const { + return MultiplyHigh(GetHostTicksElapsed(), guest_cntfrq_factor); } -s64 NativeClock::GetGPUTick() const { - return MultiplyHigh(GetUptime() - start_ticks, gputick_cntfrq_factor); +u64 NativeClock::GetGPUTick() const { + return MultiplyHigh(GetHostTicksElapsed(), gputick_cntfrq_factor); } -s64 NativeClock::GetUptime() const { - s64 cntvct_el0 = 0; +u64 NativeClock::GetHostTicksNow() const { + u64 cntvct_el0 = 0; asm volatile("dsb ish\n\t" "mrs %[cntvct_el0], cntvct_el0\n\t" "dsb ish\n\t" @@ -62,11 +58,15 @@ s64 NativeClock::GetUptime() const { return cntvct_el0; } +u64 NativeClock::GetHostTicksElapsed() const { + return GetHostTicksNow(); +} + bool NativeClock::IsNative() const { return true; } -s64 NativeClock::GetHostCNTFRQ() { +u64 NativeClock::GetHostCNTFRQ() { u64 cntfrq_el0 = 0; std::string_view board{""}; #ifdef ANDROID diff --git a/src/common/arm64/native_clock.h b/src/common/arm64/native_clock.h index 39cad5710..a28b419f2 100755 --- a/src/common/arm64/native_clock.h +++ b/src/common/arm64/native_clock.h @@ -11,23 +11,23 @@ class NativeClock final : public WallClock { public: explicit NativeClock(); - void Reset() override; - std::chrono::nanoseconds GetTimeNS() const override; std::chrono::microseconds GetTimeUS() const override; std::chrono::milliseconds GetTimeMS() const override; - s64 GetCNTPCT() const override; + u64 GetCNTPCT() const override; - s64 GetGPUTick() const override; + u64 GetGPUTick() const override; - s64 GetUptime() const override; + u64 GetHostTicksNow() const override; + + u64 GetHostTicksElapsed() const override; bool IsNative() const override; - static s64 GetHostCNTFRQ(); + static u64 GetHostCNTFRQ(); public: using FactorType = unsigned __int128; @@ -42,7 +42,6 @@ private: FactorType ms_cntfrq_factor; FactorType guest_cntfrq_factor; FactorType gputick_cntfrq_factor; - s64 start_ticks; }; } // namespace Common::Arm64 diff --git a/src/common/memory_detect.h b/src/common/memory_detect.h index 9e125d7ab..6e77ef01e 100755 --- a/src/common/memory_detect.h +++ b/src/common/memory_detect.h @@ -18,4 +18,4 @@ struct MemoryInfo { */ [[nodiscard]] const MemoryInfo& GetMemInfo(); -} // namespace Common +} // namespace Common \ No newline at end of file diff --git a/src/common/uuid.h b/src/common/uuid.h index 131a7cf9e..917280515 100755 --- a/src/common/uuid.h +++ b/src/common/uuid.h @@ -12,8 +12,9 @@ namespace Common { struct UUID { - std::array uuid; + std::array uuid{}; + /// Constructs an invalid UUID. constexpr UUID() = default; /// Constructs a UUID from a reference to a 128 bit array. @@ -33,6 +34,14 @@ struct UUID { */ explicit UUID(std::string_view uuid_string); + ~UUID() = default; + + constexpr UUID(const UUID&) noexcept = default; + constexpr UUID(UUID&&) noexcept = default; + + constexpr UUID& operator=(const UUID&) noexcept = default; + constexpr UUID& operator=(UUID&&) noexcept = default; + /** * Returns whether the stored UUID is valid or not. * @@ -112,7 +121,6 @@ struct UUID { friend constexpr bool operator==(const UUID& lhs, const UUID& rhs) = default; }; static_assert(sizeof(UUID) == 0x10, "UUID has incorrect size."); -static_assert(std::is_trivial_v); /// An invalid UUID. This UUID has all its bytes set to 0. constexpr UUID InvalidUUID = {}; diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index 22174fcc1..746778616 100755 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp @@ -18,39 +18,34 @@ namespace Common { class StandardWallClock final : public WallClock { public: - explicit StandardWallClock() {} - - void Reset() override { - start_time = std::chrono::system_clock::now(); - } + explicit StandardWallClock() : start_time{SteadyClock::Now()} {} std::chrono::nanoseconds GetTimeNS() const override { - return std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()); + return SteadyClock::Now() - start_time; } std::chrono::microseconds GetTimeUS() const override { - return std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()); + return static_cast(GetHostTicksElapsed() / NsToUsRatio::den); } std::chrono::milliseconds GetTimeMS() const override { - return std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()); + return static_cast(GetHostTicksElapsed() / NsToMsRatio::den); } - s64 GetCNTPCT() const override { - return GetUptime() * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den; + u64 GetCNTPCT() const override { + return GetHostTicksElapsed() * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den; } - s64 GetGPUTick() const override { - return GetUptime() * NsToGPUTickRatio::num / NsToGPUTickRatio::den; + u64 GetGPUTick() const override { + return GetHostTicksElapsed() * NsToGPUTickRatio::num / NsToGPUTickRatio::den; } - s64 GetUptime() const override { - return std::chrono::duration_cast( - std::chrono::system_clock::now() - start_time) - .count(); + u64 GetHostTicksNow() const override { + return static_cast(SteadyClock::Now().time_since_epoch().count()); + } + + u64 GetHostTicksElapsed() const override { + return static_cast(GetTimeNS().count()); } bool IsNative() const override { @@ -58,7 +53,7 @@ public: } private: - std::chrono::system_clock::time_point start_time{}; + SteadyClock::time_point start_time; }; std::unique_ptr CreateOptimalClock() { diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h index 192d4466a..d885c84e5 100755 --- a/src/common/wall_clock.h +++ b/src/common/wall_clock.h @@ -19,8 +19,6 @@ public: virtual ~WallClock() = default; - virtual void Reset() = 0; - /// @returns The time in nanoseconds since the construction of this clock. virtual std::chrono::nanoseconds GetTimeNS() const = 0; @@ -31,13 +29,16 @@ public: virtual std::chrono::milliseconds GetTimeMS() const = 0; /// @returns The guest CNTPCT ticks since the construction of this clock. - virtual s64 GetCNTPCT() const = 0; + virtual u64 GetCNTPCT() const = 0; /// @returns The guest GPU ticks since the construction of this clock. - virtual s64 GetGPUTick() const = 0; + virtual u64 GetGPUTick() const = 0; /// @returns The raw host timer ticks since an indeterminate epoch. - virtual s64 GetUptime() const = 0; + virtual u64 GetHostTicksNow() const = 0; + + /// @returns The raw host timer ticks since the construction of this clock. + virtual u64 GetHostTicksElapsed() const = 0; /// @returns Whether the clock directly uses the host's hardware clock. virtual bool IsNative() const = 0; diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 21dfce8a8..9fbe75bd1 100755 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp @@ -8,39 +8,39 @@ namespace Common::X64 { NativeClock::NativeClock(u64 rdtsc_frequency_) - : rdtsc_frequency{rdtsc_frequency_}, ns_rdtsc_factor{GetFixedPoint64Factor(NsRatio::den, - rdtsc_frequency)}, + : start_ticks{FencedRDTSC()}, rdtsc_frequency{rdtsc_frequency_}, + ns_rdtsc_factor{GetFixedPoint64Factor(NsRatio::den, rdtsc_frequency)}, us_rdtsc_factor{GetFixedPoint64Factor(UsRatio::den, rdtsc_frequency)}, ms_rdtsc_factor{GetFixedPoint64Factor(MsRatio::den, rdtsc_frequency)}, cntpct_rdtsc_factor{GetFixedPoint64Factor(CNTFRQ, rdtsc_frequency)}, gputick_rdtsc_factor{GetFixedPoint64Factor(GPUTickFreq, rdtsc_frequency)} {} -void NativeClock::Reset() { - start_ticks = FencedRDTSC(); -} - std::chrono::nanoseconds NativeClock::GetTimeNS() const { - return std::chrono::nanoseconds{MultiplyHigh(GetUptime(), ns_rdtsc_factor)}; + return std::chrono::nanoseconds{MultiplyHigh(GetHostTicksElapsed(), ns_rdtsc_factor)}; } std::chrono::microseconds NativeClock::GetTimeUS() const { - return std::chrono::microseconds{MultiplyHigh(GetUptime(), us_rdtsc_factor)}; + return std::chrono::microseconds{MultiplyHigh(GetHostTicksElapsed(), us_rdtsc_factor)}; } std::chrono::milliseconds NativeClock::GetTimeMS() const { - return std::chrono::milliseconds{MultiplyHigh(GetUptime(), ms_rdtsc_factor)}; + return std::chrono::milliseconds{MultiplyHigh(GetHostTicksElapsed(), ms_rdtsc_factor)}; } -s64 NativeClock::GetCNTPCT() const { - return MultiplyHigh(GetUptime() - start_ticks, cntpct_rdtsc_factor); +u64 NativeClock::GetCNTPCT() const { + return MultiplyHigh(GetHostTicksElapsed(), cntpct_rdtsc_factor); } -s64 NativeClock::GetGPUTick() const { - return MultiplyHigh(GetUptime() - start_ticks, gputick_rdtsc_factor); +u64 NativeClock::GetGPUTick() const { + return MultiplyHigh(GetHostTicksElapsed(), gputick_rdtsc_factor); } -s64 NativeClock::GetUptime() const { - return static_cast(FencedRDTSC()); +u64 NativeClock::GetHostTicksNow() const { + return FencedRDTSC(); +} + +u64 NativeClock::GetHostTicksElapsed() const { + return FencedRDTSC() - start_ticks; } bool NativeClock::IsNative() const { diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h index 1fa151b09..925d3928c 100755 --- a/src/common/x64/native_clock.h +++ b/src/common/x64/native_clock.h @@ -11,19 +11,19 @@ class NativeClock final : public WallClock { public: explicit NativeClock(u64 rdtsc_frequency_); - void Reset() override; - std::chrono::nanoseconds GetTimeNS() const override; std::chrono::microseconds GetTimeUS() const override; std::chrono::milliseconds GetTimeMS() const override; - s64 GetCNTPCT() const override; + u64 GetCNTPCT() const override; - s64 GetGPUTick() const override; + u64 GetGPUTick() const override; - s64 GetUptime() const override; + u64 GetHostTicksNow() const override; + + u64 GetHostTicksElapsed() const override; bool IsNative() const override; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4d91e01a2..decf1c9d4 100755 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -511,24 +511,6 @@ add_library(core STATIC hle/service/glue/glue_manager.h hle/service/glue/notif.cpp hle/service/glue/notif.h - hle/service/glue/time/alarm_worker.cpp - hle/service/glue/time/alarm_worker.h - hle/service/glue/time/file_timestamp_worker.cpp - hle/service/glue/time/file_timestamp_worker.h - hle/service/glue/time/manager.cpp - hle/service/glue/time/manager.h - hle/service/glue/time/pm_state_change_handler.cpp - hle/service/glue/time/pm_state_change_handler.h - hle/service/glue/time/standard_steady_clock_resource.cpp - hle/service/glue/time/standard_steady_clock_resource.h - hle/service/glue/time/static.cpp - hle/service/glue/time/static.h - hle/service/glue/time/time_zone.cpp - hle/service/glue/time/time_zone.h - hle/service/glue/time/time_zone_binary.cpp - hle/service/glue/time/time_zone_binary.h - hle/service/glue/time/worker.cpp - hle/service/glue/time/worker.h hle/service/grc/grc.cpp hle/service/grc/grc.h hle/service/hid/hid.cpp @@ -707,46 +689,6 @@ add_library(core STATIC hle/service/prepo/prepo.h hle/service/psc/psc.cpp hle/service/psc/psc.h - hle/service/psc/time/alarms.cpp - hle/service/psc/time/alarms.h - hle/service/psc/time/clocks/context_writers.cpp - hle/service/psc/time/clocks/context_writers.h - hle/service/psc/time/clocks/ephemeral_network_system_clock_core.h - hle/service/psc/time/clocks/standard_local_system_clock_core.cpp - hle/service/psc/time/clocks/standard_local_system_clock_core.h - hle/service/psc/time/clocks/standard_network_system_clock_core.cpp - hle/service/psc/time/clocks/standard_network_system_clock_core.h - hle/service/psc/time/clocks/standard_steady_clock_core.cpp - hle/service/psc/time/clocks/standard_steady_clock_core.h - hle/service/psc/time/clocks/standard_user_system_clock_core.cpp - hle/service/psc/time/clocks/standard_user_system_clock_core.h - hle/service/psc/time/clocks/steady_clock_core.h - hle/service/psc/time/clocks/system_clock_core.cpp - hle/service/psc/time/clocks/system_clock_core.h - hle/service/psc/time/clocks/tick_based_steady_clock_core.cpp - hle/service/psc/time/clocks/tick_based_steady_clock_core.h - hle/service/psc/time/common.cpp - hle/service/psc/time/common.h - hle/service/psc/time/errors.h - hle/service/psc/time/shared_memory.cpp - hle/service/psc/time/shared_memory.h - hle/service/psc/time/static.cpp - hle/service/psc/time/static.h - hle/service/psc/time/manager.h - hle/service/psc/time/power_state_service.cpp - hle/service/psc/time/power_state_service.h - hle/service/psc/time/service_manager.cpp - hle/service/psc/time/service_manager.h - hle/service/psc/time/steady_clock.cpp - hle/service/psc/time/steady_clock.h - hle/service/psc/time/system_clock.cpp - hle/service/psc/time/system_clock.h - hle/service/psc/time/time_zone.cpp - hle/service/psc/time/time_zone.h - hle/service/psc/time/time_zone_service.cpp - hle/service/psc/time/time_zone_service.h - hle/service/psc/time/power_state_request_manager.cpp - hle/service/psc/time/power_state_request_manager.h hle/service/ptm/psm.cpp hle/service/ptm/psm.h hle/service/ptm/ptm.cpp @@ -813,6 +755,40 @@ add_library(core STATIC hle/service/ssl/ssl.cpp hle/service/ssl/ssl.h hle/service/ssl/ssl_backend.h + hle/service/time/clock_types.h + hle/service/time/ephemeral_network_system_clock_context_writer.h + hle/service/time/ephemeral_network_system_clock_core.h + hle/service/time/errors.h + hle/service/time/local_system_clock_context_writer.h + hle/service/time/network_system_clock_context_writer.h + hle/service/time/standard_local_system_clock_core.h + hle/service/time/standard_network_system_clock_core.h + hle/service/time/standard_steady_clock_core.cpp + hle/service/time/standard_steady_clock_core.h + hle/service/time/standard_user_system_clock_core.cpp + hle/service/time/standard_user_system_clock_core.h + hle/service/time/steady_clock_core.h + hle/service/time/system_clock_context_update_callback.cpp + hle/service/time/system_clock_context_update_callback.h + hle/service/time/system_clock_core.cpp + hle/service/time/system_clock_core.h + hle/service/time/tick_based_steady_clock_core.cpp + hle/service/time/tick_based_steady_clock_core.h + hle/service/time/time.cpp + hle/service/time/time.h + hle/service/time/time_interface.cpp + hle/service/time/time_interface.h + hle/service/time/time_manager.cpp + hle/service/time/time_manager.h + hle/service/time/time_sharedmemory.cpp + hle/service/time/time_sharedmemory.h + hle/service/time/time_zone_content_manager.cpp + hle/service/time/time_zone_content_manager.h + hle/service/time/time_zone_manager.cpp + hle/service/time/time_zone_manager.h + hle/service/time/time_zone_service.cpp + hle/service/time/time_zone_service.h + hle/service/time/time_zone_types.h hle/service/usb/usb.cpp hle/service/usb/usb.h hle/service/vi/display/vi_display.cpp @@ -893,7 +869,7 @@ endif() create_target_directory_groups(core) -target_link_libraries(core PUBLIC common PRIVATE audio_core hid_core network video_core nx_tzdb tz) +target_link_libraries(core PUBLIC common PRIVATE audio_core hid_core network video_core nx_tzdb) target_link_libraries(core PUBLIC Boost::headers PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls RenderDoc::API) if (MINGW) target_link_libraries(core PRIVATE ${MSWSOCK_LIBRARY}) diff --git a/src/core/core.cpp b/src/core/core.cpp index f33552e64..479615b12 100755 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -40,12 +40,9 @@ #include "core/hle/service/apm/apm_controller.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/glue/glue_manager.h" -#include "core/hle/service/glue/time/static.h" -#include "core/hle/service/psc/time/static.h" -#include "core/hle/service/psc/time/steady_clock.h" -#include "core/hle/service/psc/time/system_clock.h" #include "core/hle/service/service.h" #include "core/hle/service/sm/sm.h" +#include "core/hle/service/time/time_manager.h" #include "core/internal_network/network.h" #include "core/loader/loader.h" #include "core/memory.h" @@ -133,8 +130,8 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, struct System::Impl { explicit Impl(System& system) - : kernel{system}, fs_controller{system}, hid_core{}, room_network{}, - cpu_manager{system}, reporter{system}, applet_manager{system}, profile_manager{} {} + : kernel{system}, fs_controller{system}, hid_core{}, room_network{}, cpu_manager{system}, + reporter{system}, applet_manager{system}, profile_manager{}, time_manager{system} {} void Initialize(System& system) { device_memory = std::make_unique(); @@ -146,7 +143,7 @@ struct System::Impl { core_timing.SetMulticore(is_multicore); core_timing.Initialize([&system]() { system.RegisterHostThread(); }); - RefreshTime(system); + RefreshTime(); // Create a default fs if one doesn't already exist. if (virtual_filesystem == nullptr) { @@ -185,7 +182,7 @@ struct System::Impl { Initialize(system); } - void RefreshTime(System& system) { + void RefreshTime() { const auto posix_time = std::chrono::system_clock::now().time_since_epoch(); const auto current_time = std::chrono::duration_cast(posix_time).count(); @@ -193,32 +190,6 @@ struct System::Impl { (Settings::values.custom_rtc_enabled ? Settings::values.custom_rtc.GetValue() : current_time) - current_time; - - if (!system.IsPoweredOn()) { - return; - } - - auto static_service_a = - system.ServiceManager().GetService("time:a", true); - auto static_service_s = - system.ServiceManager().GetService("time:s", true); - - std::shared_ptr user_clock; - static_service_a->GetStandardUserSystemClock(user_clock); - - std::shared_ptr local_clock; - static_service_a->GetStandardLocalSystemClock(local_clock); - - std::shared_ptr network_clock; - static_service_s->GetStandardNetworkSystemClock(network_clock); - - const auto new_time = Settings::values.custom_rtc_enabled - ? Settings::values.custom_rtc.GetValue() - : current_time; - - user_clock->SetCurrentTime(new_time); - local_clock->SetCurrentTime(new_time); - network_clock->SetCurrentTime(new_time); } void Run() { @@ -294,6 +265,9 @@ struct System::Impl { service_manager = std::make_shared(kernel); services = std::make_unique(service_manager, system); + // Initialize time manager, which must happen after kernel is created + time_manager.Initialize(); + is_powered_on = true; exit_locked = false; exit_requested = false; @@ -442,6 +416,7 @@ struct System::Impl { service_manager.reset(); cheat_engine.reset(); telemetry_session.reset(); + time_manager.Shutdown(); core_timing.ClearPendingEvents(); app_loader.reset(); audio_core.reset(); @@ -557,6 +532,7 @@ struct System::Impl { /// Service State Service::Glue::ARPManager arp_manager; Service::Account::ProfileManager profile_manager; + Service::Time::TimeManager time_manager; /// Service manager std::shared_ptr service_manager; @@ -934,6 +910,14 @@ const Service::Account::ProfileManager& System::GetProfileManager() const { return impl->profile_manager; } +Service::Time::TimeManager& System::GetTimeManager() { + return impl->time_manager; +} + +const Service::Time::TimeManager& System::GetTimeManager() const { + return impl->time_manager; +} + void System::SetExitLocked(bool locked) { impl->exit_locked = locked; } @@ -1045,9 +1029,13 @@ void System::Exit() { } void System::ApplySettings() { - impl->RefreshTime(*this); + impl->RefreshTime(); if (IsPoweredOn()) { + if (Settings::values.custom_rtc_enabled) { + const s64 posix_time{Settings::values.custom_rtc.GetValue()}; + GetTimeManager().UpdateLocalSystemClockTime(posix_time); + } Renderer().RefreshBaseSettings(); } } diff --git a/src/core/core.h b/src/core/core.h index 6634098d4..4e470cb7f 100755 --- a/src/core/core.h +++ b/src/core/core.h @@ -73,6 +73,10 @@ namespace SM { class ServiceManager; } // namespace SM +namespace Time { +class TimeManager; +} // namespace Time + } // namespace Service namespace Tegra { @@ -377,6 +381,9 @@ public: [[nodiscard]] Service::Account::ProfileManager& GetProfileManager(); [[nodiscard]] const Service::Account::ProfileManager& GetProfileManager() const; + [[nodiscard]] Service::Time::TimeManager& GetTimeManager(); + [[nodiscard]] const Service::Time::TimeManager& GetTimeManager() const; + [[nodiscard]] Core::Debugger& GetDebugger(); [[nodiscard]] const Core::Debugger& GetDebugger() const; diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 8918f46d3..5cd970b4d 100755 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -66,7 +66,6 @@ void CoreTiming::Initialize(std::function&& on_thread_init_) { event_fifo_id = 0; shutting_down = false; cpu_ticks = 0; - clock->Reset(); if (is_multicore) { timer_thread = std::make_unique(ThreadEntry, std::ref(*this)); } @@ -158,7 +157,7 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr& event_type, } } - for (auto& h : to_remove) { + for (auto h : to_remove) { event_queue.erase(h); } diff --git a/src/core/file_sys/system_archive/time_zone_binary.cpp b/src/core/file_sys/system_archive/time_zone_binary.cpp index d4fb1d983..7cf9f5f15 100755 --- a/src/core/file_sys/system_archive/time_zone_binary.cpp +++ b/src/core/file_sys/system_archive/time_zone_binary.cpp @@ -6,6 +6,7 @@ #include "common/swap.h" #include "core/file_sys/system_archive/time_zone_binary.h" #include "core/file_sys/vfs_vector.h" +#include "core/hle/service/time/time_zone_types.h" #include "nx_tzdb.h" diff --git a/src/core/hle/service/caps/caps_manager.cpp b/src/core/hle/service/caps/caps_manager.cpp index c68fe5152..261fc204c 100755 --- a/src/core/hle/service/caps/caps_manager.cpp +++ b/src/core/hle/service/caps/caps_manager.cpp @@ -10,11 +10,8 @@ #include "core/core.h" #include "core/hle/service/caps/caps_manager.h" #include "core/hle/service/caps/caps_result.h" -#include "core/hle/service/psc/time/static.h" -#include "core/hle/service/psc/time/system_clock.h" -#include "core/hle/service/psc/time/time_zone_service.h" -#include "core/hle/service/service.h" -#include "core/hle/service/sm/sm.h" +#include "core/hle/service/time/time_manager.h" +#include "core/hle/service/time/time_zone_content_manager.h" namespace Service::Capture { @@ -242,15 +239,10 @@ Result AlbumManager::SaveScreenShot(ApplicationAlbumEntry& out_entry, const ApplicationData& app_data, std::span image_data, u64 aruid) { const u64 title_id = system.GetApplicationProcessProgramID(); - - auto static_service = - system.ServiceManager().GetService("time:u", true); - - std::shared_ptr user_clock{}; - static_service->GetStandardUserSystemClock(user_clock); + const auto& user_clock = system.GetTimeManager().GetStandardUserSystemClockCore(); s64 posix_time{}; - auto result = user_clock->GetCurrentTime(posix_time); + Result result = user_clock.GetCurrentTime(system, posix_time); if (result.IsError()) { return result; @@ -265,14 +257,10 @@ Result AlbumManager::SaveEditedScreenShot(ApplicationAlbumEntry& out_entry, const ScreenShotAttribute& attribute, const AlbumFileId& file_id, std::span image_data) { - auto static_service = - system.ServiceManager().GetService("time:u", true); - - std::shared_ptr user_clock{}; - static_service->GetStandardUserSystemClock(user_clock); + const auto& user_clock = system.GetTimeManager().GetStandardUserSystemClockCore(); s64 posix_time{}; - auto result = user_clock->GetCurrentTime(posix_time); + Result result = user_clock.GetCurrentTime(system, posix_time); if (result.IsError()) { return result; @@ -467,23 +455,19 @@ Result AlbumManager::SaveImage(ApplicationAlbumEntry& out_entry, std::span("time:u", true); + Time::TimeZone::CalendarInfo calendar_date{}; + const auto& time_zone_manager = + system.GetTimeManager().GetTimeZoneContentManager().GetTimeZoneManager(); - std::shared_ptr timezone_service{}; - static_service->GetTimeZoneService(timezone_service); - - Service::PSC::Time::CalendarTime calendar_time{}; - Service::PSC::Time::CalendarAdditionalInfo additional_info{}; - timezone_service->ToCalendarTimeWithMyRule(calendar_time, additional_info, posix_time); + time_zone_manager.ToCalendarTimeWithMyRules(posix_time, calendar_date); return { - .year = calendar_time.year, - .month = calendar_time.month, - .day = calendar_time.day, - .hour = calendar_time.hour, - .minute = calendar_time.minute, - .second = calendar_time.second, + .year = calendar_date.time.year, + .month = calendar_date.time.month, + .day = calendar_date.time.day, + .hour = calendar_date.time.hour, + .minute = calendar_date.time.minute, + .second = calendar_date.time.second, .unique_id = 0, }; } diff --git a/src/core/hle/service/glue/glue.cpp b/src/core/hle/service/glue/glue.cpp index 66b684c30..a996f58cf 100755 --- a/src/core/hle/service/glue/glue.cpp +++ b/src/core/hle/service/glue/glue.cpp @@ -8,9 +8,6 @@ #include "core/hle/service/glue/ectx.h" #include "core/hle/service/glue/glue.h" #include "core/hle/service/glue/notif.h" -#include "core/hle/service/glue/time/manager.h" -#include "core/hle/service/glue/time/static.h" -#include "core/hle/service/psc/time/common.h" #include "core/hle/service/server_manager.h" namespace Service::Glue { @@ -34,22 +31,6 @@ void LoopProcess(Core::System& system) { // Notification Services for application server_manager->RegisterNamedService("notif:a", std::make_shared(system)); - // Time - auto time = std::make_shared(system); - - server_manager->RegisterNamedService( - "time:u", - std::make_shared( - system, Service::PSC::Time::StaticServiceSetupInfo{0, 0, 0, 0, 0, 0}, time, "time:u")); - server_manager->RegisterNamedService( - "time:a", - std::make_shared( - system, Service::PSC::Time::StaticServiceSetupInfo{1, 1, 0, 1, 0, 0}, time, "time:a")); - server_manager->RegisterNamedService( - "time:r", - std::make_shared( - system, Service::PSC::Time::StaticServiceSetupInfo{0, 0, 0, 0, 1, 0}, time, "time:r")); - ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/kernel_helpers.cpp b/src/core/hle/service/kernel_helpers.cpp index ed8587ffd..95f85d83e 100755 --- a/src/core/hle/service/kernel_helpers.cpp +++ b/src/core/hle/service/kernel_helpers.cpp @@ -65,9 +65,6 @@ Kernel::KEvent* ServiceContext::CreateEvent(std::string&& name) { } void ServiceContext::CloseEvent(Kernel::KEvent* event) { - if (!event) { - return; - } event->GetReadableEvent().Close(); event->Close(); } diff --git a/src/core/hle/service/nfc/common/device.cpp b/src/core/hle/service/nfc/common/device.cpp index ae51a8408..31cc87acc 100755 --- a/src/core/hle/service/nfc/common/device.cpp +++ b/src/core/hle/service/nfc/common/device.cpp @@ -29,11 +29,7 @@ #include "core/hle/service/nfc/common/device.h" #include "core/hle/service/nfc/mifare_result.h" #include "core/hle/service/nfc/nfc_result.h" -#include "core/hle/service/psc/time/static.h" -#include "core/hle/service/psc/time/steady_clock.h" -#include "core/hle/service/psc/time/time_zone_service.h" -#include "core/hle/service/service.h" -#include "core/hle/service/sm/sm.h" +#include "core/hle/service/time/time_manager.h" #include "hid_core/frontend/emulated_controller.h" #include "hid_core/hid_core.h" #include "hid_core/hid_types.h" @@ -397,7 +393,8 @@ Result NfcDevice::WriteMifare(std::span paramet return result; } -Result NfcDevice::SendCommandByPassThrough(const s64& timeout, std::span command_data, +Result NfcDevice::SendCommandByPassThrough(const Time::Clock::TimeSpanType& timeout, + std::span command_data, std::span out_data) { // Not implemented return ResultSuccess; @@ -1399,41 +1396,27 @@ void NfcDevice::SetAmiiboName(NFP::AmiiboSettings& settings, } NFP::AmiiboDate NfcDevice::GetAmiiboDate(s64 posix_time) const { - auto static_service = - system.ServiceManager().GetService("time:u", true); - - std::shared_ptr timezone_service{}; - static_service->GetTimeZoneService(timezone_service); - - Service::PSC::Time::CalendarTime calendar_time{}; - Service::PSC::Time::CalendarAdditionalInfo additional_info{}; - + const auto& time_zone_manager = + system.GetTimeManager().GetTimeZoneContentManager().GetTimeZoneManager(); + Time::TimeZone::CalendarInfo calendar_info{}; NFP::AmiiboDate amiibo_date{}; amiibo_date.SetYear(2000); amiibo_date.SetMonth(1); amiibo_date.SetDay(1); - if (timezone_service->ToCalendarTimeWithMyRule(calendar_time, additional_info, posix_time) == - ResultSuccess) { - amiibo_date.SetYear(calendar_time.year); - amiibo_date.SetMonth(calendar_time.month); - amiibo_date.SetDay(calendar_time.day); + if (time_zone_manager.ToCalendarTime({}, posix_time, calendar_info) == ResultSuccess) { + amiibo_date.SetYear(calendar_info.time.year); + amiibo_date.SetMonth(calendar_info.time.month); + amiibo_date.SetDay(calendar_info.time.day); } return amiibo_date; } -s64 NfcDevice::GetCurrentPosixTime() const { - auto static_service = - system.ServiceManager().GetService("time:u", true); - - std::shared_ptr steady_clock{}; - static_service->GetStandardSteadyClock(steady_clock); - - Service::PSC::Time::SteadyClockTimePoint time_point{}; - R_ASSERT(steady_clock->GetCurrentTimePoint(time_point)); - return time_point.time_point; +u64 NfcDevice::GetCurrentPosixTime() const { + auto& standard_steady_clock{system.GetTimeManager().GetStandardSteadyClockCore()}; + return standard_steady_clock.GetCurrentTimePoint(system).time_point; } u64 NfcDevice::RemoveVersionByte(u64 application_id) const { diff --git a/src/core/hle/service/nfc/common/device.h b/src/core/hle/service/nfc/common/device.h index d59202d18..15f9b25da 100755 --- a/src/core/hle/service/nfc/common/device.h +++ b/src/core/hle/service/nfc/common/device.h @@ -11,6 +11,7 @@ #include "core/hle/service/nfc/nfc_types.h" #include "core/hle/service/nfp/nfp_types.h" #include "core/hle/service/service.h" +#include "core/hle/service/time/clock_types.h" namespace Kernel { class KEvent; @@ -48,8 +49,8 @@ public: Result WriteMifare(std::span parameters); - Result SendCommandByPassThrough(const s64& timeout, std::span command_data, - std::span out_data); + Result SendCommandByPassThrough(const Time::Clock::TimeSpanType& timeout, + std::span command_data, std::span out_data); Result Mount(NFP::ModelType model_type, NFP::MountTarget mount_target); Result Unmount(); @@ -107,7 +108,7 @@ private: NFP::AmiiboName GetAmiiboName(const NFP::AmiiboSettings& settings) const; void SetAmiiboName(NFP::AmiiboSettings& settings, const NFP::AmiiboName& amiibo_name) const; NFP::AmiiboDate GetAmiiboDate(s64 posix_time) const; - s64 GetCurrentPosixTime() const; + u64 GetCurrentPosixTime() const; u64 RemoveVersionByte(u64 application_id) const; void UpdateSettingsCrc(); void UpdateRegisterInfoCrc(); diff --git a/src/core/hle/service/nfc/common/device_manager.cpp b/src/core/hle/service/nfc/common/device_manager.cpp index fd2566fb3..44f651b87 100755 --- a/src/core/hle/service/nfc/common/device_manager.cpp +++ b/src/core/hle/service/nfc/common/device_manager.cpp @@ -10,10 +10,8 @@ #include "core/hle/service/nfc/common/device.h" #include "core/hle/service/nfc/common/device_manager.h" #include "core/hle/service/nfc/nfc_result.h" -#include "core/hle/service/psc/time/static.h" -#include "core/hle/service/psc/time/steady_clock.h" -#include "core/hle/service/service.h" -#include "core/hle/service/sm/sm.h" +#include "core/hle/service/time/clock_types.h" +#include "core/hle/service/time/time_manager.h" #include "hid_core/hid_types.h" #include "hid_core/hid_util.h" @@ -84,19 +82,11 @@ Result DeviceManager::ListDevices(std::vector& nfp_devices, std::size_t max continue; } if (skip_fatal_errors) { - constexpr s64 MinimumRecoveryTime = 60; + constexpr u64 MinimumRecoveryTime = 60; + auto& standard_steady_clock{system.GetTimeManager().GetStandardSteadyClockCore()}; + const u64 elapsed_time = standard_steady_clock.GetCurrentTimePoint(system).time_point - + time_since_last_error; - auto static_service = - system.ServiceManager().GetService("time:u", - true); - - std::shared_ptr steady_clock{}; - static_service->GetStandardSteadyClock(steady_clock); - - Service::PSC::Time::SteadyClockTimePoint time_point{}; - R_ASSERT(steady_clock->GetCurrentTimePoint(time_point)); - - const s64 elapsed_time = time_point.time_point - time_since_last_error; if (time_since_last_error != 0 && elapsed_time < MinimumRecoveryTime) { continue; } @@ -260,7 +250,8 @@ Result DeviceManager::WriteMifare(u64 device_handle, return result; } -Result DeviceManager::SendCommandByPassThrough(u64 device_handle, const s64& timeout, +Result DeviceManager::SendCommandByPassThrough(u64 device_handle, + const Time::Clock::TimeSpanType& timeout, std::span command_data, std::span out_data) { std::scoped_lock lock{mutex}; @@ -750,16 +741,8 @@ Result DeviceManager::VerifyDeviceResult(std::shared_ptr device, if (operation_result == ResultUnknown112 || operation_result == ResultUnknown114 || operation_result == ResultUnknown115) { - auto static_service = - system.ServiceManager().GetService("time:u", true); - - std::shared_ptr steady_clock{}; - static_service->GetStandardSteadyClock(steady_clock); - - Service::PSC::Time::SteadyClockTimePoint time_point{}; - R_ASSERT(steady_clock->GetCurrentTimePoint(time_point)); - - time_since_last_error = time_point.time_point; + auto& standard_steady_clock{system.GetTimeManager().GetStandardSteadyClockCore()}; + time_since_last_error = standard_steady_clock.GetCurrentTimePoint(system).time_point; } return operation_result; diff --git a/src/core/hle/service/nfc/common/device_manager.h b/src/core/hle/service/nfc/common/device_manager.h index c56a2fbda..f02bdccf5 100755 --- a/src/core/hle/service/nfc/common/device_manager.h +++ b/src/core/hle/service/nfc/common/device_manager.h @@ -13,6 +13,7 @@ #include "core/hle/service/nfc/nfc_types.h" #include "core/hle/service/nfp/nfp_types.h" #include "core/hle/service/service.h" +#include "core/hle/service/time/clock_types.h" #include "hid_core/hid_types.h" namespace Service::NFC { @@ -41,7 +42,7 @@ public: std::span read_data); Result WriteMifare(u64 device_handle, std::span write_parameters); - Result SendCommandByPassThrough(u64 device_handle, const s64& timeout, + Result SendCommandByPassThrough(u64 device_handle, const Time::Clock::TimeSpanType& timeout, std::span command_data, std::span out_data); // Nfp device manager @@ -91,7 +92,7 @@ private: const std::optional> GetNfcDevice(u64 handle) const; bool is_initialized = false; - s64 time_since_last_error = 0; + u64 time_since_last_error = 0; mutable std::mutex mutex; std::array, 10> devices{}; diff --git a/src/core/hle/service/nfc/nfc_interface.cpp b/src/core/hle/service/nfc/nfc_interface.cpp index 207ac4efe..a71cf74b8 100755 --- a/src/core/hle/service/nfc/nfc_interface.cpp +++ b/src/core/hle/service/nfc/nfc_interface.cpp @@ -13,6 +13,7 @@ #include "core/hle/service/nfc/nfc_result.h" #include "core/hle/service/nfc/nfc_types.h" #include "core/hle/service/nfp/nfp_result.h" +#include "core/hle/service/time/clock_types.h" #include "hid_core/hid_types.h" namespace Service::NFC { @@ -260,10 +261,10 @@ void NfcInterface::WriteMifare(HLERequestContext& ctx) { void NfcInterface::SendCommandByPassThrough(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; - const auto timeout{rp.PopRaw()}; + const auto timeout{rp.PopRaw()}; const auto command_data{ctx.ReadBuffer()}; LOG_INFO(Service_NFC, "(STUBBED) called, device_handle={}, timeout={}, data_size={}", - device_handle, timeout, command_data.size()); + device_handle, timeout.ToSeconds(), command_data.size()); std::vector out_data(1); auto result = diff --git a/src/core/hle/service/ns/language.cpp b/src/core/hle/service/ns/language.cpp index 3dad98c32..303f754ef 100755 --- a/src/core/hle/service/ns/language.cpp +++ b/src/core/hle/service/ns/language.cpp @@ -415,4 +415,4 @@ std::optional ConvertToLanguageCode(const ApplicationLanguage return std::nullopt; } } -} // namespace Service::NS +} // namespace Service::NS \ No newline at end of file diff --git a/src/core/hle/service/ns/language.h b/src/core/hle/service/ns/language.h index 7a54265c7..11e5cfda7 100755 --- a/src/core/hle/service/ns/language.h +++ b/src/core/hle/service/ns/language.h @@ -5,7 +5,10 @@ #include #include "common/common_types.h" -#include "core/hle/service/set/system_settings.h" + +namespace Service::Set { +enum class LanguageCode : u64; +} namespace Service::NS { /// This is nn::ns::detail::ApplicationLanguage diff --git a/src/core/hle/service/nvnflinger/nvnflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp index c74bcfe2e..e4b38ae0b 100755 --- a/src/core/hle/service/nvnflinger/nvnflinger.cpp +++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp @@ -223,7 +223,8 @@ Result Nvnflinger::FindVsyncEvent(Kernel::KReadableEvent** out_vsync_event, u64 return VI::ResultNotFound; } - return display->GetVSyncEvent(out_vsync_event); + *out_vsync_event = display->GetVSyncEvent(); + return ResultSuccess; } VI::Display* Nvnflinger::FindDisplay(u64 display_id) { diff --git a/src/core/hle/service/psc/psc.cpp b/src/core/hle/service/psc/psc.cpp index 94eaa566a..ec1be0a55 100755 --- a/src/core/hle/service/psc/psc.cpp +++ b/src/core/hle/service/psc/psc.cpp @@ -4,13 +4,9 @@ #include #include "common/logging/log.h" -#include "core/core.h" #include "core/hle/service/ipc_helpers.h" #include "core/hle/service/psc/psc.h" -#include "core/hle/service/psc/time/manager.h" -#include "core/hle/service/psc/time/power_state_service.h" -#include "core/hle/service/psc/time/service_manager.h" -#include "core/hle/service/psc/time/static.h" +#include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" namespace Service::PSC { @@ -80,17 +76,6 @@ void LoopProcess(Core::System& system) { server_manager->RegisterNamedService("psc:c", std::make_shared(system)); server_manager->RegisterNamedService("psc:m", std::make_shared(system)); - - auto time = std::make_shared(system); - - server_manager->RegisterNamedService( - "time:m", std::make_shared(system, time, server_manager.get())); - server_manager->RegisterNamedService( - "time:su", std::make_shared( - system, Time::StaticServiceSetupInfo{0, 0, 0, 0, 0, 1}, time, "time:su")); - server_manager->RegisterNamedService("time:al", - std::make_shared(system, time)); - ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index e47929bf8..e2060f5f7 100755 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -66,6 +66,7 @@ #include "core/hle/service/sockets/sockets.h" #include "core/hle/service/spl/spl_module.h" #include "core/hle/service/ssl/ssl.h" +#include "core/hle/service/time/time.h" #include "core/hle/service/usb/usb.h" #include "core/hle/service/vi/vi.h" #include "core/reporter.h" @@ -245,9 +246,6 @@ Services::Services(std::shared_ptr& sm, Core::System& system kernel.RunOnGuestCoreProcess("fatal", [&] { Fatal::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("fgm", [&] { FGM::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("friends", [&] { Friend::LoopProcess(system); }); - // glue depends on settings and psc, so they must come first - kernel.RunOnGuestCoreProcess("settings", [&] { Set::LoopProcess(system); }); - kernel.RunOnGuestCoreProcess("psc", [&] { PSC::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("glue", [&] { Glue::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("grc", [&] { GRC::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("hid", [&] { HID::LoopProcess(system); }); @@ -271,10 +269,13 @@ Services::Services(std::shared_ptr& sm, Core::System& system kernel.RunOnGuestCoreProcess("pcv", [&] { PCV::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("prepo", [&] { PlayReport::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("ProcessManager", [&] { PM::LoopProcess(system); }); + kernel.RunOnGuestCoreProcess("psc", [&] { PSC::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("ptm", [&] { PTM::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("ro", [&] { RO::LoopProcess(system); }); + kernel.RunOnGuestCoreProcess("settings", [&] { Set::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("spl", [&] { SPL::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("ssl", [&] { SSL::LoopProcess(system); }); + kernel.RunOnGuestCoreProcess("time", [&] { Time::LoopProcess(system); }); kernel.RunOnGuestCoreProcess("usb", [&] { USB::LoopProcess(system); }); // clang-format on } diff --git a/src/core/hle/service/set/private_settings.h b/src/core/hle/service/set/private_settings.h index b02291ce7..b63eaf45c 100755 --- a/src/core/hle/service/set/private_settings.h +++ b/src/core/hle/service/set/private_settings.h @@ -9,7 +9,7 @@ #include "common/common_funcs.h" #include "common/common_types.h" #include "common/uuid.h" -#include "core/hle/service/psc/time/common.h" +#include "core/hle/service/time/clock_types.h" namespace Service::Set { @@ -29,14 +29,14 @@ static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid s struct InitialLaunchSettings { InitialLaunchFlag flags; INSERT_PADDING_BYTES(0x4); - Service::PSC::Time::SteadyClockTimePoint timestamp; + Service::Time::Clock::SteadyClockTimePoint timestamp; }; static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size"); #pragma pack(push, 4) struct InitialLaunchSettingsPacked { InitialLaunchFlag flags; - Service::PSC::Time::SteadyClockTimePoint timestamp; + Service::Time::Clock::SteadyClockTimePoint timestamp; }; #pragma pack(pop) static_assert(sizeof(InitialLaunchSettingsPacked) == 0x1C, diff --git a/src/core/hle/service/set/system_settings.h b/src/core/hle/service/set/system_settings.h index b6793484d..6ec9e71e7 100755 --- a/src/core/hle/service/set/system_settings.h +++ b/src/core/hle/service/set/system_settings.h @@ -9,6 +9,7 @@ #include "common/common_funcs.h" #include "common/common_types.h" #include "core/hle/service/set/private_settings.h" +#include "core/hle/service/time/clock_types.h" namespace Service::Set { @@ -269,7 +270,7 @@ struct EulaVersion { EulaVersionClockType clock_type; INSERT_PADDING_BYTES(0x4); s64 posix_time; - Service::PSC::Time::SteadyClockTimePoint timestamp; + Time::Clock::SteadyClockTimePoint timestamp; }; static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size"); @@ -480,13 +481,13 @@ struct SystemSettings { std::array reserved_2951C; // nn::time::SystemClockContext - Service::PSC::Time::SystemClockContext user_system_clock_context; - Service::PSC::Time::SystemClockContext network_system_clock_context; + Service::Time::Clock::SystemClockContext user_system_clock_context; + Service::Time::Clock::SystemClockContext network_system_clock_context; bool user_system_clock_automatic_correction_enabled; std::array pad_295C1; std::array reserved_295C4; // nn::time::SteadyClockTimePoint - Service::PSC::Time::SteadyClockTimePoint + Service::Time::Clock::SteadyClockTimePoint user_system_clock_automatic_correction_updated_time_point; std::array reserved_295E0; @@ -579,10 +580,10 @@ struct SystemSettings { std::array reserved_29ED5; // nn::time::LocationName - Service::PSC::Time::LocationName device_time_zone_location_name; + Service::Time::TimeZone::LocationName device_time_zone_location_name; std::array reserved_29F64; // nn::time::SteadyClockTimePoint - Service::PSC::Time::SteadyClockTimePoint device_time_zone_location_updated_time; + Service::Time::Clock::SteadyClockTimePoint device_time_zone_location_updated_time; std::array reserved_29F80; diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp index fd9d279df..af9348522 100755 --- a/src/core/hle/service/set/system_settings_server.cpp +++ b/src/core/hle/service/set/system_settings_server.cpp @@ -489,10 +489,11 @@ void ISystemSettingsServer::SetExternalSteadyClockSourceId(HLERequestContext& ct void ISystemSettingsServer::GetUserSystemClockContext(HLERequestContext& ctx) { LOG_INFO(Service_SET, "called"); - Service::PSC::Time::SystemClockContext context{}; + Service::Time::Clock::SystemClockContext context{}; auto res = GetUserSystemClockContext(context); - IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::SystemClockContext) / sizeof(u32)}; + IPC::ResponseBuilder rb{ctx, + 2 + sizeof(Service::Time::Clock::SystemClockContext) / sizeof(u32)}; rb.Push(res); rb.PushRaw(context); } @@ -501,7 +502,7 @@ void ISystemSettingsServer::SetUserSystemClockContext(HLERequestContext& ctx) { LOG_INFO(Service_SET, "called"); IPC::RequestParser rp{ctx}; - auto context{rp.PopRaw()}; + auto context{rp.PopRaw()}; auto res = SetUserSystemClockContext(context); @@ -752,19 +753,19 @@ void ISystemSettingsServer::GetQuestFlag(HLERequestContext& ctx) { void ISystemSettingsServer::GetDeviceTimeZoneLocationName(HLERequestContext& ctx) { LOG_WARNING(Service_SET, "called"); - Service::PSC::Time::LocationName name{}; + Service::Time::TimeZone::LocationName name{}; auto res = GetDeviceTimeZoneLocationName(name); - IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::LocationName) / sizeof(u32)}; + IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::Time::TimeZone::LocationName) / sizeof(u32)}; rb.Push(res); - rb.PushRaw(name); + rb.PushRaw(name); } void ISystemSettingsServer::SetDeviceTimeZoneLocationName(HLERequestContext& ctx) { LOG_WARNING(Service_SET, "called"); IPC::RequestParser rp{ctx}; - auto name{rp.PopRaw()}; + auto name{rp.PopRaw()}; auto res = SetDeviceTimeZoneLocationName(name); @@ -786,10 +787,11 @@ void ISystemSettingsServer::SetRegionCode(HLERequestContext& ctx) { void ISystemSettingsServer::GetNetworkSystemClockContext(HLERequestContext& ctx) { LOG_INFO(Service_SET, "called"); - Service::PSC::Time::SystemClockContext context{}; + Service::Time::Clock::SystemClockContext context{}; auto res = GetNetworkSystemClockContext(context); - IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::SystemClockContext) / sizeof(u32)}; + IPC::ResponseBuilder rb{ctx, + 2 + sizeof(Service::Time::Clock::SystemClockContext) / sizeof(u32)}; rb.Push(res); rb.PushRaw(context); } @@ -798,7 +800,7 @@ void ISystemSettingsServer::SetNetworkSystemClockContext(HLERequestContext& ctx) LOG_INFO(Service_SET, "called"); IPC::RequestParser rp{ctx}; - auto context{rp.PopRaw()}; + auto context{rp.PopRaw()}; auto res = SetNetworkSystemClockContext(context); @@ -1014,19 +1016,19 @@ void ISystemSettingsServer::GetKeyboardLayout(HLERequestContext& ctx) { void ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) { LOG_WARNING(Service_SET, "called."); - Service::PSC::Time::SteadyClockTimePoint time_point{}; + Service::Time::Clock::SteadyClockTimePoint time_point{}; auto res = GetDeviceTimeZoneLocationUpdatedTime(time_point); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(res); - rb.PushRaw(time_point); + rb.PushRaw(time_point); } void ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) { LOG_WARNING(Service_SET, "called."); IPC::RequestParser rp{ctx}; - auto time_point{rp.PopRaw()}; + auto time_point{rp.PopRaw()}; auto res = SetDeviceTimeZoneLocationUpdatedTime(time_point); @@ -1038,12 +1040,12 @@ void ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime( HLERequestContext& ctx) { LOG_WARNING(Service_SET, "called."); - Service::PSC::Time::SteadyClockTimePoint time_point{}; + Service::Time::Clock::SteadyClockTimePoint time_point{}; auto res = GetUserSystemClockAutomaticCorrectionUpdatedTime(time_point); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(res); - rb.PushRaw(time_point); + rb.PushRaw(time_point); } void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime( @@ -1051,7 +1053,7 @@ void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime( LOG_WARNING(Service_SET, "called."); IPC::RequestParser rp{ctx}; - auto time_point{rp.PopRaw()}; + auto time_point{rp.PopRaw()}; auto res = SetUserSystemClockAutomaticCorrectionUpdatedTime(time_point); @@ -1129,25 +1131,25 @@ void ISystemSettingsServer::StoreSettings() { auto system_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000050"; if (!StoreSettingsFile(system_dir, m_system_settings)) { - LOG_ERROR(Service_SET, "Failed to store System settings"); + LOG_ERROR(HW_GPU, "Failed to store System settings"); } auto private_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000052"; if (!StoreSettingsFile(private_dir, m_private_settings)) { - LOG_ERROR(Service_SET, "Failed to store Private settings"); + LOG_ERROR(HW_GPU, "Failed to store Private settings"); } auto device_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000053"; if (!StoreSettingsFile(device_dir, m_device_settings)) { - LOG_ERROR(Service_SET, "Failed to store Device settings"); + LOG_ERROR(HW_GPU, "Failed to store Device settings"); } auto appln_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000054"; if (!StoreSettingsFile(appln_dir, m_appln_settings)) { - LOG_ERROR(Service_SET, "Failed to store ApplLn settings"); + LOG_ERROR(HW_GPU, "Failed to store ApplLn settings"); } } @@ -1190,39 +1192,39 @@ Result ISystemSettingsServer::SetExternalSteadyClockSourceId(Common::UUID id) { } Result ISystemSettingsServer::GetUserSystemClockContext( - Service::PSC::Time::SystemClockContext& out_context) { + Service::Time::Clock::SystemClockContext& out_context) { out_context = m_system_settings.user_system_clock_context; R_SUCCEED(); } Result ISystemSettingsServer::SetUserSystemClockContext( - Service::PSC::Time::SystemClockContext& context) { + Service::Time::Clock::SystemClockContext& context) { m_system_settings.user_system_clock_context = context; SetSaveNeeded(); R_SUCCEED(); } Result ISystemSettingsServer::GetDeviceTimeZoneLocationName( - Service::PSC::Time::LocationName& out_name) { + Service::Time::TimeZone::LocationName& out_name) { out_name = m_system_settings.device_time_zone_location_name; R_SUCCEED(); } Result ISystemSettingsServer::SetDeviceTimeZoneLocationName( - Service::PSC::Time::LocationName& name) { + Service::Time::TimeZone::LocationName& name) { m_system_settings.device_time_zone_location_name = name; SetSaveNeeded(); R_SUCCEED(); } Result ISystemSettingsServer::GetNetworkSystemClockContext( - Service::PSC::Time::SystemClockContext& out_context) { + Service::Time::Clock::SystemClockContext& out_context) { out_context = m_system_settings.network_system_clock_context; R_SUCCEED(); } Result ISystemSettingsServer::SetNetworkSystemClockContext( - Service::PSC::Time::SystemClockContext& context) { + Service::Time::Clock::SystemClockContext& context) { m_system_settings.network_system_clock_context = context; SetSaveNeeded(); R_SUCCEED(); @@ -1251,26 +1253,26 @@ Result ISystemSettingsServer::GetExternalSteadyClockInternalOffset(s64& out_offs } Result ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime( - Service::PSC::Time::SteadyClockTimePoint& out_time_point) { + Service::Time::Clock::SteadyClockTimePoint& out_time_point) { out_time_point = m_system_settings.device_time_zone_location_updated_time; R_SUCCEED(); } Result ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime( - Service::PSC::Time::SteadyClockTimePoint& time_point) { + Service::Time::Clock::SteadyClockTimePoint& time_point) { m_system_settings.device_time_zone_location_updated_time = time_point; SetSaveNeeded(); R_SUCCEED(); } Result ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime( - Service::PSC::Time::SteadyClockTimePoint& out_time_point) { + Service::Time::Clock::SteadyClockTimePoint& out_time_point) { out_time_point = m_system_settings.user_system_clock_automatic_correction_updated_time_point; R_SUCCEED(); } Result ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime( - Service::PSC::Time::SteadyClockTimePoint out_time_point) { + Service::Time::Clock::SteadyClockTimePoint out_time_point) { m_system_settings.user_system_clock_automatic_correction_updated_time_point = out_time_point; SetSaveNeeded(); R_SUCCEED(); diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.h index 833e6461d..6f587e0b3 100755 --- a/src/core/hle/service/set/system_settings_server.h +++ b/src/core/hle/service/set/system_settings_server.h @@ -11,12 +11,13 @@ #include "common/polyfill_thread.h" #include "common/uuid.h" #include "core/hle/result.h" -#include "core/hle/service/psc/time/common.h" #include "core/hle/service/service.h" #include "core/hle/service/set/appln_settings.h" #include "core/hle/service/set/device_settings.h" #include "core/hle/service/set/private_settings.h" #include "core/hle/service/set/system_settings.h" +#include "core/hle/service/time/clock_types.h" +#include "core/hle/service/time/time_zone_types.h" namespace Core { class System; @@ -56,24 +57,24 @@ public: Result GetExternalSteadyClockSourceId(Common::UUID& out_id); Result SetExternalSteadyClockSourceId(Common::UUID id); - Result GetUserSystemClockContext(Service::PSC::Time::SystemClockContext& out_context); - Result SetUserSystemClockContext(Service::PSC::Time::SystemClockContext& context); - Result GetDeviceTimeZoneLocationName(Service::PSC::Time::LocationName& out_name); - Result SetDeviceTimeZoneLocationName(Service::PSC::Time::LocationName& name); - Result GetNetworkSystemClockContext(Service::PSC::Time::SystemClockContext& out_context); - Result SetNetworkSystemClockContext(Service::PSC::Time::SystemClockContext& context); + Result GetUserSystemClockContext(Service::Time::Clock::SystemClockContext& out_context); + Result SetUserSystemClockContext(Service::Time::Clock::SystemClockContext& context); + Result GetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& out_name); + Result SetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& name); + Result GetNetworkSystemClockContext(Service::Time::Clock::SystemClockContext& out_context); + Result SetNetworkSystemClockContext(Service::Time::Clock::SystemClockContext& context); Result IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled); Result SetUserSystemClockAutomaticCorrectionEnabled(bool enabled); Result SetExternalSteadyClockInternalOffset(s64 offset); Result GetExternalSteadyClockInternalOffset(s64& out_offset); Result GetDeviceTimeZoneLocationUpdatedTime( - Service::PSC::Time::SteadyClockTimePoint& out_time_point); + Service::Time::Clock::SteadyClockTimePoint& out_time_point); Result SetDeviceTimeZoneLocationUpdatedTime( - Service::PSC::Time::SteadyClockTimePoint& time_point); + Service::Time::Clock::SteadyClockTimePoint& time_point); Result GetUserSystemClockAutomaticCorrectionUpdatedTime( - Service::PSC::Time::SteadyClockTimePoint& out_time_point); + Service::Time::Clock::SteadyClockTimePoint& out_time_point); Result SetUserSystemClockAutomaticCorrectionUpdatedTime( - Service::PSC::Time::SteadyClockTimePoint time_point); + Service::Time::Clock::SteadyClockTimePoint time_point); private: void SetLanguageCode(HLERequestContext& ctx); @@ -144,8 +145,8 @@ private: PrivateSettings m_private_settings{}; DeviceSettings m_device_settings{}; ApplnSettings m_appln_settings{}; - std::mutex m_save_needed_mutex; std::jthread m_save_thread; + std::mutex m_save_needed_mutex; bool m_save_needed{false}; }; diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 2401ce49c..d17813405 100755 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -3,7 +3,6 @@ #pragma once -#include #include #include #include @@ -11,7 +10,6 @@ #include "common/concepts.h" #include "core/hle/kernel/k_port.h" -#include "core/hle/kernel/svc.h" #include "core/hle/result.h" #include "core/hle/service/service.h" @@ -64,21 +62,12 @@ public: Result GetServicePort(Kernel::KClientPort** out_client_port, const std::string& name); template T> - std::shared_ptr GetService(const std::string& service_name, bool block = false) const { + std::shared_ptr GetService(const std::string& service_name) const { auto service = registered_services.find(service_name); - if (service == registered_services.end() && !block) { + if (service == registered_services.end()) { LOG_DEBUG(Service, "Can't find service: {}", service_name); return nullptr; - } else if (block) { - using namespace std::literals::chrono_literals; - while (service == registered_services.end()) { - Kernel::Svc::SleepThread( - kernel.System(), - std::chrono::duration_cast(100ms).count()); - service = registered_services.find(service_name); - } } - return std::static_pointer_cast(service->second()); } diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index 144ef2cc8..901ede743 100755 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -71,18 +71,7 @@ size_t Display::GetNumLayers() const { return std::ranges::count_if(layers, [](auto& l) { return l->IsOpen(); }); } -Result Display::GetVSyncEvent(Kernel::KReadableEvent** out_vsync_event) { - if (got_vsync_event) { - return ResultPermissionDenied; - } - - got_vsync_event = true; - - *out_vsync_event = GetVSyncEventUnchecked(); - return ResultSuccess; -} - -Kernel::KReadableEvent* Display::GetVSyncEventUnchecked() { +Kernel::KReadableEvent* Display::GetVSyncEvent() { return &vsync_event->GetReadableEvent(); } diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 7705965dd..224ec87d0 100755 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -74,16 +74,8 @@ public: std::size_t GetNumLayers() const; - /** - * Gets the internal vsync event. - * - * @returns The internal Vsync event if it has not yet been retrieved, - * VI::ResultPermissionDenied otherwise. - */ - [[nodiscard]] Result GetVSyncEvent(Kernel::KReadableEvent** out_vsync_event); - /// Gets the internal vsync event. - Kernel::KReadableEvent* GetVSyncEventUnchecked(); + Kernel::KReadableEvent* GetVSyncEvent(); /// Signals the internal vsync event. void SignalVSyncEvent(); @@ -104,7 +96,6 @@ public: /// Resets the display for a new connection. void Reset() { layers.clear(); - got_vsync_event = false; } /// Attempts to find a layer with the given ID. @@ -133,7 +124,6 @@ private: std::vector> layers; Kernel::KEvent* vsync_event{}; - bool got_vsync_event{false}; }; } // namespace Service::VI diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 7c58c184e..6205b42b0 100755 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -343,8 +343,8 @@ private: class IManagerDisplayService final : public ServiceFramework { public: - explicit IManagerDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_) - : ServiceFramework{system_, "IManagerDisplayService"}, nv_flinger{nv_flinger_} { + explicit IManagerDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_) + : ServiceFramework{system_, "IManagerDisplayService"}, nvnflinger{nvnflinger_} { // clang-format off static const FunctionInfo functions[] = { {200, nullptr, "AllocateProcessHeapBlock"}, @@ -440,7 +440,7 @@ private: IPC::RequestParser rp{ctx}; const u64 display = rp.Pop(); - const Result rc = nv_flinger.CloseDisplay(display) ? ResultSuccess : ResultUnknown; + const Result rc = nvnflinger.CloseDisplay(display) ? ResultSuccess : ResultUnknown; IPC::ResponseBuilder rb{ctx, 2}; rb.Push(rc); @@ -457,7 +457,7 @@ private: "(STUBBED) called. unknown=0x{:08X}, display=0x{:016X}, aruid=0x{:016X}", unknown, display, aruid); - const auto layer_id = nv_flinger.CreateLayer(display); + const auto layer_id = nvnflinger.CreateLayer(display); if (!layer_id) { LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display); IPC::ResponseBuilder rb{ctx, 2}; @@ -494,14 +494,14 @@ private: rb.Push(ResultSuccess); } - Nvnflinger::Nvnflinger& nv_flinger; + Nvnflinger::Nvnflinger& nvnflinger; }; class IApplicationDisplayService final : public ServiceFramework { public: - IApplicationDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, + IApplicationDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_, Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_) - : ServiceFramework{system_, "IApplicationDisplayService"}, nv_flinger{nv_flinger_}, + : ServiceFramework{system_, "IApplicationDisplayService"}, nvnflinger{nvnflinger_}, hos_binder_driver_server{hos_binder_driver_server_} { static const FunctionInfo functions[] = { @@ -564,7 +564,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface(system, nv_flinger); + rb.PushIpcInterface(system, nvnflinger); } void GetManagerDisplayService(HLERequestContext& ctx) { @@ -572,7 +572,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface(system, nv_flinger); + rb.PushIpcInterface(system, nvnflinger); } void GetIndirectDisplayTransactionService(HLERequestContext& ctx) { @@ -607,7 +607,7 @@ private: ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet"); - const auto display_id = nv_flinger.OpenDisplay(name); + const auto display_id = nvnflinger.OpenDisplay(name); if (!display_id) { LOG_ERROR(Service_VI, "Display not found! display_name={}", name); IPC::ResponseBuilder rb{ctx, 2}; @@ -624,7 +624,7 @@ private: IPC::RequestParser rp{ctx}; const u64 display_id = rp.Pop(); - const Result rc = nv_flinger.CloseDisplay(display_id) ? ResultSuccess : ResultUnknown; + const Result rc = nvnflinger.CloseDisplay(display_id) ? ResultSuccess : ResultUnknown; IPC::ResponseBuilder rb{ctx, 2}; rb.Push(rc); @@ -703,7 +703,7 @@ private: LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}, aruid=0x{:016X}", layer_id, aruid); - const auto display_id = nv_flinger.OpenDisplay(display_name); + const auto display_id = nvnflinger.OpenDisplay(display_name); if (!display_id) { LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id); IPC::ResponseBuilder rb{ctx, 2}; @@ -711,7 +711,7 @@ private: return; } - const auto buffer_queue_id = nv_flinger.FindBufferQueueId(*display_id, layer_id); + const auto buffer_queue_id = nvnflinger.FindBufferQueueId(*display_id, layer_id); if (!buffer_queue_id) { LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id); IPC::ResponseBuilder rb{ctx, 2}; @@ -719,7 +719,7 @@ private: return; } - nv_flinger.OpenLayer(layer_id); + nvnflinger.OpenLayer(layer_id); android::OutputParcel parcel; parcel.WriteInterface(NativeWindow{*buffer_queue_id}); @@ -737,7 +737,7 @@ private: LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}", layer_id); - nv_flinger.CloseLayer(layer_id); + nvnflinger.CloseLayer(layer_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); @@ -753,7 +753,7 @@ private: // TODO(Subv): What's the difference between a Stray and a Managed layer? - const auto layer_id = nv_flinger.CreateLayer(display_id); + const auto layer_id = nvnflinger.CreateLayer(display_id); if (!layer_id) { LOG_ERROR(Service_VI, "Layer not found! display_id={}", display_id); IPC::ResponseBuilder rb{ctx, 2}; @@ -761,7 +761,7 @@ private: return; } - const auto buffer_queue_id = nv_flinger.FindBufferQueueId(display_id, *layer_id); + const auto buffer_queue_id = nvnflinger.FindBufferQueueId(display_id, *layer_id); if (!buffer_queue_id) { LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id); IPC::ResponseBuilder rb{ctx, 2}; @@ -785,7 +785,7 @@ private: const u64 layer_id = rp.Pop(); LOG_WARNING(Service_VI, "(STUBBED) called. layer_id=0x{:016X}", layer_id); - nv_flinger.DestroyLayer(layer_id); + nvnflinger.DestroyLayer(layer_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); @@ -798,7 +798,7 @@ private: LOG_DEBUG(Service_VI, "called. display_id={}", display_id); Kernel::KReadableEvent* vsync_event{}; - const auto result = nv_flinger.FindVsyncEvent(&vsync_event, display_id); + const auto result = nvnflinger.FindVsyncEvent(&vsync_event, display_id); if (result != ResultSuccess) { if (result == ResultNotFound) { LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id); @@ -808,6 +808,12 @@ private: rb.Push(result); return; } + if (vsync_event_fetched) { + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(VI::ResultPermissionDenied); + return; + } + vsync_event_fetched = true; IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(ResultSuccess); @@ -899,8 +905,9 @@ private: } } - Nvnflinger::Nvnflinger& nv_flinger; + Nvnflinger::Nvnflinger& nvnflinger; Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; + bool vsync_event_fetched{false}; }; static bool IsValidServiceAccess(Permission permission, Policy policy) { @@ -916,7 +923,7 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) { } void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system, - Nvnflinger::Nvnflinger& nv_flinger, + Nvnflinger::Nvnflinger& nvnflinger, Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, Permission permission) { IPC::RequestParser rp{ctx}; @@ -931,19 +938,19 @@ void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system, IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface(system, nv_flinger, hos_binder_driver_server); + rb.PushIpcInterface(system, nvnflinger, hos_binder_driver_server); } -void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nv_flinger, +void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) { auto server_manager = std::make_unique(system); server_manager->RegisterNamedService( - "vi:m", std::make_shared(system, nv_flinger, hos_binder_driver_server)); + "vi:m", std::make_shared(system, nvnflinger, hos_binder_driver_server)); server_manager->RegisterNamedService( - "vi:s", std::make_shared(system, nv_flinger, hos_binder_driver_server)); + "vi:s", std::make_shared(system, nvnflinger, hos_binder_driver_server)); server_manager->RegisterNamedService( - "vi:u", std::make_shared(system, nv_flinger, hos_binder_driver_server)); + "vi:u", std::make_shared(system, nvnflinger, hos_binder_driver_server)); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h index fc851defa..25e0aed66 100755 --- a/src/core/hle/service/vi/vi.h +++ b/src/core/hle/service/vi/vi.h @@ -48,7 +48,7 @@ void GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system, Permission permission); } // namespace detail -void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nv_flinger, +void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, Nvnflinger::HosBinderDriverServer& hos_binder_driver_server); } // namespace Service::VI diff --git a/src/tests/video_core/memory_tracker.cpp b/src/tests/video_core/memory_tracker.cpp index 45b1a91dc..0e559a590 100755 --- a/src/tests/video_core/memory_tracker.cpp +++ b/src/tests/video_core/memory_tracker.cpp @@ -545,4 +545,4 @@ TEST_CASE("MemoryTracker: Cached write downloads") { REQUIRE(!memory_track->IsRegionGpuModified(c + PAGE, PAGE)); memory_track->MarkRegionAsCpuModified(c, WORD); REQUIRE(rasterizer.Count() == 0); -} +} \ No newline at end of file diff --git a/src/video_core/query_cache/query_base.h b/src/video_core/query_cache/query_base.h index d5d21beaa..aca6a6447 100755 --- a/src/video_core/query_cache/query_base.h +++ b/src/video_core/query_cache/query_base.h @@ -67,4 +67,4 @@ public: size_t size_slots{}; }; -} // namespace VideoCommon +} // namespace VideoCommon \ No newline at end of file diff --git a/src/video_core/query_cache/query_cache_base.h b/src/video_core/query_cache/query_cache_base.h index 00c25c8d6..c12fb75ef 100755 --- a/src/video_core/query_cache/query_cache_base.h +++ b/src/video_core/query_cache/query_cache_base.h @@ -175,4 +175,4 @@ protected: std::unique_ptr impl; }; -} // namespace VideoCommon +} // namespace VideoCommon \ No newline at end of file diff --git a/src/video_core/query_cache/query_stream.h b/src/video_core/query_cache/query_stream.h index 1d11b1275..d9040acd2 100755 --- a/src/video_core/query_cache/query_stream.h +++ b/src/video_core/query_cache/query_stream.h @@ -146,4 +146,4 @@ protected: std::deque old_queries; }; -} // namespace VideoCommon +} // namespace VideoCommon \ No newline at end of file diff --git a/src/video_core/query_cache/types.h b/src/video_core/query_cache/types.h index 0c6a882e2..e9226bbfc 100755 --- a/src/video_core/query_cache/types.h +++ b/src/video_core/query_cache/types.h @@ -71,4 +71,4 @@ enum class ReductionOp : u32 { MaxReductionOp, }; -} // namespace VideoCommon +} // namespace VideoCommon \ No newline at end of file diff --git a/src/video_core/rasterizer_download_area.h b/src/video_core/rasterizer_download_area.h index d28826043..2d7425c79 100755 --- a/src/video_core/rasterizer_download_area.h +++ b/src/video_core/rasterizer_download_area.h @@ -13,4 +13,4 @@ struct RasterizerDownloadArea { bool preemtive; }; -} // namespace VideoCore +} // namespace VideoCore \ No newline at end of file diff --git a/src/video_core/renderer_vulkan/vk_descriptor_pool.h b/src/video_core/renderer_vulkan/vk_descriptor_pool.h index 6c6b5e0cb..c8a0e0171 100755 --- a/src/video_core/renderer_vulkan/vk_descriptor_pool.h +++ b/src/video_core/renderer_vulkan/vk_descriptor_pool.h @@ -84,4 +84,4 @@ private: std::vector> banks; }; -} // namespace Vulkan +} // namespace Vulkan \ No newline at end of file diff --git a/src/video_core/texture_cache/accelerated_swizzle.cpp b/src/video_core/texture_cache/accelerated_swizzle.cpp index 551f9ba48..21dae8394 100755 --- a/src/video_core/texture_cache/accelerated_swizzle.cpp +++ b/src/video_core/texture_cache/accelerated_swizzle.cpp @@ -66,4 +66,4 @@ BlockLinearSwizzle3DParams MakeBlockLinearSwizzle3DParams(const SwizzleParameter }; } -} // namespace VideoCommon::Accelerated +} // namespace VideoCommon::Accelerated \ No newline at end of file diff --git a/src/yuzu/configuration/configure_ringcon.cpp b/src/yuzu/configuration/configure_ringcon.cpp index 656106e38..94cfd48b1 100755 --- a/src/yuzu/configuration/configure_ringcon.cpp +++ b/src/yuzu/configuration/configure_ringcon.cpp @@ -494,4 +494,4 @@ QString ConfigureRingController::AnalogToText(const Common::ParamPackage& param, } return QObject::tr("[unknown]"); -} +} \ No newline at end of file diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 2c4180f57..0042fb314 100755 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -14,6 +14,7 @@ #include #include "common/settings.h" #include "core/core.h" +#include "core/hle/service/time/time_manager.h" #include "ui_configure_system.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_system.h" diff --git a/src/yuzu/debugger/console.h b/src/yuzu/debugger/console.h index 83102f3d6..767f5a7d1 100755 --- a/src/yuzu/debugger/console.h +++ b/src/yuzu/debugger/console.h @@ -10,4 +10,4 @@ namespace Debugger { * get a real qt logging window which would work for all platforms. */ void ToggleConsole(); -} // namespace Debugger +} // namespace Debugger \ No newline at end of file