From 0e1a90ea1da0c1737363e9412781f734f39048d4 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Tue, 6 Jul 2021 21:02:37 +0100 Subject: x1000: SPL refactoring This streamlines the boot code a bit and reduces target specific boilerplate. The clock init hack used by the bootloader has been "standardized" and works for the main Rockbox binary now, so you can boot rockbox.bin over USB without special hacks. Change-Id: I7c1fac37df5a45873583ce6818eaedb9f71a782b --- firmware/target/mips/ingenic_x1000/system-x1000.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'firmware/target/mips/ingenic_x1000/system-x1000.c') diff --git a/firmware/target/mips/ingenic_x1000/system-x1000.c b/firmware/target/mips/ingenic_x1000/system-x1000.c index 779bb2055c..d43c8e67e4 100644 --- a/firmware/target/mips/ingenic_x1000/system-x1000.c +++ b/firmware/target/mips/ingenic_x1000/system-x1000.c @@ -27,6 +27,7 @@ #include "dma-x1000.h" #include "irq-x1000.h" #include "clk-x1000.h" +#include "boot-x1000.h" #include "x1000/cpm.h" #include "x1000/ost.h" #include "x1000/tcu.h" @@ -59,6 +60,27 @@ static void system_init_irq(void) write_c0_cause(M_CauseIV); } +/* First function called by crt0.S */ +void system_early_init(void) +{ +#if defined(FIIO_M3K) && !defined(BOOTLOADER) + /* HACK for compatibility: CPM scratchpad has undefined contents at + * time of reset and old bootloader revisions don't initialize it. + * Therefore we can't rely on its contents on the FiiO M3K. This does + * kind of break the entire point of boot flags, but right now they + * are really only used by the bootloader so it's not a huge issue. + * This hack should keep everything working as usual. */ + if(jz_readf(CPM_MPCR, ON) == 0) { + init_boot_flags(); + set_boot_option(BOOT_OPTION_ROCKBOX); + set_boot_flag(BOOT_FLAG_CLK_INIT); + } +#endif + + /* Finish up clock init */ + clk_init(); +} + /* First thing called from Rockbox main() */ void system_init(void) { -- cgit v1.2.3