From e99a09639d92eb8e018e27097578d5ebbd2fb420 Mon Sep 17 00:00:00 2001 From: Greg Bowne Date: Sun, 8 Oct 2023 12:22:16 -0700 Subject: [PATCH] fixing up some missing bits in isr.c and isr.h --- src/kernel/arch/x86/idt.h | 2 -- src/kernel/arch/x86/isr.c | 14 +++++++++++++- src/kernel/arch/x86/isr.h | 9 +++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/kernel/arch/x86/idt.h b/src/kernel/arch/x86/idt.h index 0e94d4a..0fa2204 100644 --- a/src/kernel/arch/x86/idt.h +++ b/src/kernel/arch/x86/idt.h @@ -3,8 +3,6 @@ #include -// Define the isr_regs structure - // IDT entry structure struct idt_entry { diff --git a/src/kernel/arch/x86/isr.c b/src/kernel/arch/x86/isr.c index e7b2bea..5a348d9 100644 --- a/src/kernel/arch/x86/isr.c +++ b/src/kernel/arch/x86/isr.c @@ -12,8 +12,20 @@ enum SERIAL_PORT_INTERRUPT = 0x24 }; +void dummy_isr(struct isr_regs *regs) +{ + printf("Timer interrupt occurred!\n"); +} + // ISR table -void (*isr_table[256])(struct isr_regs *regs); +void (*isr_table[256])(struct isr_regs *regs) = { + // initialize the dummy isr_table + [TIMER_INTERRUPT] = dummy_isr, // Timer interrupt + [KEYBOARD_INTERRUPT] = dummy_isr, // Keyboard interrupt + [NETWORK_INTERRUPT] = dummy_isr, // Network interrupt + [DISK_INTERRUPT] = dummy_isr, // Disk interrupt + [SERIAL_PORT_INTERRUPT] = dummy_isr // Serial port interrupt +}; // Register an ISR void isr_register(uint8_t num, void (*handler)(struct isr_regs *regs)) diff --git a/src/kernel/arch/x86/isr.h b/src/kernel/arch/x86/isr.h index 86d753c..0b98787 100644 --- a/src/kernel/arch/x86/isr.h +++ b/src/kernel/arch/x86/isr.h @@ -3,6 +3,15 @@ #include +struct isr_regs +{ + uint32_t gs, fs, es, ds; // Segment selectors + uint32_t edi, esi, ebp, esp; // Pushed by pusha instruction + uint32_t ebx, edx, ecx, eax; // Pushed by the interrupt handler + uint32_t int_no, err_code; // Interrupt number and error code (if applicable) + uint32_t eip, cs, eflags, esp_at_signal; // Pushed by the processor automatically +}; + // Structure for storing register values during an ISR struct idt_regs {