SPARC: implement ARCH_EXCEPT()

Introduce a new software trap 15 which is generated by the
ARCH_EXCEPT() function macro.

The handler for this software trap calls z_sparc_fatal_error() and
finally z_fatal_error() with "reason" and ESF as arguments.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
This commit is contained in:
Martin Åberg 2021-01-12 15:21:57 +01:00 committed by Ioannis Glaropoulos
commit c2b1e8d2f5
4 changed files with 43 additions and 15 deletions

View file

@ -34,6 +34,7 @@
*/
#define SPARC_SW_TRAP_FLUSH_WINDOWS 0x03
#define SPARC_SW_TRAP_SET_PIL 0x09
#define SPARC_SW_TRAP_EXCEPT 0x0F
#ifndef _ASMLANGUAGE
#include <sys/util.h>
@ -111,6 +112,19 @@ struct __esf {
typedef struct __esf z_arch_esf_t;
#define ARCH_EXCEPT(reason_p) \
do { \
register uint32_t _g1 __asm__("g1") = reason_p; \
\
__asm__ volatile ( \
"ta %[vector]\n\t" \
: \
: [vector] "i" (SPARC_SW_TRAP_EXCEPT), "r" (_g1) \
: "memory" \
); \
CODE_UNREACHABLE; \
} while (false)
#ifdef __cplusplus
}
#endif