mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-31 14:58:22 -04:00
emunand: Move all emulation code to fusee-secondary and simplify logic
This commit is contained in:
parent
9eb0b84ed1
commit
92816be055
8 changed files with 315 additions and 193 deletions
|
@ -35,14 +35,7 @@ extern void (*__program_exit_callback)(int rc);
|
|||
static void *g_framebuffer;
|
||||
static char g_bct0_buffer[BCTO_MAX_SIZE];
|
||||
|
||||
typedef struct {
|
||||
bool enabled;
|
||||
char path[0x100];
|
||||
} emunand_config_t;
|
||||
|
||||
#define CONFIG_LOG_LEVEL_KEY "log_level"
|
||||
#define EMUNAND_ENABLED_KEY "emunand_enabled"
|
||||
#define EMUNAND_PATH_KEY "emunand_path"
|
||||
|
||||
#define DEFAULT_BCT0_FOR_DEBUG \
|
||||
"BCT0\n"\
|
||||
|
@ -91,26 +84,6 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int emunand_ini_handler(void *user, const char *section, const char *name, const char *value) {
|
||||
emunand_config_t *emunand_cfg = (emunand_config_t *)user;
|
||||
if (strcmp(section, "emunand") == 0) {
|
||||
if (strcmp(name, EMUNAND_ENABLED_KEY) == 0) {
|
||||
int tmp = 0;
|
||||
sscanf(value, "%d", &tmp);
|
||||
emunand_cfg->enabled = (tmp != 0);
|
||||
}
|
||||
if (strcmp(name, EMUNAND_PATH_KEY) == 0) {
|
||||
strncpy(emunand_cfg->path, value, sizeof(emunand_cfg->path) - 1);
|
||||
emunand_cfg->path[sizeof(emunand_cfg->path) - 1] = '\0';
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void setup_env(void) {
|
||||
g_framebuffer = (void *)0xC0000000;
|
||||
|
||||
|
@ -159,7 +132,6 @@ int main(void) {
|
|||
stage2_args_t *stage2_args;
|
||||
uint32_t stage2_version = 0;
|
||||
ScreenLogLevel log_level = SCREEN_LOG_LEVEL_MANDATORY;
|
||||
emunand_config_t emunand_cfg = {.enabled = false, .path = ""};
|
||||
|
||||
/* Override the global logging level. */
|
||||
log_set_log_level(log_level);
|
||||
|
@ -170,9 +142,8 @@ int main(void) {
|
|||
/* Load the BCT0 configuration ini off of the SD. */
|
||||
bct0 = load_config();
|
||||
|
||||
/* Extract the logging level and emunand settings from the BCT.ini file. */
|
||||
if ((ini_parse_string(bct0, config_ini_handler, &log_level) < 0) ||
|
||||
(ini_parse_string(bct0, emunand_ini_handler, &emunand_cfg) < 0)) {
|
||||
/* Extract the logging level from the BCT.ini file. */
|
||||
if (ini_parse_string(bct0, config_ini_handler, &log_level) < 0) {
|
||||
fatal_error("Failed to parse BCT.ini!\n");
|
||||
}
|
||||
|
||||
|
@ -190,9 +161,6 @@ int main(void) {
|
|||
memcpy(&stage2_args->version, &stage2_version, 4);
|
||||
memcpy(&stage2_args->log_level, &log_level, sizeof(log_level));
|
||||
stage2_args->display_initialized = false;
|
||||
stage2_args->emunand_enabled = emunand_cfg.enabled;
|
||||
strncpy(stage2_args->emunand_path, emunand_cfg.path, sizeof(stage2_args->emunand_path) - 1);
|
||||
stage2_args->emunand_path[sizeof(stage2_args->emunand_path) - 1] = '\0';
|
||||
strcpy(stage2_args->bct0, bct0);
|
||||
g_chainloader_argc = 2;
|
||||
|
||||
|
@ -205,4 +173,4 @@ int main(void) {
|
|||
/* Finally, after the cleanup routines (__libc_fini_array, etc.) are called, jump to Stage2. */
|
||||
__program_exit_callback = exit_callback;
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -46,12 +46,10 @@ typedef struct {
|
|||
uint32_t version;
|
||||
ScreenLogLevel log_level;
|
||||
bool display_initialized;
|
||||
bool emunand_enabled;
|
||||
char emunand_path[0x100];
|
||||
char bct0[BCTO_MAX_SIZE];
|
||||
} stage2_args_t;
|
||||
|
||||
const char *stage2_get_program_path(void);
|
||||
void load_stage2(const char *bct0);
|
||||
|
||||
#endif
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue