From 2d0ec274ac7a0b7e0556b2749f811efc53c1296b Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Mon, 16 Mar 2026 08:08:18 +0100 Subject: [PATCH] makes bootup multi core able --- port/moonlight/bootup.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/port/moonlight/bootup.c b/port/moonlight/bootup.c index d4f15f7..d212bcf 100644 --- a/port/moonlight/bootup.c +++ b/port/moonlight/bootup.c @@ -9,7 +9,7 @@ #include #include #include - +#include #ifdef __cplusplus #define EXTERN_C extern "C" #else @@ -50,7 +50,6 @@ extern int main(void); // The linker script will place this in the reset entry point. // It will be 'called' with no stack or C runtime configuration. -// NOTE - this only supports a single hart. // tp will not be initialized void _start(void) { // Setup SP and GP @@ -64,6 +63,24 @@ void _start(void) { "la gp, __global_pointer$;" ".option pop;" "la sp, _sp;" +#if defined(__riscv_zicsr) + "csrr t0, mhartid;" +#else + "li t0, 0;" +#endif + "la t1, __stack_size;" + "la t1, __stack_size;" + "la sp, _sp;" + // Loop incase M extension is not present + "1:;" + "beqz t0, 2f;" + "sub sp, sp, t1;" + "addi t0, t0, -1;" + "j 1b;" + "2:;" +#ifdef TX_THREAD_SMP_MAX_CORES + "call _tx_thread_smp_initialize_wait;" +#endif "jal zero, _initialize;" : /* output: none %0 */ : /* input: none */