From: Duje Mihanović Date: Sun, 8 May 2022 12:47:14 +0000 (+0200) Subject: Fix interrupt trap gates X-Git-Tag: 0.1.0~1 X-Git-Url: https://git.dujemihanovic.xyz/donate?a=commitdiff_plain;h=0cd522f39687d1fed9e204e5504d19baa8d85e04;p=nameless-os.git Fix interrupt trap gates Until now the code would set the most significant bit in the type part of the IDT descriptor for trap gates as a result of my error, causing a triple fault when trying to handle a double fault. A less significant, but still noteworthy change is that the double fault handler has been slightly revamped to print out :( on a red background and no longer spits out a warning because I accidentally wrote a string there, not a char. --- diff --git a/include/arch/x86/irq/idt.h b/include/arch/x86/irq/idt.h index 8b2efa1..daf586f 100644 --- a/include/arch/x86/irq/idt.h +++ b/include/arch/x86/irq/idt.h @@ -6,8 +6,8 @@ #define IDT_VECTOR_COUNT 256 /* our IDT will have 256 vectors */ #define IDT_DESCRIPTOR_SIZE 8 /* each IDT descriptor is 8 bytes long */ -#define IDT_TRAP_GATE 0x1F -#define IDT_INTERRUPT_GATE 0x0E +#define IDT_TRAP_GATE 0xF +#define IDT_INTERRUPT_GATE 0xE struct idt_descriptor { uint16_t offset_1; /* bits 0-15 of offset */ diff --git a/kernel/arch/x86/irq/sample_handler.c b/kernel/arch/x86/irq/sample_handler.c index d9bd8f9..f4f4a4b 100644 --- a/kernel/arch/x86/irq/sample_handler.c +++ b/kernel/arch/x86/irq/sample_handler.c @@ -25,9 +25,9 @@ void keyb_handler(struct interrupt_frame *frame) __attribute__((interrupt)) void double_fault(struct abort_frame *frame) { - *(volatile char *) (0xb8000) = ":"; - *(volatile char *) (0xb8002) = "("; + *(volatile uint32_t *) (0xb8000) = 0xcf28cf3a; +halt: asm volatile ("cli; hlt"); - while(1); + goto halt; }