hos/l4t: deduplicate sc7exit-b01 load

And remove obsolete MWS (L4T one deprecated it 3 years ago).
This commit is contained in:
CTCaer
2025-12-17 06:28:36 +02:00
parent 4af4692710
commit 73d96b7ca8
3 changed files with 26 additions and 72 deletions

View File

@@ -341,18 +341,6 @@ void pkg1_warmboot_patch(void *hos_ctxt)
*(vu32 *)(ctxt->pkg1_id->warmboot_base + warmboot_patchset[i].off) = warmboot_patchset[i].val;
}
static void _warmboot_filename(char *out, u32 fuses)
{
if (fuses < 16)
{
out[19] = '0';
itoa(fuses, &out[19 + 1], 16);
}
else
itoa(fuses, &out[19], 16);
strcat(out, ".bin");
}
int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base, u32 fuses_fw, u8 mkey)
{
launch_ctxt_t *ctxt = (launch_ctxt_t *)hos_ctxt;
@@ -360,45 +348,27 @@ int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base, u32 fuses_fw, u8 mke
if (h_cfg.t210b01)
{
u32 pa_id;
u32 fuses_max = 32; // Current ODM7 max.
u8 burnt_fuses = bit_count(fuse_read_odm(7));
// Save current warmboot in storage cache (MWS) and check if another one is needed.
// Check if not overridden.
if (!ctxt->warmboot)
{
char path[128];
strcpy(path, "warmboot_mariko/wb_");
_warmboot_filename(path, fuses_fw);
// Check if warmboot fw exists and save it.
if (ctxt->warmboot_size && f_stat(path, NULL))
{
f_mkdir("warmboot_mariko");
sd_save_to_file((void *)warmboot_base, ctxt->warmboot_size, path);
}
// Load warmboot fw from storage (MWS) if not matched.
// Load sc7exit-fw from storage if low.
if (burnt_fuses > fuses_fw)
{
u32 tmp_fuses = burnt_fuses;
while (true)
{
_warmboot_filename(path, burnt_fuses);
if (!f_stat(path, NULL))
{
ctxt->warmboot = sd_file_read(path, &ctxt->warmboot_size);
burnt_fuses = tmp_fuses;
break;
}
if (tmp_fuses >= fuses_max)
break;
tmp_fuses++;
}
//!TODO: Update on fuse burns.
void *warmboot_fw = sd_file_read("bootloader/sys/l4t/sc7exit_b01.bin", &ctxt->warmboot_size);
fuses_fw = *(u32 *)warmboot_fw;
// Check if proper warmboot firmware was not found.
if (!ctxt->warmboot)
// Check if high enough.
if (!warmboot_fw || burnt_fuses > fuses_fw)
res = 0;
else
{
ctxt->warmboot = warmboot_fw + sizeof(u32);
ctxt->warmboot_size -= sizeof(u32) * 2;
burnt_fuses = fuses_fw;
}
}
else // Replace burnt fuses with higher count.
burnt_fuses = fuses_fw;
@@ -406,7 +376,7 @@ int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base, u32 fuses_fw, u8 mke
// Configure warmboot parameters. Anything lower than 6.0.0 is not supported.
// From 7.0.0 and up, it's not derived from PA segment but it's 0x21 * fuses.
pa_id = 0x21 * burnt_fuses;
u32 pa_id = 0x21 * burnt_fuses;
if (burnt_fuses <= 8) // Old method.
pa_id -= 0x60;