1 /* timer parameters. */
2 #define LATCH_COUNT 0x00 /* cc00xxxx, c = channel, x = any */
3 #define SQUARE_WAVE 0x36 /* ccaammmb, a = access, m = mode, b = BCD */
5 /************************ NOTICE THE DIVISOR VALUE ***********************/
6 #define TIMER_FREQ 1193182L /* timer frequency for timer in PC and AT */
7 #define TIMER_COUNT ((unsigned) (TIMER_FREQ/10)) /* initial value for counter*/
10 #define TIMER_MODE 0x43
14 int enable_irq(irq_nr
) unsigned irq_nr
;
17 out_byte(0x21, in_byte(0x21) & ~(1 << irq_nr
));
21 /*===========================================================================*
23 *===========================================================================*/
29 /* Initialize channel 0 of the 8253A timer to e.g. 60 Hz. */
31 printf("timer init\n");
34 out_byte(TIMER_MODE
, SQUARE_WAVE
); /* set timer to run continuously */
35 out_byte(TIMER0
, TIMER_COUNT
); /* load timer low byte */
36 out_byte(TIMER0
, TIMER_COUNT
>> 8); /* load timer high byte */
37 enable_irq(TIMER_IRQ
);
40 /*===========================================================================*
42 *===========================================================================*/
50 printf("1 second timer interrupt\n");