From 47ba20d762fdbacbb1bf9f24dc3f19ea4649b1e6 Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Sun, 22 Mar 2026 22:47:26 +0100 Subject: [PATCH] Changes simulation ending mechanism (exit function) As higher optimization might actually schedule a jump to self while waiting for timer interrupts this is a more robust implementation in that sense --- port/moonlight/src/bootup.c | 6 +++--- test/threadx/run_threadx_test.sh | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/port/moonlight/src/bootup.c b/port/moonlight/src/bootup.c index 69df782..17ac817 100644 --- a/port/moonlight/src/bootup.c +++ b/port/moonlight/src/bootup.c @@ -10,6 +10,7 @@ #include #include #include +#include #ifdef __cplusplus #define EXTERN_C extern "C" #else @@ -121,10 +122,9 @@ void _initialize(void) { // This should never be called. Busy loop with the CPU in idle state. void _exit(int exit_code) { (void)exit_code; - // Halt + csr_clr_bits_mie(MIE_MTI_BIT_MASK); + csr_clr_bits_mstatus(MSTATUS_MIE_BIT_MASK); while (1) { __asm__ volatile ("wfi"); - // Incase periodic interrupts are scheduled (e.g. timer), additionaly jump to self - for (;;); } } \ No newline at end of file diff --git a/test/threadx/run_threadx_test.sh b/test/threadx/run_threadx_test.sh index e728176..fa40c93 100755 --- a/test/threadx/run_threadx_test.sh +++ b/test/threadx/run_threadx_test.sh @@ -21,7 +21,6 @@ trap 'rm -f "$log_file"' EXIT "$simulator" \ --isa="$isa" \ -f "$elf" \ - -p tb.top.core.finish_condition=1 \ -m 10s \ | tee "$log_file"