From 432d8801e1a743c5e80df99e0f384b3a6a1e146b Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Tue, 20 Nov 2018 17:43:19 +0100 Subject: [PATCH] Complete pagefault handler --- core/exception_handler.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/exception_handler.c b/core/exception_handler.c index a948fba..8af4d93 100644 --- a/core/exception_handler.c +++ b/core/exception_handler.c @@ -11,14 +11,21 @@ __attribute__((interrupt)) void print_handler(struct interrupt_frame *frame, ulo (void)error_code; } - // c.f. https://wiki.osdev.org/Paging#Handling // error_code bit0: Present ? // bit1: Trying to write ? // bit2: User page try to access? -__attribute__((interrupt)) void pagefault_handler(struct interrupt_frame *frame, ulong error_code){ +__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)); + printStringDetails("PAGE FAULT", RED, BLACK, 0, VGA_HEIGHT - 1); printIntDetails(error_code, RED, BLACK, 11, VGA_HEIGHT - 1); + (void)faulting_address; (void)frame; (void)error_code; }