summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/interrupts
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/arch/amd64/interrupts')
-rw-r--r--src/kernel/arch/amd64/interrupts/irq.c9
-rw-r--r--src/kernel/arch/amd64/interrupts/irq.h1
-rw-r--r--src/kernel/arch/amd64/interrupts/isr.c6
3 files changed, 16 insertions, 0 deletions
diff --git a/src/kernel/arch/amd64/interrupts/irq.c b/src/kernel/arch/amd64/interrupts/irq.c
index b5e9255..9872ec7 100644
--- a/src/kernel/arch/amd64/interrupts/irq.c
+++ b/src/kernel/arch/amd64/interrupts/irq.c
@@ -5,6 +5,12 @@
static const int PIC1 = 0x20;
static const int PIC2 = 0xA0;
+static void pit_init(void) {
+ uint16_t divisor = 1193;
+ port_out8(0x40, divisor & 0xFF);
+ port_out8(0x40, divisor >> 8);
+}
+
void irq_init(void) {
port_out8(PIC1, 0x11); /* start init sequence */
port_out8(PIC2, 0x11);
@@ -18,11 +24,14 @@ void irq_init(void) {
port_out8(PIC2+1, 0x1);
uint8_t mask = 0xff;
+ mask &= ~(1 << IRQ_PIT);
mask &= ~(1 << IRQ_PS2);
mask &= ~(1 << IRQ_COM1);
port_out8(PIC1+1, mask);
port_out8(PIC2+1, 0xff);
+
+ pit_init();
}
void irq_eoi(uint8_t line) {
diff --git a/src/kernel/arch/amd64/interrupts/irq.h b/src/kernel/arch/amd64/interrupts/irq.h
index 3340101..2a4b12d 100644
--- a/src/kernel/arch/amd64/interrupts/irq.h
+++ b/src/kernel/arch/amd64/interrupts/irq.h
@@ -3,6 +3,7 @@
#include <stdint.h>
#define IRQ_IBASE 0x20
+#define IRQ_PIT 0
#define IRQ_PS2 1
#define IRQ_COM1 4
diff --git a/src/kernel/arch/amd64/interrupts/isr.c b/src/kernel/arch/amd64/interrupts/isr.c
index 71da27b..0bfd865 100644
--- a/src/kernel/arch/amd64/interrupts/isr.c
+++ b/src/kernel/arch/amd64/interrupts/isr.c
@@ -3,6 +3,7 @@
#include <kernel/arch/amd64/interrupts/irq.h>
#include <kernel/arch/amd64/interrupts/isr.h>
#include <kernel/arch/amd64/port_io.h>
+#include <kernel/arch/amd64/time.h>
#include <kernel/arch/generic.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
@@ -28,6 +29,11 @@ void isr_stage3(int interrupt, uint64_t *stackframe) {
isr_test_interrupt_called = true;
return;
+ case IRQ_IBASE + IRQ_PIT:
+ pit_irq();
+ irq_eoi(IRQ_PIT);
+ return;
+
case IRQ_IBASE + IRQ_PS2:
ps2_irq();
irq_eoi(IRQ_PS2);