#include
volatile uint32_t timer_ticks = 0;
int timer_intr(int intr_no, void *arg, struct pt_regs *regs)
{
timer_ticks++;
return 0;
}
static void settimer(int hz)
{
/*设置定时器多长时间发送一个中断给cpu*/
uint32_t divisor = 1193180/hz;
/*二进制,工作模式为3,先写LSB再写MSB*/
outb(0x43, 0x36);
outb(0x40, divisor&0xff);
outb(0x40, divisor>>8);
}
static void timer_init()
{
KPRINTF("timer_init\n");
irq_attach(IRQ2INTR(IRQ_TIMER), timer_intr, NULL, "TIMER_INTERRUPT");
settimer(200);
enable_irq(IRQ_TIMER);
}
INITFUNC(timer_init, INIT_TIMER);
阅读(1872) | 评论(0) | 转发(0) |