xtensa: exiting simulator on fatal errors

There was old code to exit the simulator when there is a fatal
error. This updates the #ifdef and the function name so that
it can be used to exit both QEMU and simulator when a fatal
error occurs. This should help with twister runs as this will
fail immediately instead of having wait for timeout.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2024-02-15 11:50:43 -08:00 committed by David Leach
parent 33f586f312
commit d89e7f63fd

View file

@ -16,7 +16,7 @@
#include <zephyr/logging/log.h> #include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
#ifdef XT_SIMULATOR #if defined(CONFIG_SIMULATOR_XTENSA) || defined(XT_SIMULATOR)
#include <xtensa/simcall.h> #include <xtensa/simcall.h>
#endif #endif
@ -109,8 +109,8 @@ void xtensa_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
z_fatal_error(reason, esf); z_fatal_error(reason, esf);
} }
#ifdef XT_SIMULATOR #if defined(CONFIG_SIMULATOR_XTENSA) || defined(XT_SIMULATOR)
void exit(int return_code) void xtensa_simulator_exit(int return_code)
{ {
__asm__ ( __asm__ (
"mov a3, %[code]\n\t" "mov a3, %[code]\n\t"
@ -119,13 +119,13 @@ void exit(int return_code)
: :
: [code] "r" (return_code), [call] "i" (SYS_exit) : [code] "r" (return_code), [call] "i" (SYS_exit)
: "a3", "a2"); : "a3", "a2");
}
#endif
#ifdef XT_SIMULATOR CODE_UNREACHABLE;
FUNC_NORETURN void z_system_halt(unsigned int reason) }
FUNC_NORETURN void arch_system_halt(unsigned int reason)
{ {
exit(255 - reason); xtensa_simulator_exit(255 - reason);
CODE_UNREACHABLE; CODE_UNREACHABLE;
} }
#endif #endif