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 */