blob: e7c41801d8a91ed89eaf51fff501ada75233553e [file] [log] [blame]
swissChiliaed6ff32021-05-29 17:51:04 -07001#include "pic.h"
2#include <log.h>
3
4#define DECLARE_INTERRUPT(sym, name) \
5 static void sym##_h(struct registers *regs) \
6 { \
swissChili9bd74de2021-06-15 20:30:48 -07007 kprintf(ERROR "Fault " name ": eip = 0x%x, err = 0x%x\n", regs->eip, \
swissChiliaed6ff32021-05-29 17:51:04 -07008 regs->error_code); \
9 asm volatile("cli"); \
10 kpanic(name); \
11 }
12
13#define ADD_INTERRUPT(sym, num) add_interrupt_handler(num, sym##_h)
14
15DECLARE_INTERRUPT(gp, "#GP")
16DECLARE_INTERRUPT(pf, "#PF")
17
18void init_faults()
19{
20 ADD_INTERRUPT(gp, 13);
21 ADD_INTERRUPT(pf, 14);
22}