summaryrefslogtreecommitdiff
path: root/src/include/toxic/idt.h
diff options
context:
space:
mode:
authorCarlos Maiolino <[email protected]>2025-07-26 15:32:32 +0200
committerCarlos Maiolino <[email protected]>2025-08-01 13:07:38 +0200
commit57d8e2b236c7a185bdd941c247ef0dcc5961a24e (patch)
tree1d1f496510c77422647f1513c3ca6f85e0110689 /src/include/toxic/idt.h
parent80ac430366d65ef89a078832380a021308bbbfdf (diff)
Implement interrupt descriptor table
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'src/include/toxic/idt.h')
-rw-r--r--src/include/toxic/idt.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/include/toxic/idt.h b/src/include/toxic/idt.h
new file mode 100644
index 0000000..f54f7f7
--- /dev/null
+++ b/src/include/toxic/idt.h
@@ -0,0 +1,27 @@
+#ifndef IDT_H
+#define IDT_H
+#include <stdint.h>
+
+/* ATTR byte field values */
+#define INT_GATE_32 0x0E
+#define TRAP_GATE_32 0x0F
+#define DPL_RING3 0x60
+#define PRESENT_BIT (1 << 7)
+
+#define TOXIC_INT_ATTR (PRESENT_BIT | DPL_RING3 | INT_GATE_32)
+
+struct int_descriptor {
+ uint16_t offset_low; /* bits 0..15 */
+ uint16_t selector; /* Code segment selector */
+ uint8_t reserved; /* Unused, must be 0 */
+ uint8_t type_attr; /* gate type, DPL, presence */
+ uint16_t offset_high; /* bits 16..31 */
+} __attribute__((packed));
+
+struct int_reg_descriptor {
+ uint16_t limit; /* Int descriptor table size (bytes) -1 */
+ uint32_t base; /* Table starting offset (linear address) */
+} __attribute__((packed));
+
+void interrupts_init(void);
+#endif /* IDT_H */