mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-26 11:42:09 +00:00
hos: update fss0 parser
- Move extra key checks in the parser - Remove some sept leftover checks - Update printing to reflect PK3 name (FSS0 -> FSS/PK3)
This commit is contained in:
parent
7fb10b0242
commit
a2d18f0848
3 changed files with 19 additions and 27 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Atmosphère Fusée Secondary Storage parser.
|
* Atmosphère Fusée Secondary Storage (Package3) parser.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019-2021 CTCaer
|
* Copyright (c) 2019-2021 CTCaer
|
||||||
*
|
*
|
||||||
|
@ -82,9 +82,9 @@ typedef struct _fss_content_t
|
||||||
char name[0x10];
|
char name[0x10];
|
||||||
} fss_content_t;
|
} fss_content_t;
|
||||||
|
|
||||||
static void _update_r2p(launch_ctxt_t *ctxt, const char *path)
|
static void _set_fss_path_and_update_r2p(launch_ctxt_t *ctxt, const char *path)
|
||||||
{
|
{
|
||||||
char *r2p_path = malloc(512);
|
char *r2p_path = malloc(256);
|
||||||
u32 path_len = strlen(path);
|
u32 path_len = strlen(path);
|
||||||
|
|
||||||
strcpy(r2p_path, path);
|
strcpy(r2p_path, path);
|
||||||
|
@ -101,16 +101,11 @@ static void _update_r2p(launch_ctxt_t *ctxt, const char *path)
|
||||||
|
|
||||||
free(r2p_payload);
|
free(r2p_payload);
|
||||||
|
|
||||||
// Save fss0 parrent path.
|
// Save FSS0 parent path.
|
||||||
if (ctxt)
|
|
||||||
{
|
|
||||||
r2p_path[path_len] = 0;
|
r2p_path[path_len] = 0;
|
||||||
ctxt->fss0_main_path = r2p_path;
|
ctxt->fss0_main_path = r2p_path;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
path_len--;
|
path_len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +117,7 @@ int parse_fss(launch_ctxt_t *ctxt, const char *path)
|
||||||
FIL fp;
|
FIL fp;
|
||||||
|
|
||||||
bool stock = false;
|
bool stock = false;
|
||||||
|
bool experimental = false;
|
||||||
|
|
||||||
// Skip if stock and Exosphere and warmboot are not needed.
|
// Skip if stock and Exosphere and warmboot are not needed.
|
||||||
bool pkg1_old = ctxt->pkg1_id->kb <= KB_FIRMWARE_VERSION_620; // Should check if t210b01?
|
bool pkg1_old = ctxt->pkg1_id->kb <= KB_FIRMWARE_VERSION_620; // Should check if t210b01?
|
||||||
|
@ -132,6 +128,10 @@ int parse_fss(launch_ctxt_t *ctxt, const char *path)
|
||||||
if (!strcmp("stock", kv->key))
|
if (!strcmp("stock", kv->key))
|
||||||
if (kv->val[0] == '1')
|
if (kv->val[0] == '1')
|
||||||
stock = true;
|
stock = true;
|
||||||
|
|
||||||
|
if (!strcmp("fss0experimental", kv->key))
|
||||||
|
if (kv->val[0] == '1')
|
||||||
|
experimental = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HOS_MARIKO_STOCK_SECMON
|
#ifdef HOS_MARIKO_STOCK_SECMON
|
||||||
|
@ -142,12 +142,13 @@ int parse_fss(launch_ctxt_t *ctxt, const char *path)
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Try to open FSS0.
|
||||||
if (f_open(&fp, path, FA_READ) != FR_OK)
|
if (f_open(&fp, path, FA_READ) != FR_OK)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
void *fss = malloc(f_size(&fp));
|
void *fss = malloc(f_size(&fp));
|
||||||
|
|
||||||
// Read first 1024 bytes of the fss file.
|
// Read first 1024 bytes of the FSS0 file.
|
||||||
f_read(&fp, fss, 1024, NULL);
|
f_read(&fp, fss, 1024, NULL);
|
||||||
|
|
||||||
// Get FSS0 Meta header offset.
|
// Get FSS0 Meta header offset.
|
||||||
|
@ -157,7 +158,7 @@ int parse_fss(launch_ctxt_t *ctxt, const char *path)
|
||||||
// Check if valid FSS0 and parse it.
|
// Check if valid FSS0 and parse it.
|
||||||
if (fss_meta->magic == FSS0_MAGIC)
|
if (fss_meta->magic == FSS0_MAGIC)
|
||||||
{
|
{
|
||||||
gfx_printf("Found FSS0, Atmosphere %d.%d.%d-%08x\n"
|
gfx_printf("Found FSS/PK3, Atmosphere %d.%d.%d-%08x\n"
|
||||||
"Max HOS: %d.%d.%d\n"
|
"Max HOS: %d.%d.%d\n"
|
||||||
"Unpacking.. ",
|
"Unpacking.. ",
|
||||||
fss_meta->version >> 24, (fss_meta->version >> 16) & 0xFF, (fss_meta->version >> 8) & 0xFF, fss_meta->git_rev,
|
fss_meta->version >> 24, (fss_meta->version >> 16) & 0xFF, (fss_meta->version >> 8) & 0xFF, fss_meta->git_rev,
|
||||||
|
@ -177,8 +178,8 @@ int parse_fss(launch_ctxt_t *ctxt, const char *path)
|
||||||
if ((curr_fss_cnt[i].offset + curr_fss_cnt[i].size) > fss_meta->size)
|
if ((curr_fss_cnt[i].offset + curr_fss_cnt[i].size) > fss_meta->size)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If content is experimental and experimental flag is not enabled, skip it.
|
// If content is experimental and experimental config is not enabled, skip it.
|
||||||
if ((curr_fss_cnt[i].flags0 & CNT_FLAG0_EXPERIMENTAL) && !ctxt->fss0_experimental)
|
if ((curr_fss_cnt[i].flags0 & CNT_FLAG0_EXPERIMENTAL) && !experimental)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Prepare content.
|
// Prepare content.
|
||||||
|
@ -229,7 +230,8 @@ int parse_fss(launch_ctxt_t *ctxt, const char *path)
|
||||||
gfx_printf("Done!\n");
|
gfx_printf("Done!\n");
|
||||||
f_close(&fp);
|
f_close(&fp);
|
||||||
|
|
||||||
_update_r2p(ctxt, path);
|
// Set FSS0 path and update r2p if needed.
|
||||||
|
_set_fss_path_and_update_r2p(ctxt, path);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,6 @@ typedef struct _launch_ctxt_t
|
||||||
|
|
||||||
char *fss0_main_path;
|
char *fss0_main_path;
|
||||||
u32 fss0_hosver;
|
u32 fss0_hosver;
|
||||||
bool fss0_experimental;
|
|
||||||
bool atmosphere;
|
bool atmosphere;
|
||||||
|
|
||||||
exo_ctxt_t exo_ctx;
|
exo_ctxt_t exo_ctx;
|
||||||
|
|
|
@ -262,15 +262,6 @@ static int _config_exo_cal0_writes_enable(launch_ctxt_t *ctxt, const char *value
|
||||||
|
|
||||||
static int _config_fss(launch_ctxt_t *ctxt, const char *value)
|
static int _config_fss(launch_ctxt_t *ctxt, const char *value)
|
||||||
{
|
{
|
||||||
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ctxt->cfg->kvs, link)
|
|
||||||
{
|
|
||||||
if (!strcmp("fss0experimental", kv->key))
|
|
||||||
{
|
|
||||||
ctxt->fss0_experimental = *kv->val == '1';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return parse_fss(ctxt, value);
|
return parse_fss(ctxt, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue