diff options
Diffstat (limited to 'i686/lidt.c')
-rw-r--r-- | i686/lidt.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/i686/lidt.c b/i686/lidt.c index cf8084e..3260eb9 100644 --- a/i686/lidt.c +++ b/i686/lidt.c @@ -8,17 +8,17 @@ struct __attribute__((packed)) Pointer { enum Type { Null = 0, - Intr = 0x8e, // 1000 1110 32-bit interrupt + Intr = 0x8e, /* 1000 1110 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 + 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, "interrupt gate size"); +/* _Static_assert(sizeof(struct Gate_t) == 8, "interrupt gate size"); */ void Gate(struct Gate_t *entry, void (*f)(struct interrupt_frame *), uint16_t selector) @@ -36,18 +36,20 @@ static struct Gate_t interrupt_table[256] __attribute((aligned(4096))); void idt_install() { - // exceptions 0x00~0x13 - for (int i = 0; i <= 0x13; ++i) Gate(&interrupt_table[i], &abort_handler, 0x10); + int i; - // irq 0x20~0x2f - for (int i = 0x22; i <= 0x2f; ++i) Gate(&interrupt_table[i], &abort_handler, 0x10); + /* exceptions 0x00~0x13 */ + for (i = 0; i <= 0x13; ++i) Gate(&interrupt_table[i], &abort_handler, 0x10); + + /* irq 0x20~0x2f */ + for (i = 0x22; i <= 0x2f; ++i) Gate(&interrupt_table[i], &abort_handler, 0x10); Gate(&interrupt_table[0x20], &irq0x00, 0x10); Gate(&interrupt_table[0x21], &irq0x01, 0x10); Gate(&interrupt_table[0x2c], &irq0x0c, 0x10); - // syscall 0x80 + /* syscall 0x80 */ Gate(&interrupt_table[0x80], &syscall_handler, 0x10); const struct Pointer ptr = {.limit = sizeof(interrupt_table) - 1, .base = (unsigned)&interrupt_table}; - asm volatile("lidt (%0)" : : "a"(&ptr)); + __asm__("lidt (%0)" : : "a"(&ptr)); } |