16volatile uint64_t pit_ticks = 0;
17volatile uint16_t pit_frequency = 0;
31 if (frequency == 0)
return;
33 uint16_t divisor = 1193182 / frequency;
36 outb(0x40, divisor & 0xFF);
37 outb(0x40, divisor >> 8);
39 pit_frequency = frequency;
47 uint64_t target = pit_ticks + (ms * pit_frequency / 1000);
49 while (pit_ticks < target)
Provides utilities for IO operations with the hardware.
void outb(uint16_t port, uint8_t value)
Outputs a byte to the specified port.
void irq_register(uint8_t irq, irq_handler_fn fn)
Registers a handler function for the specified IRQ number.
IRQ Handler and utilities.
void pic_clear_mask(uint8_t irq)
Unmasks (Enables) a line.
Handles the legacy PIC for IRQ interrupts.
static void timer_irq(struct interrupt_frame *frame)
Handles the timer.
void pit_init(uint16_t frequency)
Initialize the PIT timer.
void pit_sleep_ms(uint32_t ms)
Sleep for a certain time using the PIT.
Handles timer interrupts from the PIT (Programmable Interrupt Timer).
The frame holding the registers when an interrupt happens.