~kris/9p

9hist

ref: 9f032393e9ff251d336308f07c8ec6ecbe6f3fed 9hist/pc/clock.c -rw-r--r-- 502 bytes
9f032393 — David du Colombier Plan 9 from Bell Labs 1991-07-05 35 years ago
                                                                                
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
30
31
32
33
#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"

/*
 *  8253 timer
 */
enum
{
	Timerctl=	0x43,		/* control port */
	Timercnt=	0x40,		/* timer count port (outb count-1) */
	Timericnt=	0x41,		/* timer count input port */

	Timerlatch=	0x40,		/* latch count into Timericnt */
};

void
clockinit(void)
{
	setvec(Clockvec, clock, SEGIG);
}

void
clock(void *arg)
{
	m->ticks++;
	if((m->ticks%185)==0)
		print("%d secs\n", TK2SEC(m->ticks));
	INT0ENABLE;
}