From c4f4412df9c7f8ab0078fb613ce014179ea2c001 Mon Sep 17 00:00:00 2001 From: The-Little-Wolf <116989599+The-Little-Wolf@users.noreply.github.com> Date: Fri, 20 Mar 2026 14:49:03 -0700 Subject: [PATCH] [Xam/Info] - Implement GetSystemTimeAsFileTime & QueryPerformanceFrequency - Implement QueryPerformanceFrequency, GetSystemTimeAsFileTime - Used in Aurora and dash launch --- src/xenia/kernel/xam/xam_info.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/xenia/kernel/xam/xam_info.cc b/src/xenia/kernel/xam/xam_info.cc index 0fd67f63a..047a029a5 100644 --- a/src/xenia/kernel/xam/xam_info.cc +++ b/src/xenia/kernel/xam/xam_info.cc @@ -7,6 +7,7 @@ ****************************************************************************** */ +#include "xenia/base/clock.h" #include "xenia/base/cvar.h" #include "xenia/base/logging.h" #include "xenia/base/string_util.h" @@ -808,6 +809,32 @@ DECLARE_XAM_EXPORT1(XamDoesOmniNeedConfiguration, kNone, kStub); dword_result_t XamFirstRunExperienceShouldRun_entry() { return 0; } DECLARE_XAM_EXPORT1(XamFirstRunExperienceShouldRun, kNone, kStub); +dword_result_t QueryPerformanceFrequency_entry(lpqword_t query) { + // Copied from KeQueryPerformanceFrequency + uint64_t result = Clock::guest_tick_frequency(); + *query = static_cast(result); + return 1; +} +DECLARE_XAM_EXPORT1(QueryPerformanceFrequency, kNone, kImplemented); + +void GetSystemTimeAsFileTime_entry(lpqword_t time_ptr, + const ppc_context_t& ctx) { + if (time_ptr) { + // Copied from KeQuerySystemTime + // update the timestamp bundle to the time we queried. + // this is a race, but i don't of any sw that requires it, it just seems + // like we ought to keep it consistent with ketimestampbundle in case + // something uses this function, but also reads it directly + uint32_t ts_bundle = ctx->kernel_state->GetKeTimestampBundle(); + uint64_t time = Clock::QueryGuestSystemTime(); + // todo: cmpxchg? + ctx->TranslateVirtual(ts_bundle)->system_time = + xe::byte_swap(time); + *time_ptr = time; + } +} +DECLARE_XAM_EXPORT1(GetSystemTimeAsFileTime, kNone, kImplemented); + } // namespace xam } // namespace kernel } // namespace xe