~kris/9p

9hist

ref: 6bc41a53311561691c0ae0d8db0192e77af6d650 9hist/pc/clock.c -rw-r--r-- 641 bytes
6bc41a53 — David du Colombier Plan 9 from Bell Labs 1991-07-06 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
34
35
36
37
38
39
40
41
42
43
44
#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"
#include	"ureg.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(Ureg *ur)
{
	Proc *p;

	m->ticks++;
	p = m->proc;
	if(p){
		p->pc = ur->eip;
		if (p->state==Running)
			p->time[p->insyscall]++;
	}

	if((m->ticks%185) == 92)
		floppystart();
	else if((m->ticks%185) == 0)
		floppystop();
}