Interrupts :D

This commit is contained in:
Justus Wolff
2026-03-21 00:21:32 +01:00
parent c6a8ea907a
commit 983ebb281e
11 changed files with 523 additions and 196 deletions

View File

@@ -20,6 +20,25 @@
#define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */
#define ICW4_SFNM 0x10 /* Special fully nested (not) */
#define CASCADE_IRQ 2
#define IDT_MAX_DESCRIPTORS 32
typedef struct {
uint16_t isr_low; // The lower 16 bits of the ISR's address
uint16_t kernel_cs; // The GDT segment selector that the CPU will load into CS before calling the ISR
uint8_t reserved; // Set to zero
uint8_t attributes; // Type and attributes; see the IDT page
uint16_t isr_high; // The higher 16 bits of the ISR's address
} __attribute__((packed)) idt_entry_t;
typedef struct {
uint16_t limit;
uint32_t base;
} __attribute__((packed)) idtr_t;
typedef struct {
uint32_t ds;
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
uint32_t int_no, err_code;
uint32_t eip, cs, eflags, useresp, ss;
} INT_registers_t;
inline void PIC_sendEOI(uint8_t irq) {
if (irq >= 8) { // slave also needs EOI
@@ -27,4 +46,17 @@ inline void PIC_sendEOI(uint8_t irq) {
}
outb(PIC1_COMMAND,PIC_EOI);
}
extern void PIC_remap(int offset1, int offset2);
void PIC_remap(int offset1, int offset2);
__attribute__((noreturn))
void INT_exhand(INT_registers_t regs);
void INT_IRQ(uint8_t IRQ, INT_registers_t regs);
void idt_set_descriptor(uint8_t vector, void* isr, uint8_t flags);
void idt_init();
__attribute__((aligned(0x10)))
extern idt_entry_t idt[256];
extern idtr_t idtr;
extern void* isr_stub_table[];
extern void* irq_stub_table[];
extern uint8_t INT_vectors[IDT_MAX_DESCRIPTORS];
extern char *exception_messages[];