matos/arch/x86/exception.c

24 lines
530 B
C
Raw Normal View History

2018-07-20 15:41:58 +02:00
#include "exception.h"
#include "idt.h"
#include "interrupt.h"
#include "irq.h"
exception_handler exception_handler_array[EXCEPTION_NUM] = {
NULL,
};
int exceptionSetRoutine(int exception, exception_handler handler)
{
uint32_t flags;
if ((exception < 0) || exception >= EXCEPTION_NUM)
return -1;
2018-07-20 15:41:58 +02:00
disable_IRQs(flags);
2018-07-20 15:41:58 +02:00
exception_handler_array[exception] = handler;
2018-07-20 15:41:58 +02:00
idt_set_handler(EXCEPTION_INTERRUPT_BASE_ADDRESS + exception, (unsigned int)handler, 0);
restore_IRQs(flags);
return 0;
2018-07-20 15:41:58 +02:00
}