3 #include <cpu/x86/msr.h>
4 #include <cpu/x86/lapic.h>
8 /* Set the apic timer to no interrupts and periodic mode */
9 lapic_write(LAPIC_LVTT, (1 << 17)|(1<< 16)|(0 << 12)|(0 << 0));
11 /* Set the divider to 1, no divider */
12 lapic_write(LAPIC_TDCR, LAPIC_TDR_DIV_1);
14 /* Set the initial counter to 0xffffffff */
15 lapic_write(LAPIC_TMICT, 0xffffffff);
19 void udelay(unsigned usecs)
21 uint32_t start, value, ticks;
22 /* Calculate the number of ticks to run, our FSB runs a 200Mhz */
24 start = lapic_read(LAPIC_TMCCT);
26 value = lapic_read(LAPIC_TMCCT);
27 } while((start - value) < ticks);