From c9ad4bfbf875b0d23e1f7bf7d5aff2d149ba4fd7 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 19 Jul 2021 17:23:20 +0200 Subject: add a page fault handler --- src/kernel/arch/i386/interrupts/idt.c | 1 + src/kernel/arch/i386/interrupts/isr.c | 6 ++++++ src/kernel/arch/i386/interrupts/isr.h | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/kernel/arch/i386/interrupts/idt.c b/src/kernel/arch/i386/interrupts/idt.c index 5573928..bbaf610 100644 --- a/src/kernel/arch/i386/interrupts/idt.c +++ b/src/kernel/arch/i386/interrupts/idt.c @@ -54,6 +54,7 @@ static void idt_prepare() { idt_add(0x08, false, isr_double_fault); idt_add(0x0d, false, isr_general_protection_fault); + idt_add(0x0e, false, isr_page_fault); idt_add(0x34, false, isr_test_interrupt); } diff --git a/src/kernel/arch/i386/interrupts/isr.c b/src/kernel/arch/i386/interrupts/isr.c index 35796fa..9da06fb 100644 --- a/src/kernel/arch/i386/interrupts/isr.c +++ b/src/kernel/arch/i386/interrupts/isr.c @@ -20,6 +20,12 @@ void isr_general_protection_fault(UNUSED struct interrupt_frame *frame) { panic(); } +__attribute__((interrupt)) +void isr_page_fault(UNUSED struct interrupt_frame *frame) { + log_const("#PF"); + panic(); +} + __attribute__((interrupt)) void isr_test_interrupt(UNUSED struct interrupt_frame *frame) { isr_test_interrupt_called = true; diff --git a/src/kernel/arch/i386/interrupts/isr.h b/src/kernel/arch/i386/interrupts/isr.h index 150fc46..c3585dc 100644 --- a/src/kernel/arch/i386/interrupts/isr.h +++ b/src/kernel/arch/i386/interrupts/isr.h @@ -11,5 +11,8 @@ void isr_double_fault(struct interrupt_frame *frame); __attribute__((interrupt)) void isr_general_protection_fault(struct interrupt_frame *frame); +__attribute__((interrupt)) +void isr_page_fault(struct interrupt_frame *frame); + __attribute__((interrupt)) void isr_test_interrupt(struct interrupt_frame *frame); -- cgit v1.2.3