1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-23 02:42:09 +00:00

fusee/exo: add emunand configitem support

This commit is contained in:
Michael Scire 2019-05-27 12:07:51 -07:00
parent 4dac80df75
commit 79d96bbdfd
6 changed files with 32 additions and 9 deletions

View file

@ -284,6 +284,9 @@ uint32_t configitem_get(bool privileged, ConfigItem item, uint64_t *p_outvalue)
/* UNOFFICIAL: Gets whether this unit has the RCM bug patched. */
*p_outvalue = (int)(fuse_has_rcm_bug_patch());;
break;
case CONFIGITEM_EMUNAND_CONFIG:
/* UNOFFICIAL: Gets configuration meta for emunand. */
*p_outvalue = exosphere_get_emunand_config();
default:
result = 2;
break;

View file

@ -45,6 +45,9 @@ typedef enum {
CONFIGITEM_NEEDS_SHUTDOWN = 65002,
CONFIGITEM_EXOSPHERE_VERHASH = 65003,
CONFIGITEM_HAS_RCM_BUG_PATCH = 65004,
/* These are unofficial, emunand-related. */
CONFIGITEM_EMUNAND_CONFIG = 65100,
} ConfigItem;
#define REBOOT_KIND_NO_REBOOT 0

View file

@ -83,3 +83,11 @@ unsigned int exosphere_should_disable_usermode_exception_handlers(void) {
return EXOSPHERE_CHECK_FLAG(EXOSPHERE_FLAG_DISABLE_USERMODE_EXCEPTION_HANDLERS);
}
uint64_t exosphere_get_emunand_config(void) {
if (!g_has_loaded_config) {
generic_panic();
}
return g_exosphere_cfg.emunand_config;
}

View file

@ -42,12 +42,15 @@
#define EXOSPHERE_FLAGS_DEFAULT (EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV)
typedef struct {
unsigned int magic;
unsigned int target_firmware;
unsigned int flags;
unsigned int reserved;
uint32_t magic;
uint32_t target_firmware;
uint32_t flags;
uint32_t reserved;
uint64_t emunand_config;
} exosphere_config_t;
_Static_assert(sizeof(exosphere_config_t) == 0x18, "exosphere config definition");
unsigned int exosphere_load_config(void);
unsigned int exosphere_get_target_firmware(void);
unsigned int exosphere_should_perform_620_keygen(void);
@ -55,6 +58,8 @@ unsigned int exosphere_should_override_debugmode_priv(void);
unsigned int exosphere_should_override_debugmode_user(void);
unsigned int exosphere_should_disable_usermode_exception_handlers(void);
uint64_t exosphere_get_emunand_config(void);
static inline unsigned int exosphere_get_target_firmware_for_init(void) {
const unsigned int magic = MAILBOX_EXOSPHERE_CONFIG_PHYS.magic;
if (magic == MAGIC_EXOSPHERE_CONFIG) {

View file

@ -17,6 +17,7 @@
#ifndef FUSEE_EXOSPHERE_CONFIG_H
#define FUSEE_EXOSPHERE_CONFIG_H
#include <stdint.h>
#include <atmosphere.h>
/* This serves to set configuration for *exosphere itself*, separate from the SecMon Exosphere mimics. */
@ -31,12 +32,15 @@
#define EXOSPHERE_FLAGS_DEFAULT (EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV)
typedef struct {
unsigned int magic;
unsigned int target_firmware;
unsigned int flags;
unsigned int reserved;
uint32_t magic;
uint32_t target_firmware;
uint32_t flags;
uint32_t reserved;
uint64_t emunand_config;
} exosphere_config_t;
_Static_assert(sizeof(exosphere_config_t) == 0x18, "exosphere config definition");
#define MAILBOX_EXOSPHERE_CONFIGURATION ((volatile exosphere_config_t *)(0x8000F000ull))
#define EXOSPHERE_TARGETFW_KEY "target_firmware"

View file

@ -125,7 +125,7 @@ static int exosphere_ini_handler(void *user, const char *section, const char *na
int tmp = 0;
if (strcmp(section, "exosphere") == 0) {
if (strcmp(name, EXOSPHERE_TARGETFW_KEY) == 0) {
sscanf(value, "%d", &exo_cfg->target_firmware);
sscanf(value, "%ld", &exo_cfg->target_firmware);
} else if (strcmp(name, EXOSPHERE_DEBUGMODE_PRIV_KEY) == 0) {
sscanf(value, "%d", &tmp);
if (tmp) {