-
Notifications
You must be signed in to change notification settings - Fork 9
/
prf.c
153 lines (139 loc) · 2.51 KB
/
prf.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "../param.h"
#include "../seg.h"
#include "../buf.h"
#include "../conf.h"
/*
* Address and structure of the
* KL-11 console device registers.
*/
struct
{
int rsr;
int rbr;
int xsr;
int xbr;
};
/* --------------------------- */
/*
* In case console is off,
* panicstr contains argument to last
* call to panic.
*/
char *panicstr;
/*
* Scaled down version of C Library printf.
* Only %s %l %d (==%l) %o are recognized.
* Used to print diagnostic information
* directly on console tty.
* Since it is not interrupt driven,
* all system activities are pretty much
* suspended.
* Printf should not be used for chit-chat.
*/
printf(fmt,x1,x2,x3,x4,x5,x6,x7,x8,x9,xa,xb,xc)
char fmt[];
{
register char *s;
register *adx, c;
adx = &x1;
loop:
while((c = *fmt++) != '%') {
if(c == '\0')
return;
putchar(c);
}
c = *fmt++;
if(c == 'd' || c == 'l' || c == 'o')
printn(*adx, c=='o'? 8: 10);
if(c == 's') {
s = *adx;
while(c = *s++)
putchar(c);
}
adx++;
goto loop;
}
/* --------------------------- */
/*
* Print an unsigned integer in base b.
*/
printn(n, b)
{
register a;
if(a = ldiv(n, b))
printn(a, b);
putchar(lrem(n, b) + '0');
}
/* --------------------------- */
/*
* Print a character on console.
* Attempts to save and restore device
* status.
* If the switches are 0, all
* printing is inhibited.
*/
putchar(c)
{
register rc, s;
rc = c;
if(SW->integ == 0)
return;
while((KL->xsr&0200) == 0)
;
if(rc == 0)
return;
s = KL->xsr;
KL->xsr = 0;
KL->xbr = rc;
if(rc == '\n') {
putchar('\r');
putchar(0177);
putchar(0177);
}
putchar(0);
KL->xsr = s;
}
/* --------------------------- */
/*
* Panic is called on unresolvable
* fatal errors.
* It syncs, prints "panic: mesg" and
* then loops.
*/
panic(s)
char *s;
{
panicstr = s;
update();
printf("panic: %s\n", s);
for(;;)
idle();
}
/* --------------------------- */
/*
* prdev prints a warning message of the
* form "mesg on dev x/y".
* x and y are the major and minor parts of
* the device argument.
*/
prdev(str, dev)
{
printf("%s on dev %l/%l\n", str, dev.d_major, dev.d_minor);
}
/* --------------------------- */
/*
* deverr prints a diagnostic from
* a device driver.
* It prints the device, block number,
* and an octal word (usually some error
* status register) passed as argument.
*/
deverror(bp, o1, o2)
int *bp;
{
register *rbp;
rbp = bp;
prdev("err", rbp->b_dev);
printf("bn%l er%o %o\n", rbp->b_blkno, o1, o2);
}
/* --------------------------- */