From 925f08e0b9c46dd3b34f0b073abf233de1820986 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 14 Dec 2025 17:12:42 +0100 Subject: [PATCH] implements halt using WFI if hartid!=0 and multicore --- env/riscv_vp/init.c | 5 ++++- env/start.S | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/env/riscv_vp/init.c b/env/riscv_vp/init.c index dc60394..447a4f6 100644 --- a/env/riscv_vp/init.c +++ b/env/riscv_vp/init.c @@ -103,7 +103,10 @@ void __attribute__((weak)) _init() { while(i < NUM_INTERRUPTS) { localISR[i++] = default_handler; } - +#endif +#if defined(NUM_HARTS) && NUM_HARTS > 1 + for(int i = 1; i < NUM_HARTS; ++i) + set_aclint_msip(aclint, i, 1); #endif } diff --git a/env/start.S b/env/start.S index 3f83220..e6849ca 100644 --- a/env/start.S +++ b/env/start.S @@ -30,11 +30,14 @@ _start: 2: la t0, trap_entry csrw mtvec, t0 -#ifdef HARTX_WAIT4WFI +#if defined(NUM_HARTS) && NUM_HARTS>1 /* block other cores until hart 0 has finished initialization */ csrr t0, mhartid beqz t0, hart0_init + /* enable MSI locally */ + csrwi mie, 0x8 wfi + csrw mie, zero j hartx_start hart0_init: #endif