summaryrefslogtreecommitdiff
path: root/kernel/src/arch/i686/idt.c
diff options
context:
space:
mode:
authorTyler Murphy <=>2023-07-17 19:34:52 -0400
committerTyler Murphy <=>2023-07-17 19:34:52 -0400
commit7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5 (patch)
tree4e86ff20e73171285156631db043e12aaf63bf04 /kernel/src/arch/i686/idt.c
parentpaging (diff)
downloadfinix-7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5.tar.gz
finix-7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5.tar.bz2
finix-7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5.zip
refactoring
Diffstat (limited to '')
-rw-r--r--kernel/src/arch/i686/idt.c (renamed from kernel/src/interrupt/idt.c)48
1 files changed, 35 insertions, 13 deletions
diff --git a/kernel/src/interrupt/idt.c b/kernel/src/arch/i686/idt.c
index aaa7034..04fd5f8 100644
--- a/kernel/src/interrupt/idt.c
+++ b/kernel/src/arch/i686/idt.c
@@ -5,16 +5,42 @@
#include <sys.h>
#include <print.h>
#include <panic.h>
+#include <arch/i686/pic.h>
+#include <arch/i686/idt.h>
+#include <time.h>
+#include <drivers/ps2kb.h>
+#include <drivers/ps2mouse.h>
-#include "acpi/acpi.h"
-#include "drivers/ps2kb.h"
-#include "drivers/ps2mouse.h"
-#include "time.h"
-#include "tty/color.h"
-#include "idt.h"
-#include "pic.h"
#include "tty/term.h"
+struct IdtEntry {
+ uint16_t isr_low;
+ uint16_t kernel_cs;
+ uint8_t _reserved;
+ uint8_t attributes;
+ uint16_t isr_high;
+} __attribute__((packed));
+
+struct Idtr {
+ uint16_t limit;
+ uint32_t base;
+} __attribute__((packed));
+
+enum IDTFlags {
+ IDT_FLAG_GATE_TASK = 0x5,
+ IDT_FLAG_GATE_16BIT_INT = 0x6,
+ IDT_FLAG_GATE_16BIT_TRAP = 0x7,
+ IDT_FLAG_GATE_32BIT_INT = 0xE,
+ IDT_FLAG_GATE_32BIT_TRAP = 0xF,
+
+ IDT_FLAG_RING0 = (0 << 5),
+ IDT_FLAG_RING1 = (1 << 5),
+ IDT_FLAG_RING2 = (2 << 5),
+ IDT_FLAG_RING3 = (3 << 5),
+
+ IDT_FLAG_PRESENT = 0x80,
+};
+
#define WIDTH 30
static char buf[WIDTH];
static int timer = -1;
@@ -35,7 +61,8 @@ void idt_pic_timer(void) {
for (size_t i = 0; i < WIDTH; i++) putchar(' ');
term_setpos(TERM_W - WIDTH - 1, 0);
- timetostr(rtc_localtime(), "%a %b %d %Y %H:%M:%S", buf, WIDTH);
+ struct Time t = get_localtime();
+ timetostr(&t, "%a %b %d %Y %H:%M:%S", buf, WIDTH);
printk("%s", buf);
term_load(state);
@@ -101,9 +128,6 @@ static void set_descriptor(uint8_t vector, void* isr, uint8_t flags) {
}
void idt_init(void) {
-
- debugk("Loading IDT");
-
idtr.base = (uintptr_t)&idt[0];
idtr.limit = (uint16_t)sizeof(struct IdtEntry) * IDT_SIZE - 1;
@@ -112,7 +136,5 @@ void idt_init(void) {
}
__asm__ volatile ("lidt %0" : : "m"(idtr));
-
- succek("IDT has been loaded");
}