1 #include <hardware/pit.h>
4 * Start up channel 0 in 'terminal count' mode (mode 0).
5 * It will count down to zero, and then will issue a single interrupt,
6 * but we don't care about it since interrupts are neither used nor enabled.
7 * It's safe to use the timer freely here. timer.device starts up long after
10 static inline void pit_start(unsigned short start
)
12 outb(CH0
|ACCESS_FULL
|MODE_TERMINAL
, PIT_CONTROL
);
13 ch_write(start
, PIT_CH0
);
17 * In this mode the counter wraps around to 0xFFFF and continues decrementing.
18 * It's assumed that the start value is reasonably lower, and the CPU has time
19 * to detect the wraparound.
21 static inline unsigned short pit_wait(unsigned short start
)
27 outb(CH0
|ACCESS_LATCH
, PIT_CONTROL
);
28 tick
= ch_read(PIT_CH0
);
29 } while ((tick
> 0) && (tick
< start
));
34 void pit_udelay(unsigned int usec
);