diff options
Diffstat (limited to 'src/loader/inc/int.h')
-rw-r--r-- | src/loader/inc/int.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/loader/inc/int.h b/src/loader/inc/int.h new file mode 100644 index 0000000..ccd9ea8 --- /dev/null +++ b/src/loader/inc/int.h @@ -0,0 +1,49 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#ifndef INT_H +#define INT_H + +#include <def.h> + +#define INT_GATE 0x8e +#define INT_TRAP 0xef +#define INT_USER 0x60 +#define IDT_ENTRY(offset, selector, type) \ + (struct idt_entry) \ + { \ + .base_low = (u16)((offset)&0xffff), .sel = (selector), .zero = 0, .flags = (type), \ + .base_high = (u16)(((offset) >> 16) & 0xffff), \ + } + +struct int_frame { + u32 gs, fs, es, ds; + u32 edi, esi, ebp, esp, ebx, edx, ecx, eax; + u32 int_no, err_code; + u32 eip, cs, eflags; +} PACKED; + +struct int_frame_user { + u32 gs, fs, es, ds; + u32 edi, esi, ebp, esp, ebx, edx, ecx, eax; + u32 int_no, err_code; + u32 eip, cs, eflags; + u32 useresp, ss; +} PACKED; + +struct idt_entry { + u16 base_low; + u16 sel; // Kernel segment + u8 zero; // Always 0 + u8 flags; + u16 base_high; +} PACKED; + +struct idt_ptr { + u16 size; + void *base; +} PACKED; + +void idt_install(void); +void int_event_handler_add(u32 int_no, void (*handler)(void)); + +#endif |