From 16913b711ad5e21392669cc65eb5eebdcc31e14c Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Sun, 15 Sep 2019 01:18:11 +0200
Subject: Added idt gate setter

---
 src/idt/idt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'src/idt/idt.c')

diff --git a/src/idt/idt.c b/src/idt/idt.c
index 3c0c246..c442044 100644
--- a/src/idt/idt.c
+++ b/src/idt/idt.c
@@ -21,6 +21,18 @@ struct idt_ptr idtp;
 // Defined in boot.asm
 extern void idt_load();
 
+void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags) {
+    // Specify the interrupt routine's base address
+    idt[num].base_lo = (base & 0xFFFF);
+    idt[num].base_hi = (base >> 16) & 0xFFFF;
+
+    // Set selector/segment of IDT entry
+    idt[num].sel = sel;
+    idt[num].always0 = 0;
+    idt[num].flags = flags;
+}
+
+
 // Install IDT
 void idt_install() {
     // Set IDT pointer and limit
-- 
cgit v1.2.3