ams: deduplicate static initialization logic

This commit is contained in:
Michael Scire 2021-12-13 13:07:03 -08:00
parent 78f7218c4f
commit 30fac905af
24 changed files with 202 additions and 262 deletions

View file

@ -112,13 +112,13 @@ namespace ams::fssystem {
NcaCryptoConfiguration g_nca_crypto_configuration_prod;
constexpr inline s32 KeySlotCacheEntryCount = 3;
KeySlotCache g_key_slot_cache;
util::optional<KeySlotCacheEntry> g_key_slot_cache_entry[KeySlotCacheEntryCount];
constinit KeySlotCache g_key_slot_cache;
constinit util::optional<KeySlotCacheEntry> g_key_slot_cache_entry[KeySlotCacheEntryCount];
spl::AccessKey &GetNcaKekAccessKey(s32 key_type) {
static spl::AccessKey s_nca_kek_access_key_array[KeyAreaEncryptionKeyCount] = {};
static spl::AccessKey s_nca_header_kek_access_key = {};
static spl::AccessKey s_invalid_nca_kek_access_key = {};
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(spl::AccessKey, s_nca_kek_access_key_array[KeyAreaEncryptionKeyCount]);
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(spl::AccessKey, s_nca_header_kek_access_key);
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(spl::AccessKey, s_invalid_nca_kek_access_key);
if (key_type > static_cast<s32>(KeyType::NcaHeaderKey) || IsInvalidKeyTypeValue(key_type)) {
return s_invalid_nca_kek_access_key;