From 708863358e778e1ae50fe219ebbc3cc6ce7bced6 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sat, 4 Jul 2020 21:44:39 +0300 Subject: [PATCH] hos: Move warmboot patching into pkg1 object --- bootloader/hos/hos.c | 7 ++----- bootloader/hos/pkg1.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index 1a4a616..6aee6c3 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -880,11 +880,8 @@ int hos_launch(ini_sec_t *cfg) _hos_crit_error("No warmboot provided!"); goto error; } - // Else we patch it to allow downgrading. - patch_t *warmboot_patchset = ctxt.pkg1_id->warmboot_patchset; - gfx_printf("%kPatching Warmboot%k\n", 0xFFFFBA00, 0xFFCCCCCC); - for (u32 i = 0; warmboot_patchset[i].off != 0xFFFFFFFF; i++) - *(vu32 *)(ctxt.pkg1_id->warmboot_base + warmboot_patchset[i].off) = warmboot_patchset[i].val; + + pkg1_warmboot_patch((void *)&ctxt); } // Replace 'SecureMonitor' if requested or patch Pkg2 checks if needed. diff --git a/bootloader/hos/pkg1.c b/bootloader/hos/pkg1.c index cfd16f5..073ed1d 100644 --- a/bootloader/hos/pkg1.c +++ b/bootloader/hos/pkg1.c @@ -220,6 +220,18 @@ const u8 *pkg1_unpack(void *wm_dst, u32 *wb_sz, void *sm_dst, void *ldr_dst, con return sec_map; } + +void pkg1_warmboot_patch(void *hos_ctxt) +{ + launch_ctxt_t *ctxt = (launch_ctxt_t *)hos_ctxt; + + // Patch warmboot on T210 to allow downgrading. + patch_t *warmboot_patchset = ctxt->pkg1_id->warmboot_patchset; + gfx_printf("%kPatching Warmboot%k\n", 0xFFFFBA00, 0xFFCCCCCC); + for (u32 i = 0; warmboot_patchset[i].off != 0xFFFFFFFF; i++) + *(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)