Skip to content

Instantly share code, notes, and snippets.

@boochow
Created April 16, 2018 14:55
Show Gist options
  • Save boochow/0f3b3c02aad718aa0dfe8a173423e2b5 to your computer and use it in GitHub Desktop.
Save boochow/0f3b3c02aad718aa0dfe8a173423e2b5 to your computer and use it in GitHub Desktop.
// ldr pc, [pc, #24]
#define JMP_PC_24 0xe59ff018
typedef void (*exception_hander_t)(void);
typedef struct __attribute__((aligned(32))) _vector_table_t {
const unsigned int vector[8]; // all elements shoud be JMP_PC_24
exception_hander_t reset;
exception_hander_t undef;
exception_hander_t svc;
exception_hander_t prefetch_abort;
exception_hander_t data_abort;
exception_hander_t hypervisor_trap;
exception_hander_t irq;
exception_hander_t fiq;
} vector_table_t;
static void __attribute__((interrupt("UNDEF"))) undef_handler(void);
static void __attribute__((interrupt("SWI"))) svc_handler(void);
static void __attribute__((interrupt("ABORT"))) abort_handler(void);
static void __attribute__((interrupt("IRQ"))) irq_handler(void);
static void __attribute__((interrupt("FIQ"))) fiq_handler(void);
static void __attribute__((naked)) hangup(void);
static vector_table_t exception_vector = { \
.vector = { JMP_PC_24, JMP_PC_24, JMP_PC_24, JMP_PC_24, \
JMP_PC_24, JMP_PC_24, JMP_PC_24, JMP_PC_24 },
.reset = Init_Machine,
.undef = undef_handler,
.svc = svc_handler,
.prefetch_abort = abort_handler,
.data_abort = abort_handler,
.hypervisor_trap = hangup,
.irq = irq_handler,
.fiq = hangup
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment