mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 12:21:18 +00:00
exo: change config to its own static page
This is necessary to support both pre-7.0.0 and 7.0.0...
This commit is contained in:
parent
7bdb2ae897
commit
3d6405be85
4 changed files with 14 additions and 25 deletions
|
@ -22,12 +22,7 @@
|
||||||
#include "mmu.h"
|
#include "mmu.h"
|
||||||
#include "memory_map.h"
|
#include "memory_map.h"
|
||||||
|
|
||||||
#define MAILBOX_BASE (MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_NXBOOTLOADER_MAILBOX))
|
static exosphere_config_t g_exosphere_cfg = {MAGIC_EXOSPHERE_CONFIG, ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG, EXOSPHERE_FLAGS_DEFAULT};
|
||||||
|
|
||||||
/* 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, ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG, EXOSPHERE_FLAGS_DEFAULT};
|
|
||||||
static bool g_has_loaded_config = false;
|
static bool g_has_loaded_config = false;
|
||||||
|
|
||||||
#define EXOSPHERE_CHECK_FLAG(flag) ((g_exosphere_cfg.flags & flag) != 0)
|
#define EXOSPHERE_CHECK_FLAG(flag) ((g_exosphere_cfg.flags & flag) != 0)
|
||||||
|
@ -42,11 +37,8 @@ unsigned int exosphere_load_config(void) {
|
||||||
|
|
||||||
const unsigned int magic = MAILBOX_EXOSPHERE_CONFIG.magic;
|
const unsigned int magic = MAILBOX_EXOSPHERE_CONFIG.magic;
|
||||||
|
|
||||||
if (magic == MAGIC_EXOSPHERE_BOOTCONFIG) {
|
if (magic == MAGIC_EXOSPHERE_CONFIG) {
|
||||||
g_exosphere_cfg = MAILBOX_EXOSPHERE_CONFIG;
|
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;
|
return g_exosphere_cfg.target_firmware;
|
||||||
|
|
|
@ -25,17 +25,15 @@
|
||||||
|
|
||||||
/* This serves to set configuration for *exosphere itself*, separate from the SecMon Exosphere mimics. */
|
/* This serves to set configuration for *exosphere itself*, separate from the SecMon Exosphere mimics. */
|
||||||
|
|
||||||
/* "XBC0" */
|
/* "EXO0" */
|
||||||
#define MAGIC_EXOSPHERE_BOOTCONFIG_0 (0x30434258)
|
#define MAGIC_EXOSPHERE_CONFIG (0x304F5845)
|
||||||
/* "XBC1" */
|
|
||||||
#define MAGIC_EXOSPHERE_BOOTCONFIG (0x31434258)
|
|
||||||
|
|
||||||
#define EXOSPHERE_LOOSEN_PACKAGE2_RESTRICTIONS_FOR_DEBUG 1
|
#define EXOSPHERE_LOOSEN_PACKAGE2_RESTRICTIONS_FOR_DEBUG 1
|
||||||
|
|
||||||
#define MAILBOX_BASE_PHYS (MMIO_GET_DEVICE_PA(MMIO_DEVID_NXBOOTLOADER_MAILBOX))
|
#define MAILBOX_EXOSPHERE_CONFIG (*((volatile exosphere_config_t *)(0x8000F000ull)))
|
||||||
|
|
||||||
/* TODO: Should this be at a non-static location? */
|
/* Exosphere config in DRAM shares physical/virtual mapping. */
|
||||||
#define MAILBOX_EXOSPHERE_CONFIG_PHYS (*((volatile exosphere_config_t *)(MAILBOX_BASE_PHYS + 0xE40ULL)))
|
#define MAILBOX_EXOSPHERE_CONFIG_PHYS MAILBOX_EXOSPHERE_CONFIG
|
||||||
|
|
||||||
#define EXOSPHERE_FLAGS_DEFAULT 0x00000000
|
#define EXOSPHERE_FLAGS_DEFAULT 0x00000000
|
||||||
#define EXOSPHERE_FLAG_PERFORM_620_KEYGEN (1 << 0u)
|
#define EXOSPHERE_FLAG_PERFORM_620_KEYGEN (1 << 0u)
|
||||||
|
@ -46,6 +44,7 @@ typedef struct {
|
||||||
unsigned int magic;
|
unsigned int magic;
|
||||||
unsigned int target_firmware;
|
unsigned int target_firmware;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
unsigned int reserved;
|
||||||
} exosphere_config_t;
|
} exosphere_config_t;
|
||||||
|
|
||||||
unsigned int exosphere_load_config(void);
|
unsigned int exosphere_load_config(void);
|
||||||
|
@ -56,7 +55,7 @@ unsigned int exosphere_should_override_debugmode_user(void);
|
||||||
|
|
||||||
static inline unsigned int exosphere_get_target_firmware_for_init(void) {
|
static inline unsigned int exosphere_get_target_firmware_for_init(void) {
|
||||||
const unsigned int magic = MAILBOX_EXOSPHERE_CONFIG_PHYS.magic;
|
const unsigned int magic = MAILBOX_EXOSPHERE_CONFIG_PHYS.magic;
|
||||||
if (magic == MAGIC_EXOSPHERE_BOOTCONFIG || magic == MAGIC_EXOSPHERE_BOOTCONFIG_0) {
|
if (magic == MAGIC_EXOSPHERE_CONFIG) {
|
||||||
return MAILBOX_EXOSPHERE_CONFIG_PHYS.target_firmware;
|
return MAILBOX_EXOSPHERE_CONFIG_PHYS.target_firmware;
|
||||||
} else {
|
} else {
|
||||||
return ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG;
|
return ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG;
|
||||||
|
|
|
@ -21,11 +21,8 @@
|
||||||
|
|
||||||
/* This serves to set configuration for *exosphere itself*, separate from the SecMon Exosphere mimics. */
|
/* This serves to set configuration for *exosphere itself*, separate from the SecMon Exosphere mimics. */
|
||||||
|
|
||||||
/* "XBC0" */
|
/* "EXO0" */
|
||||||
#define MAGIC_EXOSPHERE_BOOTCONFIG_0 (0x30434258)
|
#define MAGIC_EXOSPHERE_CONFIG (0x304F5845)
|
||||||
/* "XBC1" */
|
|
||||||
#define MAGIC_EXOSPHERE_BOOTCONFIG (0x31434258)
|
|
||||||
|
|
||||||
|
|
||||||
#define EXOSPHERE_FLAGS_DEFAULT 0x00000000
|
#define EXOSPHERE_FLAGS_DEFAULT 0x00000000
|
||||||
#define EXOSPHERE_FLAG_PERFORM_620_KEYGEN (1 << 0u)
|
#define EXOSPHERE_FLAG_PERFORM_620_KEYGEN (1 << 0u)
|
||||||
|
@ -36,9 +33,10 @@ typedef struct {
|
||||||
unsigned int magic;
|
unsigned int magic;
|
||||||
unsigned int target_firmware;
|
unsigned int target_firmware;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
unsigned int reserved;
|
||||||
} exosphere_config_t;
|
} exosphere_config_t;
|
||||||
|
|
||||||
#define MAILBOX_EXOSPHERE_CONFIGURATION ((volatile exosphere_config_t *)(0x40002E40))
|
#define MAILBOX_EXOSPHERE_CONFIGURATION ((volatile exosphere_config_t *)(0x8000F000ull))
|
||||||
|
|
||||||
#define EXOSPHERE_TARGETFW_KEY "target_firmware"
|
#define EXOSPHERE_TARGETFW_KEY "target_firmware"
|
||||||
#define EXOSPHERE_DEBUGMODE_PRIV_KEY "debugmode"
|
#define EXOSPHERE_DEBUGMODE_PRIV_KEY "debugmode"
|
||||||
|
|
|
@ -174,7 +174,7 @@ static uint32_t nxboot_get_target_firmware(const void *package1loader) {
|
||||||
static void nxboot_configure_exosphere(uint32_t target_firmware, unsigned int keygen_type) {
|
static void nxboot_configure_exosphere(uint32_t target_firmware, unsigned int keygen_type) {
|
||||||
exosphere_config_t exo_cfg = {0};
|
exosphere_config_t exo_cfg = {0};
|
||||||
|
|
||||||
exo_cfg.magic = MAGIC_EXOSPHERE_BOOTCONFIG;
|
exo_cfg.magic = MAGIC_EXOSPHERE_CONFIG;
|
||||||
exo_cfg.target_firmware = target_firmware;
|
exo_cfg.target_firmware = target_firmware;
|
||||||
if (keygen_type) {
|
if (keygen_type) {
|
||||||
exo_cfg.flags = EXOSPHERE_FLAGS_DEFAULT | EXOSPHERE_FLAG_PERFORM_620_KEYGEN;
|
exo_cfg.flags = EXOSPHERE_FLAGS_DEFAULT | EXOSPHERE_FLAG_PERFORM_620_KEYGEN;
|
||||||
|
|
Loading…
Reference in a new issue