summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/svc/svc_tick.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/svc/svc_tick.cpp')
-rw-r--r--src/core/hle/kernel/svc/svc_tick.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/core/hle/kernel/svc/svc_tick.cpp b/src/core/hle/kernel/svc/svc_tick.cpp
new file mode 100644
index 000000000..e9b4fd5a6
--- /dev/null
+++ b/src/core/hle/kernel/svc/svc_tick.cpp
@@ -0,0 +1,33 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "core/core.h"
+#include "core/core_timing.h"
+#include "core/hle/kernel/kernel.h"
+#include "core/hle/kernel/svc.h"
+
+namespace Kernel::Svc {
+
+/// This returns the total CPU ticks elapsed since the CPU was powered-on
+u64 GetSystemTick(Core::System& system) {
+ LOG_TRACE(Kernel_SVC, "called");
+
+ auto& core_timing = system.CoreTiming();
+
+ // Returns the value of cntpct_el0 (https://switchbrew.org/wiki/SVC#svcGetSystemTick)
+ const u64 result{core_timing.GetClockTicks()};
+
+ if (!system.Kernel().IsMulticore()) {
+ core_timing.AddTicks(400U);
+ }
+
+ return result;
+}
+
+void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high) {
+ const auto time = GetSystemTick(system);
+ *time_low = static_cast<u32>(time);
+ *time_high = static_cast<u32>(time >> 32);
+}
+
+} // namespace Kernel::Svc