mirror of
https://github.com/CTCaer/hekate
synced 2024-11-16 00:49:27 +00:00
Move verification config to nyx config
This commit is contained in:
parent
63be93be64
commit
08c81fe1f8
6 changed files with 101 additions and 62 deletions
|
@ -30,6 +30,7 @@
|
|||
#include "../utils/util.h"
|
||||
|
||||
extern hekate_config h_cfg;
|
||||
extern nyx_config n_cfg;
|
||||
|
||||
void set_default_configuration()
|
||||
{
|
||||
|
@ -53,6 +54,11 @@ void set_default_configuration()
|
|||
sd_power_cycle_time_start = 0;
|
||||
}
|
||||
|
||||
void set_nyx_default_configuration()
|
||||
{
|
||||
n_cfg.verification = 1;
|
||||
}
|
||||
|
||||
int create_config_entry()
|
||||
{
|
||||
if (!sd_mount())
|
||||
|
@ -96,9 +102,6 @@ int create_config_entry()
|
|||
f_puts("\nbootwait=", &fp);
|
||||
itoa(h_cfg.bootwait, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
f_puts("\nverification=", &fp);
|
||||
itoa(h_cfg.verification, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
f_puts("\nbacklight=", &fp);
|
||||
itoa(h_cfg.backlight, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
|
@ -169,3 +172,28 @@ int create_config_entry()
|
|||
return 0;
|
||||
}
|
||||
|
||||
int create_nyx_config_entry()
|
||||
{
|
||||
if (!sd_mount())
|
||||
return 1;
|
||||
|
||||
char lbuf[32];
|
||||
FIL fp;
|
||||
|
||||
// Make sure that bootloader folder exists.
|
||||
f_mkdir("bootloader");
|
||||
|
||||
if (f_open(&fp, "bootloader/nyx.ini", FA_WRITE | FA_CREATE_ALWAYS) != FR_OK)
|
||||
return 1;
|
||||
|
||||
// Add config entry.
|
||||
f_puts("[config]\nverification=", &fp);
|
||||
itoa(n_cfg.verification, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
f_puts("\n", &fp);
|
||||
|
||||
f_close(&fp);
|
||||
sd_unmount(false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ typedef struct _hekate_config
|
|||
u32 autoboot;
|
||||
u32 autoboot_list;
|
||||
u32 bootwait;
|
||||
u32 verification;
|
||||
u32 backlight;
|
||||
u32 autohosoff;
|
||||
u32 autonogc;
|
||||
|
@ -41,7 +40,14 @@ typedef struct _hekate_config
|
|||
u32 errors;
|
||||
} hekate_config;
|
||||
|
||||
typedef struct _nyx_config
|
||||
{
|
||||
u32 verification;
|
||||
} nyx_config;
|
||||
|
||||
void set_default_configuration();
|
||||
void set_nyx_default_configuration();
|
||||
int create_config_entry();
|
||||
int create_nyx_config_entry();
|
||||
|
||||
#endif /* _CONFIG_H_ */
|
||||
|
|
|
@ -55,12 +55,9 @@ u32 _find_section_name(char *lbuf, u32 lblen, char schar)
|
|||
ini_sec_t *_ini_create_section(link_t *dst, ini_sec_t *csec, char *name, u8 type)
|
||||
{
|
||||
if (csec)
|
||||
{
|
||||
list_append(dst, &csec->link);
|
||||
csec = NULL;
|
||||
}
|
||||
|
||||
csec = (ini_sec_t *)malloc(sizeof(ini_sec_t));
|
||||
csec = (ini_sec_t *)calloc(sizeof(ini_sec_t), 1);
|
||||
csec->name = _strdup(name);
|
||||
csec->type = type;
|
||||
|
||||
|
@ -154,7 +151,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
|
|||
{
|
||||
u32 i = _find_section_name(lbuf, lblen, '=');
|
||||
|
||||
ini_kv_t *kv = (ini_kv_t *)malloc(sizeof(ini_kv_t));
|
||||
ini_kv_t *kv = (ini_kv_t *)calloc(sizeof(ini_kv_t), 1);
|
||||
kv->key = _strdup(&lbuf[0]);
|
||||
kv->val = _strdup(&lbuf[i + 1]);
|
||||
list_append(&csec->kvs, &kv->link);
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#define HASH_FILENAME_SZ (OUT_FILENAME_SZ + 11) // 11 == strlen(".sha256sums")
|
||||
#define SHA256_SZ 0x20
|
||||
|
||||
extern hekate_config h_cfg;
|
||||
extern nyx_config n_cfg;
|
||||
|
||||
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
|
||||
|
@ -149,7 +149,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
|
|||
|
||||
if (f_open(&fp, outFilename, FA_READ) == FR_OK)
|
||||
{
|
||||
if (h_cfg.verification == 3)
|
||||
if (n_cfg.verification == 3)
|
||||
{
|
||||
char hashFilename[HASH_FILENAME_SZ];
|
||||
strncpy(hashFilename, outFilename, OUT_FILENAME_SZ - 1);
|
||||
|
@ -201,7 +201,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
|
|||
// Check every time or every 4.
|
||||
// Every 4 protects from fake sd, sector corruption and frequent I/O corruption.
|
||||
// Full provides all that, plus protection from extremely rare I/O corruption.
|
||||
if ((h_cfg.verification >= 2) || !(sparseShouldVerify % 4))
|
||||
if ((n_cfg.verification >= 2) || !(sparseShouldVerify % 4))
|
||||
{
|
||||
if (!sdmmc_storage_read(storage, lba_curr, num, bufEm))
|
||||
{
|
||||
|
@ -214,7 +214,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
|
|||
|
||||
free(clmt);
|
||||
f_close(&fp);
|
||||
if (h_cfg.verification == 3)
|
||||
if (n_cfg.verification == 3)
|
||||
f_close(&hashFp);
|
||||
|
||||
return 1;
|
||||
|
@ -234,7 +234,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
|
|||
|
||||
free(clmt);
|
||||
f_close(&fp);
|
||||
if (h_cfg.verification == 3)
|
||||
if (n_cfg.verification == 3)
|
||||
f_close(&hashFp);
|
||||
|
||||
return 1;
|
||||
|
@ -255,13 +255,13 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
|
|||
|
||||
free(clmt);
|
||||
f_close(&fp);
|
||||
if (h_cfg.verification == 3)
|
||||
if (n_cfg.verification == 3)
|
||||
f_close(&hashFp);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (h_cfg.verification == 3)
|
||||
if (n_cfg.verification == 3)
|
||||
{
|
||||
// Transform computed hash to readable hexadecimal
|
||||
char hashStr[SHA256_SZ * 2 + 1];
|
||||
|
@ -505,7 +505,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t
|
|||
memset(&fp, 0, sizeof(fp));
|
||||
currPartIdx++;
|
||||
|
||||
if (h_cfg.verification)
|
||||
if (n_cfg.verification)
|
||||
{
|
||||
// Verify part.
|
||||
if (_dump_emmc_verify(gui, storage, lbaStartPart, outFilename, part))
|
||||
|
@ -677,7 +677,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t
|
|||
f_close(&fp);
|
||||
free(clmt);
|
||||
|
||||
if (h_cfg.verification)
|
||||
if (n_cfg.verification)
|
||||
{
|
||||
// Verify last part or single file backup.
|
||||
if (_dump_emmc_verify(gui, storage, lbaStartPart, outFilename, part))
|
||||
|
@ -867,7 +867,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
|
|||
timer = get_tmr_s() - timer;
|
||||
sdmmc_storage_end(&storage);
|
||||
|
||||
if (res && h_cfg.verification)
|
||||
if (res && n_cfg.verification)
|
||||
s_printf(txt_buf, "Time taken: %dm %ds.\n#96FF00 Finished and verified!#", timer / 60, timer % 60);
|
||||
else if (res)
|
||||
s_printf(txt_buf, "Time taken: %dm %ds.\nFinished!", timer / 60, timer % 60);
|
||||
|
@ -1096,7 +1096,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
|
|||
memset(&fp, 0, sizeof(fp));
|
||||
currPartIdx++;
|
||||
|
||||
if (h_cfg.verification && !gui->raw_emummc)
|
||||
if (n_cfg.verification && !gui->raw_emummc)
|
||||
{
|
||||
// Verify part.
|
||||
if (_dump_emmc_verify(gui, storage, lbaStartPart, outFilename, part))
|
||||
|
@ -1218,7 +1218,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
|
|||
f_close(&fp);
|
||||
free(clmt);
|
||||
|
||||
if (h_cfg.verification && !gui->raw_emummc)
|
||||
if (n_cfg.verification && !gui->raw_emummc)
|
||||
{
|
||||
// Verify restored data.
|
||||
if (_dump_emmc_verify(gui, storage, lbaStartPart, outFilename, part))
|
||||
|
@ -1433,7 +1433,7 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
|
|||
timer = get_tmr_s() - timer;
|
||||
sdmmc_storage_end(&storage);
|
||||
|
||||
if (res && h_cfg.verification)
|
||||
if (res && n_cfg.verification)
|
||||
s_printf(txt_buf, "Time taken: %dm %ds.\n#96FF00 Finished and verified!#", timer / 60, timer % 60);
|
||||
else if (res)
|
||||
s_printf(txt_buf, "Time taken: %dm %ds.\nFinished!", timer / 60, timer % 60);
|
||||
|
|
|
@ -273,7 +273,7 @@ static lv_res_t _slider_brightness_action(lv_obj_t * slider)
|
|||
|
||||
static lv_res_t _data_verification_action(lv_obj_t *ddlist)
|
||||
{
|
||||
h_cfg.verification = lv_ddlist_get_selected(ddlist);
|
||||
n_cfg.verification = lv_ddlist_get_selected(ddlist);
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
@ -388,7 +388,6 @@ void create_tab_options(lv_theme_t *th, lv_obj_t *parent)
|
|||
// Create Auto NoGC button.
|
||||
lv_obj_t *btn2 = lv_btn_create(sw_h2, NULL);
|
||||
nyx_create_onoff_button(th, sw_h2, btn2, SYMBOL_SHRK" Auto NoGC", auto_nogc_toggle, true);
|
||||
|
||||
lv_obj_align(btn2, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 10);
|
||||
|
||||
label_txt2 = lv_label_create(sw_h2, NULL);
|
||||
|
@ -454,7 +453,7 @@ void create_tab_options(lv_theme_t *th, lv_obj_t *parent)
|
|||
"Sparse (Fast) \n"
|
||||
"Full (Slow)\n"
|
||||
"Full (Hashes)");
|
||||
lv_ddlist_set_selected(ddlist2, h_cfg.verification);
|
||||
lv_ddlist_set_selected(ddlist2, n_cfg.verification);
|
||||
lv_obj_align(ddlist2, label_txt, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 3 / 8, 0);
|
||||
lv_ddlist_set_action(ddlist2, _data_verification_action);
|
||||
|
||||
|
|
|
@ -210,53 +210,62 @@ out:
|
|||
void load_saved_configuration()
|
||||
{
|
||||
LIST_INIT(ini_sections);
|
||||
LIST_INIT(ini_nyx_sections);
|
||||
|
||||
// Load hekate configuration.
|
||||
if (ini_parse(&ini_sections, "bootloader/hekate_ipl.ini", false))
|
||||
{
|
||||
// Load configuration.
|
||||
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
|
||||
{
|
||||
// Skip other ini entries.
|
||||
if (ini_sec->type == INI_CHOICE)
|
||||
// Only parse config section.
|
||||
if (ini_sec->type == INI_CHOICE && !strcmp(ini_sec->name, "config"))
|
||||
{
|
||||
if (!strcmp(ini_sec->name, "config"))
|
||||
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
|
||||
{
|
||||
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
|
||||
if (!strcmp("autoboot", kv->key))
|
||||
h_cfg.autoboot = atoi(kv->val);
|
||||
else if (!strcmp("autoboot_list", kv->key))
|
||||
h_cfg.autoboot_list = atoi(kv->val);
|
||||
else if (!strcmp("bootwait", kv->key))
|
||||
h_cfg.bootwait = atoi(kv->val);
|
||||
else if (!strcmp("backlight", kv->key))
|
||||
{
|
||||
if (!strcmp("autoboot", kv->key))
|
||||
h_cfg.autoboot = atoi(kv->val);
|
||||
else if (!strcmp("autoboot_list", kv->key))
|
||||
h_cfg.autoboot_list = atoi(kv->val);
|
||||
else if (!strcmp("bootwait", kv->key))
|
||||
h_cfg.bootwait = atoi(kv->val);
|
||||
else if (!strcmp("verification", kv->key))
|
||||
h_cfg.verification = atoi(kv->val);
|
||||
else if (!strcmp("backlight", kv->key))
|
||||
{
|
||||
h_cfg.backlight = atoi(kv->val);
|
||||
if (h_cfg.backlight <= 20)
|
||||
h_cfg.backlight = 30;
|
||||
}
|
||||
else if (!strcmp("autohosoff", kv->key))
|
||||
h_cfg.autohosoff = atoi(kv->val);
|
||||
else if (!strcmp("autonogc", kv->key))
|
||||
h_cfg.autonogc = atoi(kv->val);
|
||||
else if (!strcmp("updater2p", kv->key))
|
||||
h_cfg.updater2p = atoi(kv->val);
|
||||
else if (!strcmp("brand", kv->key))
|
||||
{
|
||||
h_cfg.brand = malloc(strlen(kv->val) + 1);
|
||||
strcpy(h_cfg.brand, kv->val);
|
||||
}
|
||||
else if (!strcmp("tagline", kv->key))
|
||||
{
|
||||
h_cfg.tagline = malloc(strlen(kv->val) + 1);
|
||||
strcpy(h_cfg.tagline, kv->val);
|
||||
}
|
||||
h_cfg.backlight = atoi(kv->val);
|
||||
if (h_cfg.backlight <= 20)
|
||||
h_cfg.backlight = 30;
|
||||
}
|
||||
|
||||
continue;
|
||||
else if (!strcmp("autohosoff", kv->key))
|
||||
h_cfg.autohosoff = atoi(kv->val);
|
||||
else if (!strcmp("autonogc", kv->key))
|
||||
h_cfg.autonogc = atoi(kv->val);
|
||||
else if (!strcmp("updater2p", kv->key))
|
||||
h_cfg.updater2p = atoi(kv->val);
|
||||
else if (!strcmp("brand", kv->key))
|
||||
h_cfg.brand = kv->val;
|
||||
else if (!strcmp("tagline", kv->key))
|
||||
h_cfg.tagline = kv->val;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load Nyx configuration.
|
||||
if (ini_parse(&ini_nyx_sections, "bootloader/nyx.ini", false))
|
||||
{
|
||||
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_nyx_sections, link)
|
||||
{
|
||||
// Only parse config section.
|
||||
if (ini_sec->type == INI_CHOICE && !strcmp(ini_sec->name, "config"))
|
||||
{
|
||||
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
|
||||
{
|
||||
if (!strcmp("verification", kv->key))
|
||||
n_cfg.verification = atoi(kv->val);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue