diff --git a/libraries/libstratosphere/include/stratosphere/ams/ams_types.hpp b/libraries/libstratosphere/include/stratosphere/ams/ams_types.hpp index 27f575a88..02667187f 100644 --- a/libraries/libstratosphere/include/stratosphere/ams/ams_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/ams/ams_types.hpp @@ -38,27 +38,41 @@ namespace ams::exosphere { }; #undef AMS_DEFINE_TARGET_FIRMWARE_ENUM - constexpr inline u32 GetVersion(u32 major, u32 minor, u32 micro) { + constexpr ALWAYS_INLINE u32 GetVersion(u32 major, u32 minor, u32 micro) { return (major << 16) | (minor << 8) | (micro); } struct ApiInfo { - u32 major_version; - u32 minor_version; - u32 micro_version; - TargetFirmware target_firmware; - u32 master_key_revision; + using MasterKeyRevision = util::BitPack64::Field<0, 8, u32>; + using TargetFirmwareVersion = util::BitPack64::Field; + using MicroVersion = util::BitPack64::Field; + using MinorVersion = util::BitPack64::Field; + using MajorVersion = util::BitPack64::Field; - constexpr u32 GetVersion() const { - return ::ams::exosphere::GetVersion(this->major_version, this->minor_version, this->micro_version); + util::BitPack64 value; + + constexpr ALWAYS_INLINE u32 GetVersion() const { + return ::ams::exosphere::GetVersion(this->GetMajorVersion(), this->GetMinorVersion(), this->GetMicroVersion()); } - constexpr TargetFirmware GetTargetFirmware() const { - return this->target_firmware; + constexpr ALWAYS_INLINE u32 GetMajorVersion() const { + return this->value.Get(); } - constexpr u32 GetMasterKeyRevision() const { - return this->master_key_revision; + constexpr ALWAYS_INLINE u32 GetMinorVersion() const { + return this->value.Get(); + } + + constexpr ALWAYS_INLINE u32 GetMicroVersion() const { + return this->value.Get(); + } + + constexpr ALWAYS_INLINE TargetFirmware GetTargetFirmware() const { + return this->value.Get(); + } + + constexpr ALWAYS_INLINE u32 GetMasterKeyRevision() const { + return this->value.Get(); } }; diff --git a/libraries/libstratosphere/source/ams/ams_exosphere_api.cpp b/libraries/libstratosphere/source/ams/ams_exosphere_api.cpp index f1233ec3f..5c19ad903 100644 --- a/libraries/libstratosphere/source/ams/ams_exosphere_api.cpp +++ b/libraries/libstratosphere/source/ams/ams_exosphere_api.cpp @@ -26,13 +26,7 @@ namespace ams::exosphere { R_ASSERT(ResultNotPresent()); } - return ApiInfo{ - .major_version = static_cast((exosphere_cfg >> 0x20) & 0xFF), - .minor_version = static_cast((exosphere_cfg >> 0x18) & 0xFF), - .micro_version = static_cast((exosphere_cfg >> 0x10) & 0xFF), - .target_firmware = static_cast((exosphere_cfg >> 0x08) & 0xFF), - .master_key_revision = static_cast((exosphere_cfg >> 0x00) & 0xFF), - }; + return ApiInfo{ util::BitPack64(exosphere_cfg) }; } void ForceRebootToRcm() { diff --git a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp index 18df2ee9f..cf61aaa14 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp @@ -60,7 +60,7 @@ namespace ams::mitm::settings { #pragma GCC diagnostic ignored "-Wformat-truncation" { char display_version[sizeof(g_ams_firmware_version.display_version)]; - std::snprintf(display_version, sizeof(display_version), "%s|AMS %u.%u.%u|%c", g_ams_firmware_version.display_version, api_info.major_version, api_info.minor_version, api_info.micro_version, emummc_char); + std::snprintf(display_version, sizeof(display_version), "%s|AMS %u.%u.%u|%c", g_ams_firmware_version.display_version, api_info.GetMajorVersion(), api_info.GetMinorVersion(), api_info.GetMicroVersion(), emummc_char); std::memcpy(g_ams_firmware_version.display_version, display_version, sizeof(display_version)); } #pragma GCC diagnostic pop