aboutsummaryrefslogtreecommitdiff
path: root/arch/i686/lidt.c
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-10-29 11:26:44 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-10-29 11:26:44 +0300
commitc4fcc92183c55db868d0d6ae53e6009fb2e53ee5 (patch)
treead5ef50aa07465e11f779c4482e20e6071182e9c /arch/i686/lidt.c
parentmakefile: add libk target (diff)
downloadkernel-c4fcc92183c55db868d0d6ae53e6009fb2e53ee5.tar.xz
makefile: add i686/arch.a target
Diffstat (limited to 'arch/i686/lidt.c')
-rw-r--r--arch/i686/lidt.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/arch/i686/lidt.c b/arch/i686/lidt.c
deleted file mode 100644
index efbade3..0000000
--- a/arch/i686/lidt.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <idt.h>
-#include <stdint.h>
-
-struct __attribute__((packed)) Pointer {
- uint16_t limit;
- uint32_t base;
-};
-
-enum Type {
- Null = 0,
- Intr = 0b10001110, // 32-bit interrupt
-};
-
-struct __attribute__((packed)) Gate_t {
- uint16_t offset_15_0; // segment offset low
- uint16_t selector; // code segment selector
- uint8_t __unused; // unused in protected mode
- uint8_t type; // interrupt type
- uint16_t offset_31_16; // segment offset high
-};
-_Static_assert(sizeof(struct Gate_t) == 8);
-
-void
-Gate(struct Gate_t *entry, void *f, uint16_t selector)
-{
- uint32_t f_addr = (uint32_t)f;
- entry->offset_15_0 = f_addr & 0xffff;
- entry->offset_31_16 = (f_addr >> 16) & 0xffff;
- entry->selector = selector;
- entry->__unused = 0;
- entry->type = Intr;
-}
-
-static struct Gate_t interrupt_table[256] __attribute((aligned(4096)));
-
-void
-idt_install()
-{
- for (int i = 0; i <= 0x2f; ++i) Gate(&interrupt_table[i], &interrupt_handler, 0x10);
- Gate(&interrupt_table[0x80], &abort_handler, 0x10);
-
- const struct Pointer ptr = {.limit = sizeof(interrupt_table) - 1, .base = (unsigned)&interrupt_table};
- asm volatile("lidt (%0)" : : "a"(&ptr));
-
- asm volatile("sti");
-}