cfg: remove creation from hekate and move to Nyx

There's no reason for hekate to create the hekate config if missing, since Nyx is the sole manager of it.

So move the auto creation there to save binary space.
This commit is contained in:
CTCaer 2022-12-19 04:41:21 +02:00
parent 24795891ec
commit 227fe9b7ea
4 changed files with 5 additions and 124 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2021 CTCaer
* Copyright (c) 2018-2022 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@ -44,117 +44,3 @@ void set_default_configuration()
h_cfg.rcm_patched = fuse_check_patched_rcm();
h_cfg.emummc_force_disable = false;
}
int create_config_entry()
{
char lbuf[64];
FIL fp;
bool mainIniFound = false;
LIST_INIT(ini_sections);
if (ini_parse(&ini_sections, "bootloader/hekate_ipl.ini", false))
mainIniFound = true;
else
{
u8 res = f_open(&fp, "bootloader/hekate_ipl.ini", FA_READ);
if (res == FR_NO_FILE || res == FR_NO_PATH)
{
f_mkdir("bootloader");
f_mkdir("bootloader/ini");
f_mkdir("bootloader/payloads");
f_mkdir("bootloader/sys");
}
else
{
if (!res)
f_close(&fp);
return 1;
}
}
if (f_open(&fp, "bootloader/hekate_ipl.ini", FA_WRITE | FA_CREATE_ALWAYS) != FR_OK)
return 1;
// Add config entry.
f_puts("[config]\nautoboot=", &fp);
itoa(h_cfg.autoboot, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nautoboot_list=", &fp);
itoa(h_cfg.autoboot_list, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nbootwait=", &fp);
itoa(h_cfg.bootwait, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nbacklight=", &fp);
itoa(h_cfg.backlight, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nnoticker=", &fp);
itoa(h_cfg.noticker, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nautohosoff=", &fp);
itoa(h_cfg.autohosoff, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nautonogc=", &fp);
itoa(h_cfg.autonogc, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nupdater2p=", &fp);
itoa(h_cfg.updater2p, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nbootprotect=", &fp);
itoa(h_cfg.bootprotect, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\n", &fp);
if (mainIniFound)
{
// Re-construct existing entries.
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
{
if (!strcmp(ini_sec->name, "config"))
continue;
switch (ini_sec->type)
{
case INI_CHOICE: // Re-construct Boot entry [ ].
f_puts("[", &fp);
f_puts(ini_sec->name, &fp);
f_puts("]\n", &fp);
// Re-construct boot entry's config.
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
{
f_puts(kv->key, &fp);
f_puts("=", &fp);
f_puts(kv->val, &fp);
f_puts("\n", &fp);
}
break;
case INI_CAPTION: // Re-construct caption entry { }.
f_puts("{", &fp);
f_puts(ini_sec->name, &fp);
f_puts("}\n", &fp);
break;
case INI_NEWLINE: // Re-construct cosmetic newline \n.
f_puts("\n", &fp);
break;
case INI_COMMENT: // Re-construct comment entry #.
f_puts("#", &fp);
f_puts(ini_sec->name, &fp);
f_puts("\n", &fp);
break;
}
}
}
f_close(&fp);
return 0;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2021 CTCaer
* Copyright (c) 2018-2022 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@ -42,6 +42,5 @@ typedef struct _hekate_config
} hekate_config;
void set_default_configuration();
int create_config_entry();
#endif /* _CONFIG_H_ */

View file

@ -755,9 +755,6 @@ static void _auto_launch_firmware()
// Load emuMMC configuration.
emummc_load_cfg();
if (f_stat("bootloader/hekate_ipl.ini", NULL))
create_config_entry();
// Parse hekate main configuration.
if (!ini_parse(&ini_sections, "bootloader/hekate_ipl.ini", false))
goto out; // Can't load hekate_ipl.ini.
@ -884,10 +881,6 @@ static void _auto_launch_firmware()
}
skip_list:
// Add missing configuration entry.
if (!config_entry_found)
create_config_entry();
if (!cfg_sec)
goto out; // No configurations or auto boot is disabled.

View file

@ -211,7 +211,10 @@ static void _load_saved_configuration()
LIST_INIT(ini_nyx_sections);
if (!ini_parse(&ini_sections, "bootloader/hekate_ipl.ini", false))
{
create_config_entry();
goto skip_main_cfg_parse;
}
// Load hekate configuration.
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)