From a87f93d8ffc6cf224947e88aee9cb912b8ec6f50 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Fri, 4 Mar 2022 00:59:39 +0000 Subject: [PATCH] x1000: add function for booting linux kernels Change-Id: I0750b084fe88d21a8686daf0681b32b1dcba8fec --- .../target/mips/ingenic_x1000/boot-x1000.c | 29 +++++++++++++++++++ .../target/mips/ingenic_x1000/boot-x1000.h | 3 ++ 2 files changed, 32 insertions(+) diff --git a/firmware/target/mips/ingenic_x1000/boot-x1000.c b/firmware/target/mips/ingenic_x1000/boot-x1000.c index d3e6eb35d7..3ba060ffc4 100644 --- a/firmware/target/mips/ingenic_x1000/boot-x1000.c +++ b/firmware/target/mips/ingenic_x1000/boot-x1000.c @@ -102,6 +102,35 @@ void x1000_boot_rockbox(const void* source, size_t length) while(1); } +void x1000_boot_linux(const void* source, size_t length, + void* load, void* entry, const char* args) +{ + size_t args_len = strlen(args); + + disable_irq(); + + /* --- Beyond this point, do not call into DRAM --- */ + + void* safe_mem = (void*)X1000_IRAM_END; + + /* copy argument string to a safe location */ + char* args_copy = safe_mem + 32; + iram_memmove(args_copy, args, args_len); + + /* generate argv array */ + char** argv = safe_mem; + argv[0] = NULL; + argv[1] = args_copy; + + iram_memmove(load, source, length); + commit_discard_idcache(); + + typedef void(*entry_fn)(long, char**, long, long); + entry_fn fn = (entry_fn)entry; + fn(2, argv, 0, 0); + while(1); +} + void rolo_restart(const unsigned char* source, unsigned char* dest, int length) { (void)dest; diff --git a/firmware/target/mips/ingenic_x1000/boot-x1000.h b/firmware/target/mips/ingenic_x1000/boot-x1000.h index 620d7de89a..9faba649b5 100644 --- a/firmware/target/mips/ingenic_x1000/boot-x1000.h +++ b/firmware/target/mips/ingenic_x1000/boot-x1000.h @@ -47,6 +47,9 @@ enum { void x1000_boot_rockbox(const void* source, size_t length) __attribute__((section(".icode"))); +void x1000_boot_linux(const void* source, size_t length, + void* load, void* entry, const char* args) + __attribute__((section(".icode"))); /* Note: these functions are inlined to minimize SPL code size. * They are private to the X1000 early boot code anyway... */