diff options
author | Marvin Borner | 2020-07-22 21:43:05 +0200 |
---|---|---|
committer | Marvin Borner | 2020-07-22 21:43:05 +0200 |
commit | 6f0f8d26d2710e24192e56e85ecb5fc2b7f54da7 (patch) | |
tree | 747eea900f121a50579f62ac230875f07d8f6149 /src/inc/interrupts.h | |
parent | e9c31cf19a30bd2d9960ce8341fea9cbfc973f7a (diff) |
Added interrupts
Diffstat (limited to 'src/inc/interrupts.h')
-rw-r--r-- | src/inc/interrupts.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/inc/interrupts.h b/src/inc/interrupts.h new file mode 100644 index 0000000..7145e62 --- /dev/null +++ b/src/inc/interrupts.h @@ -0,0 +1,41 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#ifndef IDT_H +#define IDT_H + +#include <def.h> + +struct regs { + u32 gs, fs, es, ds; + u32 edi, esi, ebp, esp, ebx, edx, ecx, eax; + u32 int_no, err_code; + u32 eip, cs, eflags, useresp, ss; +}; + +struct idt_entry { + u16 base_low; + u16 sel; // Kernel segment + u8 always0; // Always 0 + u8 flags; + u16 base_high; +} __attribute__((packed)); + +struct idt_ptr { + u16 limit; + void *base; +} __attribute__((packed)); + +struct idt_entry idt[256]; +struct idt_ptr idt_ptr; + +void idt_set_gate(u8 num, u32 base, u16 sel, u8 flags); + +void irq_install_handler(int irq, void (*handler)(struct regs *r)); +void irq_uninstall_handler(int irq); + +void isr_install_handler(int isr, void (*handler)(struct regs *r)); +void isr_uninstall_handler(int isr); + +void interrupts_install(); + +#endif |