From 68398407e0d1d32d0aad613d03fc7bfadabb7099 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 16 May 2020 16:34:59 -0700 Subject: [PATCH] exo2: cache soc type/hardware type for quick lookup --- ...secmon_configuration_context.arch.arm64.hpp | 16 ++++++++++++++++ .../secmon/secmon_monitor_context.hpp | 18 +++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp b/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp index 5b2c5bdc..fff53236 100644 --- a/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp +++ b/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp @@ -100,4 +100,20 @@ namespace ams::secmon { return GetSecmonConfiguration().GetKeyGeneration(); } + ALWAYS_INLINE fuse::HardwareType GetHardwareType() { + return GetSecmonConfiguration().GetHardwareType(); + } + + ALWAYS_INLINE fuse::SocType GetSocType() { + return GetSecmonConfiguration().GetSocType(); + } + + ALWAYS_INLINE fuse::HardwareState GetHardwareState() { + return GetSecmonConfiguration().GetHardwareState(); + } + + ALWAYS_INLINE bool IsProduction() { + return GetSecmonConfiguration().IsProduction(); + } + } diff --git a/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp b/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp index 2b3822b0..263ab28f 100644 --- a/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp +++ b/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp @@ -15,6 +15,7 @@ */ #pragma once #include +#include #include namespace ams::secmon { @@ -48,16 +49,31 @@ namespace ams::secmon { struct SecureMonitorConfiguration { ams::TargetFirmware target_firmware; s32 key_generation; + u8 hardware_type; + u8 soc_type; + u8 hardware_state; + u8 pad_0B[1]; u32 flags; - u32 reserved[(0x80 - 0x0C) / sizeof(u32)]; + u32 reserved[(0x80 - 0x10) / sizeof(u32)]; constexpr void CopyFrom(const SecureMonitorStorageConfiguration &storage) { this->target_firmware = storage.target_firmware; this->flags = storage.flags; } + void SetFuseInfo() { + this->hardware_type = fuse::GetHardwareType(); + this->soc_type = fuse::GetSocType(); + this->hardware_state = fuse::GetHardwareState(); + } + constexpr ams::TargetFirmware GetTargetFirmware() const { return this->target_firmware; } constexpr int GetKeyGeneration() const { return this->key_generation; } + constexpr fuse::HardwareType GetHardwareType() const { return static_cast(this->hardware_type); } + constexpr fuse::SocType GetSocType() const { return static_cast(this->soc_type); } + constexpr fuse::HardwareState GetHardwareState() const { return static_cast(this->hardware_state); } + + constexpr bool IsProduction() const { return this->GetHardwareState() != fuse::HardwareState_Development; } constexpr bool IsDevelopmentFunctionEnabledForKernel() const { return (this->flags & SecureMonitorConfigurationFlag_IsDevelopmentFunctionEnabledForKernel) != 0; } constexpr bool IsDevelopmentFunctionEnabledForUser() const { return (this->flags & SecureMonitorConfigurationFlag_IsDevelopmentFunctionEnabledForUser) != 0; }