matos/core/exception_handler.c

32 lines
1.1 KiB
C
Raw Normal View History

2018-07-20 15:41:58 +02:00
#include "exception.h"
#include "vga.h"
// Need GCC > 6
__attribute__((interrupt)) void print_handler(struct interrupt_frame *frame, ulong error_code)
{
printStringDetails("EXCEPTION", RED, BLACK, 0, VGA_HEIGHT - 1);
printIntDetails(error_code, RED, BLACK, 11, VGA_HEIGHT - 1);
(void)frame;
(void)error_code;
}
2018-11-13 18:02:47 +01:00
2018-11-16 15:00:31 +01:00
// c.f. https://wiki.osdev.org/Paging#Handling
// error_code bit0: Present ?
// bit1: Trying to write ?
// bit2: User page try to access?
2018-11-20 17:43:19 +01:00
__attribute__((interrupt)) void pagefault_handler(struct interrupt_frame *frame,
ulong error_code)
{
// A page fault has occurred.
// The faulting address is stored in the CR2 register.
uint32_t faulting_address;
asm volatile("mov %%cr2, %0" : "=r"(faulting_address));
2018-11-13 18:02:47 +01:00
printStringDetails("PAGE FAULT", RED, BLACK, 0, VGA_HEIGHT - 1);
printIntDetails(error_code, RED, BLACK, 11, VGA_HEIGHT - 1);
2018-11-20 17:43:19 +01:00
(void)faulting_address;
2018-11-13 18:02:47 +01:00
(void)frame;
(void)error_code;
}