mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
exo2: cache soc type/hardware type for quick lookup
This commit is contained in:
parent
a0b08d0540
commit
99e0448f30
4 changed files with 38 additions and 3 deletions
|
@ -245,7 +245,7 @@ namespace ams::secmon::boot {
|
|||
|
||||
void DeriveAllKeys() {
|
||||
/* Determine whether we're prod. */
|
||||
const bool is_prod = fuse::GetHardwareState() != fuse::HardwareState_Development;
|
||||
const bool is_prod = IsProduction();
|
||||
|
||||
/* Get the ephemeral work block. */
|
||||
u8 * const work_block = se::GetEphemeralWorkBlock();
|
||||
|
|
|
@ -94,6 +94,9 @@ namespace ams::secmon {
|
|||
/* If we don't have a valid storage context, we can just use the default one. */
|
||||
ctx.secmon_cfg = DefaultSecureMonitorConfiguration;
|
||||
}
|
||||
|
||||
/* Cache the fuse info for quick access. */
|
||||
ctx.secmon_cfg.SetFuseInfo();
|
||||
}
|
||||
|
||||
void GenerateSecurityEngineAesKeySlotTestVector(void *dst, size_t size) {
|
||||
|
@ -387,7 +390,7 @@ namespace ams::secmon {
|
|||
SLAVE_SECURITY_REG_BITS_ENUM(2, DDS, ENABLE),
|
||||
SLAVE_SECURITY_REG_BITS_ENUM(2, DP2, ENABLE));
|
||||
|
||||
const auto hw_type = fuse::GetHardwareType();
|
||||
const auto hw_type = GetHardwareType();
|
||||
|
||||
/* Switch Lite can't use HDMI, so set CEC to secure on hoag. */
|
||||
if (hw_type == fuse::HardwareType_Hoag) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <exosphere/fuse.hpp>
|
||||
#include <exosphere/secmon/secmon_emummc_context.hpp>
|
||||
|
||||
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<fuse::HardwareType>(this->hardware_type); }
|
||||
constexpr fuse::SocType GetSocType() const { return static_cast<fuse::SocType>(this->soc_type); }
|
||||
constexpr fuse::HardwareState GetHardwareState() const { return static_cast<fuse::HardwareState>(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; }
|
||||
|
|
Loading…
Reference in a new issue