exosphere: add EXOSPHERE_TARGET_FIRMWARE_620

This commit is contained in:
Michael Scire
2018-11-25 16:06:46 -08:00
parent e214f4d325
commit eab5e0df9b
3 changed files with 39 additions and 6 deletions

View File

@@ -27,9 +27,12 @@
/* TODO: Should this be at a non-static location? */
#define MAILBOX_EXOSPHERE_CONFIG (*((volatile exosphere_config_t *)(MAILBOX_BASE + 0xE40ULL)))
static exosphere_config_t g_exosphere_cfg = {MAGIC_EXOSPHERE_BOOTCONFIG, EXOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG};
static exosphere_config_t g_exosphere_cfg = {MAGIC_EXOSPHERE_BOOTCONFIG, EXOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG, EXOSPHERE_FLAGS_DEFAULT};
static bool g_has_loaded_config = false;
#define EXOSPHERE_CHECK_FLAG(flag) ((g_exosphere_cfg.flags & flag) != 0)
/* Read config out of IRAM, return target firmware version. */
unsigned int exosphere_load_config(void) {
if (g_has_loaded_config) {
@@ -37,8 +40,13 @@ unsigned int exosphere_load_config(void) {
}
g_has_loaded_config = true;
if (MAILBOX_EXOSPHERE_CONFIG.magic == MAGIC_EXOSPHERE_BOOTCONFIG) {
const unsigned int magic = MAILBOX_EXOSPHERE_CONFIG.magic;
if (magic == MAGIC_EXOSPHERE_BOOTCONFIG) {
g_exosphere_cfg = MAILBOX_EXOSPHERE_CONFIG;
} else if (magic == MAGIC_EXOSPHERE_BOOTCONFIG_0) {
g_exosphere_cfg = MAILBOX_EXOSPHERE_CONFIG;
g_exosphere_cfg.flags = EXOSPHERE_FLAGS_DEFAULT;
}
return g_exosphere_cfg.target_firmware;
@@ -50,4 +58,12 @@ unsigned int exosphere_get_target_firmware(void) {
}
return g_exosphere_cfg.target_firmware;
}
}
unsigned int exosphere_get_should_perform_620_keygen(void) {
if (!g_has_loaded_config) {
generic_panic();
}
return g_exosphere_cfg.target_firmware >= EXOSPHERE_TARGET_FIRMWARE_620 && EXOSPHERE_CHECK_FLAG(EXOSPHERE_FLAG_PERFORM_620_KEYGEN);
}