xref: /aosp_15_r20/external/coreboot/src/arch/arm64/include/armv8/arch/exception.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 
3 #ifndef _ARCH_EXCEPTION_H
4 #define _ARCH_EXCEPTION_H
5 
6 #include <arch/transition.h>
7 #include <types.h>
8 
9 /* Initialize the exception handling on the current CPU. */
10 void exception_init(void);
11 
12 /* Initialize VBAR and SP_EL3. */
13 void exception_init_asm(void *exception_stack_end);
14 
15 /*
16  * Order matters for handling return values. The larger the value the higher
17  * the precedence.
18  */
19 enum {
20 	EXC_RET_IGNORED,
21 	EXC_RET_ABORT,
22 	EXC_RET_HANDLED,
23 	EXC_RET_HANDLED_DUMP_STATE,
24 };
25 
26 struct exception_handler {
27 	int (*handler)(struct exc_state *state, uint64_t vector_id);
28 	struct exception_handler *next;
29 };
30 
31 /*
32  * Register a handler provided with the associated vector id. Returns 0 on
33  * success, < 0 on error. Note that registration is not thread/interrupt safe.
34  */
35 enum cb_err exception_handler_register(uint64_t vid, struct exception_handler *h);
36 
37 /*
38  * Unregister a handler from the vector id. Return 0 on success, < 0 on error.
39  * Note that the unregistration is not thread/interrupt safe.
40  */
41 enum cb_err exception_handler_unregister(uint64_t vid, struct exception_handler *h);
42 
43 #endif
44