diff options
author | Marvin Borner | 2019-09-15 01:13:31 +0200 |
---|---|---|
committer | Marvin Borner | 2019-09-15 01:13:31 +0200 |
commit | 41a2a86fd07134668263cf901706d6c0380173a1 (patch) | |
tree | b878dfb6c7c716fb1cc9f69b812a2598ac012b94 /src/idt | |
parent | b84a680c7fd9c461ac00633ceae3ef41b9d287e3 (diff) |
Added interrupt descriptor table and memory setter
Diffstat (limited to 'src/idt')
-rw-r--r-- | src/idt/idt.c | 36 | ||||
-rw-r--r-- | src/idt/idt.h | 6 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/idt/idt.c b/src/idt/idt.c new file mode 100644 index 0000000..3c0c246 --- /dev/null +++ b/src/idt/idt.c @@ -0,0 +1,36 @@ +#include "../memory/memory.h" + +/* Defines an IDT entry */ +struct idt_entry { + unsigned short base_lo; + unsigned short sel; // Kernel segment + unsigned char always0; // Always 0 + unsigned char flags; + unsigned short base_hi; +} __attribute__((packed)); + +struct idt_ptr { + unsigned short limit; + unsigned int base; +} __attribute__((packed)); + +// Initialize IDT with 256 entries +struct idt_entry idt[256]; +struct idt_ptr idtp; + +// Defined in boot.asm +extern void idt_load(); + +// Install IDT +void idt_install() { + // Set IDT pointer and limit + idtp.limit = (sizeof(struct idt_entry) * 256) - 1; + idtp.base = &idt; + + // Clear IDT by setting memory cells to 0 + memory_set(&idt, 0, sizeof(struct idt_entry) * 256); + + // TODO: Add method to add ISRs to IDT + + idt_load(); +} diff --git a/src/idt/idt.h b/src/idt/idt.h new file mode 100644 index 0000000..6a68e86 --- /dev/null +++ b/src/idt/idt.h @@ -0,0 +1,6 @@ +#ifndef MELVIX_IDT_H +#define MELVIX_IDT_H + +void idt_install(); + +#endif |