use correct struct for interrupt frames

This commit is contained in:
hippoz 2022-02-25 21:29:18 +02:00
parent 6839eb4699
commit dda6d4698c
No known key found for this signature in database
GPG key ID: 7C52899193467641
3 changed files with 42 additions and 35 deletions

View file

@ -2,173 +2,172 @@
#include "std/std.h" #include "std/std.h"
#include "std/kstd.h" #include "std/kstd.h"
void generic_exception_handler(struct interrupt_descriptor_32 *frame, uint8_t irq) { void generic_exception_handler(struct interrupt_frame_32 *frame, uint8_t irq) {
kprintf("\n\n"); kprintf("\n\n");
kprintf("---- PANIC -------------\n"); kprintf("---- PANIC -------------\n");
kprintf("Kernel panic due to exception\n"); kprintf("Kernel panic due to exception\n");
kprintf("IRQ %d\n", (int)irq); kprintf("IRQ %d\n", (int)irq);
kprintf("selector %d\n", (int)frame->selector);
kprintf("------------------------\n"); kprintf("------------------------\n");
kabort(); kabort();
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr0(struct interrupt_descriptor_32 *frame) { static void isr0(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 0); generic_exception_handler(frame, 0);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr1(struct interrupt_descriptor_32 *frame) { static void isr1(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 1); generic_exception_handler(frame, 1);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr2(struct interrupt_descriptor_32 *frame) { static void isr2(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 2); generic_exception_handler(frame, 2);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr3(struct interrupt_descriptor_32 *frame) { static void isr3(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 3); generic_exception_handler(frame, 3);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr4(struct interrupt_descriptor_32 *frame) { static void isr4(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 4); generic_exception_handler(frame, 4);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr5(struct interrupt_descriptor_32 *frame) { static void isr5(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 5); generic_exception_handler(frame, 5);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr6(struct interrupt_descriptor_32 *frame) { static void isr6(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 6); generic_exception_handler(frame, 6);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr7(struct interrupt_descriptor_32 *frame) { static void isr7(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 7); generic_exception_handler(frame, 7);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr8(struct interrupt_descriptor_32 *frame) { static void isr8(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 8); generic_exception_handler(frame, 8);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr9(struct interrupt_descriptor_32 *frame) { static void isr9(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 9); generic_exception_handler(frame, 9);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr10(struct interrupt_descriptor_32 *frame) { static void isr10(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 10); generic_exception_handler(frame, 10);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr11(struct interrupt_descriptor_32 *frame) { static void isr11(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 11); generic_exception_handler(frame, 11);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr12(struct interrupt_descriptor_32 *frame) { static void isr12(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 12); generic_exception_handler(frame, 12);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr13(struct interrupt_descriptor_32 *frame) { static void isr13(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 13); generic_exception_handler(frame, 13);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr14(struct interrupt_descriptor_32 *frame) { static void isr14(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 14); generic_exception_handler(frame, 14);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr15(struct interrupt_descriptor_32 *frame) { static void isr15(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 15); generic_exception_handler(frame, 15);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr16(struct interrupt_descriptor_32 *frame) { static void isr16(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 16); generic_exception_handler(frame, 16);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr17(struct interrupt_descriptor_32 *frame) { static void isr17(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 17); generic_exception_handler(frame, 17);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr18(struct interrupt_descriptor_32 *frame) { static void isr18(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 18); generic_exception_handler(frame, 18);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr19(struct interrupt_descriptor_32 *frame) { static void isr19(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 19); generic_exception_handler(frame, 19);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr20(struct interrupt_descriptor_32 *frame) { static void isr20(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 20); generic_exception_handler(frame, 20);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr21(struct interrupt_descriptor_32 *frame) { static void isr21(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 21); generic_exception_handler(frame, 21);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr22(struct interrupt_descriptor_32 *frame) { static void isr22(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 22); generic_exception_handler(frame, 22);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr23(struct interrupt_descriptor_32 *frame) { static void isr23(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 23); generic_exception_handler(frame, 23);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr24(struct interrupt_descriptor_32 *frame) { static void isr24(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 24); generic_exception_handler(frame, 24);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr25(struct interrupt_descriptor_32 *frame) { static void isr25(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 25); generic_exception_handler(frame, 25);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr26(struct interrupt_descriptor_32 *frame) { static void isr26(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 26); generic_exception_handler(frame, 26);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr27(struct interrupt_descriptor_32 *frame) { static void isr27(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 27); generic_exception_handler(frame, 27);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr28(struct interrupt_descriptor_32 *frame) { static void isr28(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 28); generic_exception_handler(frame, 28);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr29(struct interrupt_descriptor_32 *frame) { static void isr29(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 29); generic_exception_handler(frame, 29);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr30(struct interrupt_descriptor_32 *frame) { static void isr30(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 30); generic_exception_handler(frame, 30);
} }
__attribute__((interrupt)) __attribute__((interrupt))
static void isr31(struct interrupt_descriptor_32 *frame) { static void isr31(struct interrupt_frame_32 *frame) {
generic_exception_handler(frame, 31); generic_exception_handler(frame, 31);
} }

View file

@ -16,6 +16,14 @@ struct interrupt_descriptor_32 {
uint16_t offset_2; // offset bits 16..31 uint16_t offset_2; // offset bits 16..31
} __attribute__((__packed__)); } __attribute__((__packed__));
struct interrupt_frame_32 {
size_t ip;
size_t cs;
size_t flags;
size_t sp;
size_t ss;
} __attribute__((__packed__));
void idt_init(void); void idt_init(void);
void idt_register_handler(uint8_t interrupt, size_t address); void idt_register_handler(uint8_t interrupt, size_t address);

View file

@ -47,7 +47,7 @@ const char us_map[128] = {
}; };
__attribute__((interrupt)) __attribute__((interrupt))
static void irq(struct interrupt_descriptor_32 *frame) { static void irq(struct interrupt_frame_32 *frame) {
uint8_t scancode = inb(0x60); uint8_t scancode = inb(0x60);
if (scancode & 128) { if (scancode & 128) {