feat/kernel: im stuck in the apic jungle and need help
This commit is contained in:
parent
f81181ea9c
commit
322e95fe98
10 changed files with 240 additions and 71 deletions
32
kernel/src/dev/pit.c
Normal file
32
kernel/src/dev/pit.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* EMK 1.0 Copyright (c) 2025 Piraterna */
|
||||
#include <dev/pit.h>
|
||||
#include <arch/io.h>
|
||||
#include <sys/apic/lapic.h>
|
||||
#include <sys/apic/ioapic.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#define PIT_VECTOR 32
|
||||
|
||||
void (*pit_callback)(struct register_ctx *ctx) = NULL;
|
||||
|
||||
void pit_handler(struct register_ctx *frame)
|
||||
{
|
||||
if (pit_callback)
|
||||
pit_callback(frame);
|
||||
lapic_eoi();
|
||||
}
|
||||
|
||||
void pit_init(idt_intr_handler handler)
|
||||
{
|
||||
if (handler)
|
||||
pit_callback = handler;
|
||||
|
||||
outb(0x43, 0x36);
|
||||
|
||||
uint16_t divisor = 5966;
|
||||
outb(0x40, divisor & 0xFF);
|
||||
outb(0x40, (divisor >> 8) & 0xFF);
|
||||
|
||||
ioapic_map(0, PIT_VECTOR, pit_handler, 0);
|
||||
ioapic_unmask(0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue