summaryrefslogtreecommitdiff
path: root/payloads/libpayload/include
diff options
context:
space:
mode:
Diffstat (limited to 'payloads/libpayload/include')
-rw-r--r--payloads/libpayload/include/arm/arch/exception.h10
-rw-r--r--payloads/libpayload/include/arm64/arch/exception.h2
-rw-r--r--payloads/libpayload/include/exception.h5
-rw-r--r--payloads/libpayload/include/x86/arch/exception.h43
4 files changed, 39 insertions, 21 deletions
diff --git a/payloads/libpayload/include/arm/arch/exception.h b/payloads/libpayload/include/arm/arch/exception.h
index c6864a5ad2..fbbce5ed3d 100644
--- a/payloads/libpayload/include/arm/arch/exception.h
+++ b/payloads/libpayload/include/arm/arch/exception.h
@@ -32,13 +32,19 @@
#include <stdint.h>
+void exception_dispatch(u32 idx);
void set_vbar(uint32_t vbar);
struct exception_state
{
- uint32_t cpsr;
- uint32_t regs[16];
+ u32 regs[16];
+ u32 cpsr;
} __attribute__((packed));
+extern struct exception_state exception_state;
+
+extern u32 exception_stack[];
+extern u32 *exception_stack_end;
+extern struct exception_state *exception_state_ptr;
enum {
EXC_UNDEF = 1,
diff --git a/payloads/libpayload/include/arm64/arch/exception.h b/payloads/libpayload/include/arm64/arch/exception.h
index f4a7552db9..44a4e5998d 100644
--- a/payloads/libpayload/include/arm64/arch/exception.h
+++ b/payloads/libpayload/include/arm64/arch/exception.h
@@ -41,6 +41,8 @@ struct exception_state
uint64_t regs[31];
} __attribute__((packed));
+extern struct exception_state *exception_state;
+
enum {
EXC_INV = 0,
EXC_SYNC = 1,
diff --git a/payloads/libpayload/include/exception.h b/payloads/libpayload/include/exception.h
index 1d9b832c07..67923ea9af 100644
--- a/payloads/libpayload/include/exception.h
+++ b/payloads/libpayload/include/exception.h
@@ -32,9 +32,10 @@
#include <arch/exception.h>
-typedef void (*exception_hook)(int type, struct exception_state *state);
+/* Return 1 if the exception was handled, 0 to proceed to the next handler. */
+typedef int (*exception_hook)(u32 type);
void exception_init(void);
-void exception_install_hook(int type, exception_hook hook);
+void exception_install_hook(exception_hook h);
#endif
diff --git a/payloads/libpayload/include/x86/arch/exception.h b/payloads/libpayload/include/x86/arch/exception.h
index 82f2ca0a32..fe222aa4f2 100644
--- a/payloads/libpayload/include/x86/arch/exception.h
+++ b/payloads/libpayload/include/x86/arch/exception.h
@@ -32,28 +32,37 @@
#include <stdint.h>
-void exception_dispatch(void);
void exception_init_asm(void);
+void exception_dispatch(void);
struct exception_state
{
- uint32_t eax;
- uint32_t ecx;
- uint32_t edx;
- uint32_t ebx;
- uint32_t esp;
- uint32_t ebp;
- uint32_t esi;
- uint32_t edi;
- uint32_t eip;
- uint32_t eflags;
- uint32_t cs;
- uint32_t ss;
- uint32_t ds;
- uint32_t es;
- uint32_t fs;
- uint32_t gs;
+ /* Careful: x86/gdb.c currently relies on the size and order of regs. */
+ struct {
+ u32 eax;
+ u32 ecx;
+ u32 edx;
+ u32 ebx;
+ u32 esp;
+ u32 ebp;
+ u32 esi;
+ u32 edi;
+ u32 eip;
+ u32 eflags;
+ u32 cs;
+ u32 ss;
+ u32 ds;
+ u32 es;
+ u32 fs;
+ u32 gs;
+ } regs;
+ u32 error_code;
+ u32 vector;
} __attribute__((packed));
+extern struct exception_state *exception_state;
+
+extern u32 exception_stack[];
+extern u32 *exception_stack_end;
enum {
EXC_DE = 0, /* Divide by zero */