X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/b91be0033265b5b6bd716bd39cb0971da41906c4..7804c2dae30700296c3205aaf7f546f491999bf4:/lunaix-os/scripts/templates/i386/i386_isrdef.c.j2?ds=sidebyside diff --git a/lunaix-os/scripts/templates/i386/i386_isrdef.c.j2 b/lunaix-os/scripts/templates/i386/i386_isrdef.c.j2 new file mode 100644 index 0000000..01ab639 --- /dev/null +++ b/lunaix-os/scripts/templates/i386/i386_isrdef.c.j2 @@ -0,0 +1,29 @@ +#include "i386_intr.h" +#include + +#define IDT_INTERRUPT 0x70 +#define KERNEL_CS 0x8 +#define IDT_ATTR(dpl, type) (((type) << 5) | ((dpl & 3) << 13) | (1 << 15)) +#define IDT_ENTRY 256 + +#define DECLARE_ISR(iv) extern void _asm_isr##iv(); + +#define ISR_INSTALL(idt, iv, isr) \ + _idt[iv] = ((ptr_t)isr & 0xffff0000) | IDT_ATTR(0, IDT_INTERRUPT); \ + _idt[iv] <<= 32; \ + _idt[iv] |= (KERNEL_CS << 16) | ((ptr_t)isr & 0x0000ffff); \ + +u64_t _idt[IDT_ENTRY]; +u16_t _idt_limit = sizeof(_idt) - 1; + +{% for isrdef in data["exception"] -%} + DECLARE_ISR({{ isrdef["index"] }}) +{% endfor %} + +void +exception_install_handler() +{ +{% for isrdef in data["exception"] %} + ISR_INSTALL(_idt, {{ isrdef["index"] }}, _asm_isr{{ isrdef["index"] }}) +{% endfor %} +} \ No newline at end of file