summaryrefslogtreecommitdiff
path: root/src/kernel/arch/i386/interrupts
diff options
context:
space:
mode:
authordzwdz2021-07-21 18:12:51 +0200
committerdzwdz2021-07-21 18:12:51 +0200
commit2d5cace287c1c0a5fe74c88e55987bc3cf5209cf (patch)
treec3e6d342e6fba71b3b3c744ee38bfedaf3589cdd /src/kernel/arch/i386/interrupts
parent04b4c029420b010a906d0af3fb7b52108471c4bd (diff)
simplify the IDT generation
Diffstat (limited to 'src/kernel/arch/i386/interrupts')
-rw-r--r--src/kernel/arch/i386/interrupts/idt.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/src/kernel/arch/i386/interrupts/idt.c b/src/kernel/arch/i386/interrupts/idt.c
index 4c46514..0b327c8 100644
--- a/src/kernel/arch/i386/interrupts/idt.c
+++ b/src/kernel/arch/i386/interrupts/idt.c
@@ -27,35 +27,27 @@ struct lidt_arg {
static struct idt_entry IDT[256];
static struct lidt_arg lidt_arg;
-static inline void idt_add(uint8_t num, bool user);
static void idt_prepare();
static void idt_load();
static void idt_test();
-static inline void idt_add(uint8_t num, bool user) {
- uintptr_t offset = (uintptr_t) &_isr_stubs + 8 * num;
-
- IDT[num] = (struct idt_entry) {
- .offset_low = offset,
- .offset_high = offset >> 16,
- .code_seg = SEG_r0code << 3,
- .zero = 0,
- .present = 1,
- .ring = user ? 3 : 0,
- .storage = 0,
- .type = 0xE, // 32-bit interrupt gate
- };
-}
-
static void idt_prepare() {
- for (int i = 0; i < 256; i++)
- IDT[i].present = 0;
+ uintptr_t offset;
+ for (int i = 0; i < 256; i++) {
+ offset = (uintptr_t) &_isr_stubs + i * 8;
- idt_add(0x08, false);
- idt_add(0x0d, false);
- idt_add(0x0e, false);
- idt_add(0x34, false);
+ IDT[i] = (struct idt_entry) {
+ .offset_low = offset,
+ .offset_high = offset >> 16,
+ .code_seg = SEG_r0code << 3,
+ .zero = 0,
+ .present = 1,
+ .ring = 0,
+ .storage = 0,
+ .type = 0xE, // 32-bit interrupt gate
+ };
+ }
}
static void idt_load() {