From 6a3ce86e105ac8df6d461fa060891e89ba888c24 Mon Sep 17 00:00:00 2001 From: Michael LeMay Date: Tue, 23 Aug 2016 11:34:32 -0700 Subject: [PATCH] galileo: Add general protection exception handler This patch adds a general protection exception handler that prints a message indicating the faulting instruction and the error code. This is useful when debugging general protection exceptions. --- platform/galileo/contiki-main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/platform/galileo/contiki-main.c b/platform/galileo/contiki-main.c index 5e95c4902..13edfca2d 100644 --- a/platform/galileo/contiki-main.c +++ b/platform/galileo/contiki-main.c @@ -76,6 +76,14 @@ app_main(void) halt(); } /*---------------------------------------------------------------------------*/ +static void +gp_fault_handler(struct interrupt_context context) +{ + fprintf(stderr, "General protection exception @%08x (ec: %u)\n", + context.eip, context.error_code); + halt(); +} +/*---------------------------------------------------------------------------*/ /* Kernel entrypoint */ int main(void) @@ -91,6 +99,7 @@ main(void) * Galileo Gen2 FTDI header */ quarkX1000_uart_init_port(QUARK_X1000_UART_1, 115200); + SET_EXCEPTION_HANDLER(13, 1, gp_fault_handler); clock_init(); rtimer_init();