summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/svc_version.h
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-01-29 01:38:00 +0100
committerLiam <byteslice@airmail.cc>2023-01-30 04:08:28 +0100
commit67a8740af6c13d42f3c361c0f242cfa52f94b754 (patch)
tree5fd77b9b9cb1abe73bd54522f33d83c0198782da /src/core/hle/kernel/svc_version.h
parentMerge pull request #9682 from ameerj/shader-s32 (diff)
downloadyuzu-67a8740af6c13d42f3c361c0f242cfa52f94b754.tar
yuzu-67a8740af6c13d42f3c361c0f242cfa52f94b754.tar.gz
yuzu-67a8740af6c13d42f3c361c0f242cfa52f94b754.tar.bz2
yuzu-67a8740af6c13d42f3c361c0f242cfa52f94b754.tar.lz
yuzu-67a8740af6c13d42f3c361c0f242cfa52f94b754.tar.xz
yuzu-67a8740af6c13d42f3c361c0f242cfa52f94b754.tar.zst
yuzu-67a8740af6c13d42f3c361c0f242cfa52f94b754.zip
Diffstat (limited to 'src/core/hle/kernel/svc_version.h')
-rw-r--r--src/core/hle/kernel/svc_version.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/core/hle/kernel/svc_version.h b/src/core/hle/kernel/svc_version.h
new file mode 100644
index 000000000..e4f47b34b
--- /dev/null
+++ b/src/core/hle/kernel/svc_version.h
@@ -0,0 +1,58 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "common/bit_field.h"
+#include "common/common_types.h"
+#include "common/literals.h"
+
+namespace Kernel::Svc {
+
+constexpr inline u32 ConvertToSvcMajorVersion(u32 sdk) {
+ return sdk + 4;
+}
+constexpr inline u32 ConvertToSdkMajorVersion(u32 svc) {
+ return svc - 4;
+}
+
+constexpr inline u32 ConvertToSvcMinorVersion(u32 sdk) {
+ return sdk;
+}
+constexpr inline u32 ConvertToSdkMinorVersion(u32 svc) {
+ return svc;
+}
+
+union KernelVersion {
+ u32 value;
+ BitField<0, 4, u32> minor_version;
+ BitField<4, 13, u32> major_version;
+};
+
+constexpr inline u32 EncodeKernelVersion(u32 major, u32 minor) {
+ return decltype(KernelVersion::minor_version)::FormatValue(minor) |
+ decltype(KernelVersion::major_version)::FormatValue(major);
+}
+
+constexpr inline u32 GetKernelMajorVersion(u32 encoded) {
+ return std::bit_cast<decltype(KernelVersion::major_version)>(encoded).Value();
+}
+
+constexpr inline u32 GetKernelMinorVersion(u32 encoded) {
+ return std::bit_cast<decltype(KernelVersion::minor_version)>(encoded).Value();
+}
+
+// Nintendo doesn't support programs targeting SVC versions < 3.0.
+constexpr inline u32 RequiredKernelMajorVersion = 3;
+constexpr inline u32 RequiredKernelMinorVersion = 0;
+constexpr inline u32 RequiredKernelVersion =
+ EncodeKernelVersion(RequiredKernelMajorVersion, RequiredKernelMinorVersion);
+
+// This is the highest SVC version supported, to be updated on new kernel releases.
+// NOTE: Official kernel versions have SVC major = SDK major + 4, SVC minor = SDK minor.
+constexpr inline u32 SupportedKernelMajorVersion = ConvertToSvcMajorVersion(15);
+constexpr inline u32 SupportedKernelMinorVersion = ConvertToSvcMinorVersion(3);
+constexpr inline u32 SupportedKernelVersion =
+ EncodeKernelVersion(SupportedKernelMajorVersion, SupportedKernelMinorVersion);
+
+} // namespace Kernel::Svc