~kris/9p

9hist

ref: 7a0c9a6ebe25857f0855a7d43adf24c6c5723a9b 9hist/pc/main.c -rw-r--r-- 977 bytes
7a0c9a6e — David du Colombier Plan 9 from Bell Labs 1991-07-10 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"

main(void)
{
	screeninit();
	trapinit();
	kbdinit();
	clockinit();
	mmuinit();
	floppyinit();
	spllo();
	floppystart(0);
	for(;;){
		int c;

		c = getc(&kbdq);
		if(c!=-1)
			screenputc(c);
		idle();
		if((TK2SEC(m->ticks)%5)==0)
			if((TK2SEC(m->ticks)%10)==0)
				floppystop(0);
			else
				floppystart(0);
	}
}

void
delay(int l)
{
	int i;

	while(--l){
		for(i=0; i < 100; i++)
			;
	}
}

int
sprint(char *s, char *fmt, ...)
{
	return doprint(s, s+PRINTSIZE, fmt, (&fmt+1)) - s;
}

int
print(char *fmt, ...)
{
	char buf[PRINTSIZE];
	int n;

	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf;
	screenputs(buf, n);
	return n;
}

void
panic(char *fmt, ...)
{
	char buf[PRINTSIZE];
	int n;

	screenputs("panic: ", 7);
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf;
	screenputs(buf, n);
	screenputs("\n", 1);
	spllo();
	for(;;)
		idle();
}

void
sched(void)
{
}