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
This commit is contained in:
2026-03-22 22:47:26 +01:00
parent 59b9e9e7e3
commit 47ba20d762
2 changed files with 3 additions and 4 deletions

View File

@@ -10,6 +10,7 @@
#include <string.h>
#include <picotls.h>
#include <tx_port.h>
#include <riscv-csr.h>
#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 (;;);
}
}