24 lines
602 B
C
24 lines
602 B
C
#include "schedule.h"
|
|
#include "io.h"
|
|
#include "interrupts.h"
|
|
#include "ipv4.h"
|
|
|
|
volatile unsigned long timer_ticks = 0;
|
|
|
|
void timer_handler(struct regs *r) {
|
|
timer_ticks++;
|
|
ipv4_process_outbound();
|
|
schedule(r);
|
|
}
|
|
|
|
void timer_phase(int hz) {
|
|
int divisor = 1193180 / hz; /* Calculate our divisor */
|
|
outportb(0x43, 0x36); /* Set our command byte 0x36 */
|
|
outportb(0x40, divisor & 0xFF); /* Set low byte of divisor */
|
|
outportb(0x40, divisor >> 8); /* Set high byte of divisor */
|
|
}
|
|
|
|
void init_timer(void) {
|
|
timer_phase(100);
|
|
irq_install_handler(0, timer_handler, 0);
|
|
} |