-
Notifications
You must be signed in to change notification settings - Fork 10
/
timer.c
29 lines (23 loc) · 883 Bytes
/
timer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Intel 8253/8254/82C54 Programmable Interval Timer (PIT).
// Only used on uniprocessors;
// SMP machines use the local APIC timer.
#include <sys/types.h>
#include "defs.h"
#include "traps.h"
#include "gaia.h"
#define IO_TIMER1 0x040 // 8253 Timer #1
// Frequency of all three count-down timers;
// (TIMER_FREQ/freq) is the appropriate count
// to generate a frequency of freq Hz.
#define TIMER_FREQ 1193182
#define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x))
#define TIMER_MODE (IO_TIMER1 + 3) // timer mode port
#define TIMER_SEL0 0x00 // select counter 0
#define TIMER_RATEGEN 0x04 // mode 2, rate generator
#define TIMER_16BIT 0x30 // r/w counter 16 bits, LSB first
void
timerinit(void)
{
// The timer on our GAIA board always causes interrupts 100 times/sec,
// and we have no method to configure it. So, do nothing here.
}