diff options
| author | Aleksa Vuckovic <aleksav013@gmail.com> | 2022-08-05 14:33:51 +0200 |
|---|---|---|
| committer | Aleksa Vuckovic <aleksav013@gmail.com> | 2022-08-05 14:33:51 +0200 |
| commit | bd7d4366b6643b5c6cd04f40dd32f5d9c9575fd6 (patch) | |
| tree | 92429e897be007d46c8f063a39a986df2124111a /kernel/include/idt.h | |
| parent | be3274c49d0ca5e31daa855c4c109d830fdead67 (diff) | |
organised files; switched to recursive make
Diffstat (limited to 'kernel/include/idt.h')
| -rw-r--r-- | kernel/include/idt.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/kernel/include/idt.h b/kernel/include/idt.h new file mode 100644 index 0000000..9ca9c3a --- /dev/null +++ b/kernel/include/idt.h @@ -0,0 +1,34 @@ +#ifndef IDT_H +#define IDT_H + +#include <stdint.h> + +#define GDT_CODE_SEG 0x08 + +#define INTERRUPT_GATE 0x8E +#define TRAP_GATE 0x8F + +struct idt_entry { + uint16_t offset_1; // offset bits 0..15 + uint16_t selector; // a code segment selector in GDT or LDT + uint8_t ist; // bits 0..2 holds Interrupt Stack Table offset, rest of bits zero. + uint8_t type_attributes; // gate type, dpl, and p fields + uint16_t offset_2; // offset bits 16..31 + uint32_t offset_3; // offset bits 32..63 + uint32_t zero; // reserved +} __attribute__((packed)); +typedef struct idt_entry idt_entry; + +struct idtp { + uint16_t size; + uint64_t offset; +} __attribute__((packed)); +typedef struct idtp idtp; + +void init_idt(void); +void load_idt(idtp* pointer); +void init_idt_table(void); +void add_to_idt(uint16_t num, uint64_t offset, uint16_t selector, uint8_t type); + + +#endif |
