diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2025-05-25 21:44:34 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-05-25 21:44:34 +0530 |
commit | 285514f87d1b2602a997069ac5c0b8c1742345d0 (patch) | |
tree | a325598584e480c67b6fae45ce5025b5e0293850 | |
parent | 1c71ed2dee37bb3c11e65832ce4577aed50d9c84 (diff) |
interrupts: use constants for IDT_ENTRY attributes
-rw-r--r-- | kernel/CMakeLists.txt | 1 | ||||
-rw-r--r-- | kernel/boot/interrupts/idt.cc | 4 | ||||
-rw-r--r-- | kernel/include/boot/interrupts.h | 10 |
3 files changed, 14 insertions, 1 deletions
diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 196f0b9..39baa4b 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -68,6 +68,7 @@ set(CXX_COMPILE_OPTIONS -Wno-missing-field-initializers -Wno-c++11-long-long -Wno-c99-extensions + -Wno-c++14-binary-literal ) target_compile_options(kernel PRIVATE diff --git a/kernel/boot/interrupts/idt.cc b/kernel/boot/interrupts/idt.cc index fa5786c..7da25e1 100644 --- a/kernel/boot/interrupts/idt.cc +++ b/kernel/boot/interrupts/idt.cc @@ -36,7 +36,9 @@ load_idt(void) /* The first 32 entries are exceptions */ for (uint8_t i = 0; i < 32; i++) - l_entries[i] = (entry_t) IDT_ENTRY((uint32_t) isr_stub_table[i], 0x8E); + l_entries[i] = (entry_t) IDT_ENTRY((uint32_t) isr_stub_table[i], + IDT_PRESENT | IDT_KERNEL_PRIVILEGE_LEVEL + | IDT_32BIT_INTERRUPT_GATE); __asm__ volatile("lidt %0" ::"m"(descriptor)); __asm__ volatile("sti"); diff --git a/kernel/include/boot/interrupts.h b/kernel/include/boot/interrupts.h index 42a0ba9..165b2d6 100644 --- a/kernel/include/boot/interrupts.h +++ b/kernel/include/boot/interrupts.h @@ -32,6 +32,16 @@ (isr >> 16) /* isr_high */ \ } +/* Attributes */ +#define IDT_PRESENT (1 << 7) +#define IDT_KERNEL_PRIVILEGE_LEVEL (0) +#define IDT_USER_PRIVILEGE_LEVEL (3 << 5) +#define IDT_TASK_GATE (0b0101) +#define IDT_16BIT_INTERRUPT_GATE (0b0110) +#define IDT_16BIT_TRAP_GATE (0b0111) +#define IDT_32BIT_INTERRUPT_GATE (0b1110) +#define IDT_32BIT_TRAP_GATE (0b1111) + namespace Interrupts { |