mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-26 13:52:21 +00:00
ams: use bitpack for api version
This commit is contained in:
parent
59be817bb8
commit
3038612774
3 changed files with 28 additions and 20 deletions
|
@ -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<MasterKeyRevision::Next, 8, TargetFirmware>;
|
||||
using MicroVersion = util::BitPack64::Field<TargetFirmwareVersion::Next, 8, u32>;
|
||||
using MinorVersion = util::BitPack64::Field<MicroVersion::Next, 8, u32>;
|
||||
using MajorVersion = util::BitPack64::Field<MinorVersion::Next, 8, u32>;
|
||||
|
||||
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<MajorVersion>();
|
||||
}
|
||||
|
||||
constexpr u32 GetMasterKeyRevision() const {
|
||||
return this->master_key_revision;
|
||||
constexpr ALWAYS_INLINE u32 GetMinorVersion() const {
|
||||
return this->value.Get<MinorVersion>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE u32 GetMicroVersion() const {
|
||||
return this->value.Get<MicroVersion>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE TargetFirmware GetTargetFirmware() const {
|
||||
return this->value.Get<TargetFirmwareVersion>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE u32 GetMasterKeyRevision() const {
|
||||
return this->value.Get<MasterKeyRevision>();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -26,13 +26,7 @@ namespace ams::exosphere {
|
|||
R_ASSERT(ResultNotPresent());
|
||||
}
|
||||
|
||||
return ApiInfo{
|
||||
.major_version = static_cast<u32>((exosphere_cfg >> 0x20) & 0xFF),
|
||||
.minor_version = static_cast<u32>((exosphere_cfg >> 0x18) & 0xFF),
|
||||
.micro_version = static_cast<u32>((exosphere_cfg >> 0x10) & 0xFF),
|
||||
.target_firmware = static_cast<TargetFirmware>((exosphere_cfg >> 0x08) & 0xFF),
|
||||
.master_key_revision = static_cast<u32>((exosphere_cfg >> 0x00) & 0xFF),
|
||||
};
|
||||
return ApiInfo{ util::BitPack64(exosphere_cfg) };
|
||||
}
|
||||
|
||||
void ForceRebootToRcm() {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue