summaryrefslogtreecommitdiff
path: root/kernel/src/interrupt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--kernel/include/arch/i686/pic.h (renamed from kernel/src/interrupt/pic.h)2
-rw-r--r--kernel/src/arch/i686/idt.asm (renamed from kernel/src/interrupt/idt.asm)0
-rw-r--r--kernel/src/arch/i686/idt.c (renamed from kernel/src/interrupt/idt.c)48
-rw-r--r--kernel/src/arch/i686/pic.c (renamed from kernel/src/interrupt/pic.c)15
-rw-r--r--kernel/src/interrupt/idt.h36
5 files changed, 41 insertions, 60 deletions
diff --git a/kernel/src/interrupt/pic.h b/kernel/include/arch/i686/pic.h
index a87420d..593a33a 100644
--- a/kernel/src/interrupt/pic.h
+++ b/kernel/include/arch/i686/pic.h
@@ -4,7 +4,7 @@
#define PIC_REMAP_OFFSET 0x20
-void pic_remap(uint8_t offset);
+void pic_remap(void);
void pic_mask(int irq);
void pic_unmask(int irq);
void pic_disable(void);
diff --git a/kernel/src/interrupt/idt.asm b/kernel/src/arch/i686/idt.asm
index 6cccdc6..6cccdc6 100644
--- a/kernel/src/interrupt/idt.asm
+++ b/kernel/src/arch/i686/idt.asm
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");
}
diff --git a/kernel/src/interrupt/pic.c b/kernel/src/arch/i686/pic.c
index 86056a1..f5d0f94 100644
--- a/kernel/src/interrupt/pic.c
+++ b/kernel/src/arch/i686/pic.c
@@ -1,17 +1,14 @@
#include <sys.h>
#include <print.h>
-
-#include "pic.h"
+#include <arch/i686/pic.h>
+#include <arch/i686/asm.h>
#define PIC1_COMMAND_PORT 0x20
#define PIC1_DATA_PORT 0x21
#define PIC2_COMMAND_PORT 0xA0
#define PIC2_DATA_PORT 0xA1
-void pic_remap(uint8_t offset) {
-
- debugk("Remapping PIC");
-
+void pic_remap(void) {
char a1 = inb(PIC1_DATA_PORT);
char a2 = inb(PIC2_DATA_PORT);
// control word 1
@@ -22,9 +19,9 @@ void pic_remap(uint8_t offset) {
io_wait();
// control word 2
// interrupt offset
- outb(PIC1_DATA_PORT, offset);
+ outb(PIC1_DATA_PORT, PIC_REMAP_OFFSET);
io_wait();
- outb(PIC2_DATA_PORT, offset + 8);
+ outb(PIC2_DATA_PORT, PIC_REMAP_OFFSET + 8);
io_wait();
// control word 3
// primary pic: set which pin secondary is connected to
@@ -42,8 +39,6 @@ void pic_remap(uint8_t offset) {
// clear data registers
outb(PIC1_DATA_PORT, a1);
outb(PIC2_DATA_PORT, a2);
-
- succek("PIC has been remapped to offset 0x%X", offset);
}
void pic_mask(int irq) {
diff --git a/kernel/src/interrupt/idt.h b/kernel/src/interrupt/idt.h
deleted file mode 100644
index 86a685f..0000000
--- a/kernel/src/interrupt/idt.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#pragma once
-
-#include <stdint.h>
-
-#define IDT_SIZE 256
-#define IDT_INTERRUPTS 256
-
-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,
-};
-
-void idt_init(void);