|
|
1.1 root 1: #include "u.h"
2: #include "../port/lib.h"
3: #include "mem.h"
4: #include "dat.h"
5: #include "fns.h"
6: #include "io.h"
7:
8: #include "ureg.h"
9:
10: void
11: delay(int ms)
12: {
13: int i;
14:
15: ms *= 6230; /* experimentally determined */
16: for(i=0; i<ms; i++)
17: ;
18: }
19:
20: /* initialize microsecond system timer */
21: void
22: timerinit(void)
23: {
24: Systimer *st;
25:
26: st = (Systimer*)TIMER;
27: st->low = 0xff;
28: st->high = 0xff;
29: st->csr = (1<<7)|(1<<6);
30: }
31:
32: void
33: clock(Ureg *ur)
34: {
35: Proc *p;
36: int user, nrun = 0;
37:
38: user = (ur->sr&SUPER) == 0;
39: if(user) {
40: u->dbgreg = ur;
41: u->p->pc = ur->pc;
42: }
43:
44: m->ticks++;
45: *(ulong*)VDMACSR |= (1<<20);
46: kproftimer(ur->pc);
47: p = m->proc;
48: if(p){
49: nrun = 1;
50: p->pc = ur->pc;
51: if(p->state==Running)
52: p->time[p->insyscall]++;
53: }
54: nrun = (nrdy+nrun)*1000;
55: MACHP(0)->load = (MACHP(0)->load*19+nrun)/20;
56: checkalarms();
57: kbdclock();
58: sccclock();
59: mouseclock();
60: if((ur->sr&SPL(7))==0 && p && p->state==Running){
61: if(anyready()){
62: if(p->hasspin)
63: p->hasspin = 0;
64: else
65: sched();
66: }
67: if(user) {
68: (*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1);
69: notify(ur);
70: }
71: }
72: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.