1:
2: /*
3: * Scaled down version of C Library printf.
4: * Only %s %u %d (==%u) %o %x %D are recognized.
5: * Used to print diagnostic information
6: * directly on console tty.
7: * Since it is not interrupt driven,
8: * all system activities are pretty much
9: * suspended.
10: * Printf should not be used for chit-chat.
11: */
12: printf(fmt, x1)
13: register char *fmt;
14: unsigned x1;
15: {
16: register c;
17: register unsigned int *adx;
18: char *s;
19:
20: adx = &x1;
21: loop:
22: while((c = *fmt++) != '%') {
23: if(c == '\0')
24: return;
25: putchar(c);
26: }
27: c = *fmt++;
28: if(c == 'd' || c == 'u' || c == 'o' || c == 'x')
29: printn((long)*adx, c=='o'? 8: (c=='x'? 16:10));
30: else if(c == 's') {
31: s = (char *)*adx;
32: while(c = *s++)
33: putchar(c);
34: } else if (c == 'D' || c == 'O') {
35: printn(*(long *)adx, c == 'D' ? 10 : 8);
36: adx += (sizeof(long) / sizeof(int)) - 1;
37: } else if (c == 'c')
38: putchar((char *)*adx);
39: adx++;
40: goto loop;
41: }
42:
43: /*
44: * Print an unsigned integer in base b.
45: */
46: printn(n, b)
47: long n;
48: {
49: register long a;
50:
51: if (n<0) { /* shouldn't happen */
52: putchar('-');
53: n = -n;
54: }
55: if(a = n/b)
56: printn(a, b);
57: putchar("0123456789ABCDEF"[(int)(n%b)]);
58: }
59:
60:
61:
62: struct device {
63: int rcsr,rbuf;
64: int tcsr,tbuf;
65: };
66: struct device *KLADDR {0177560};
67: putchar(c)
68: register c;
69: {
70: register s;
71: register unsigned timo;
72:
73: /*
74: * If last char was a break or null, don't print
75: if ((KLADDR->rbuf&0177) == 0)
76: return;
77: */
78: timo = 60000;
79: /*
80: * Try waiting for the console tty to come ready,
81: * otherwise give up after a reasonable time.
82: */
83: while((KLADDR->tcsr&0200) == 0)
84: if(--timo == 0)
85: break;
86: if(c == 0)
87: return;
88: s = KLADDR->tcsr;
89: KLADDR->tcsr = 0;
90: KLADDR->tbuf = c;
91: if(c == '\n') {
92: putchar('\r');
93: putchar(0177);
94: putchar(0177);
95: putchar(0177);
96: putchar(0177);
97: putchar(0177);
98: }
99: putchar(0);
100: KLADDR->tcsr = s;
101: }
102:
103: getchar()
104: {
105: register c;
106:
107: KLADDR->rcsr = 1;
108: while((KLADDR->rcsr&0200)==0);
109: c = KLADDR->rbuf&0177;
110: if (c=='\r')
111: c = '\n';
112: putchar(c);
113: return(c);
114: }
115:
116: gets(buf)
117: char *buf;
118: {
119: register char *lp;
120: register c;
121:
122: lp = buf;
123: for (;;) {
124: c = getchar() & 0177;
125: if (c>='A' && c<='Z')
126: c -= 'A' - 'a';
127: if (lp != buf && *(lp-1) == '\\') {
128: lp--;
129: if (c>='a' && c<='z') {
130: c += 'A' - 'a';
131: goto store;
132: }
133: switch ( c) {
134: case '(':
135: c = '{';
136: break;
137: case ')':
138: c = '}';
139: break;
140: case '!':
141: c = '|';
142: break;
143: case '^':
144: c = '~';
145: break;
146: case '\'':
147: c = '`';
148: break;
149: }
150: }
151: store:
152: switch(c) {
153: case '\n':
154: case '\r':
155: c = '\n';
156: *lp++ = '\0';
157: return;
158: case '\b':
159: case '#':
160: lp--;
161: if (lp < buf)
162: lp = buf;
163: continue;
164: case '@':
165: lp = buf;
166: putchar('\n');
167: continue;
168: default:
169: *lp++ = c;
170: }
171: }
172: }
Defined functions
gets
defined in line
116; used 4 times
printf
defined in line
12; used 413 times
- in /usr/src/sys/GENERIC/checksys.c line
64,
70,
83,
96,
108,
114,
120,
141-146(2),
152,
161,
170,
183-191(5),
203-208(2)
- in /usr/src/sys/GENERIC/genassym.c line
25-234(90)
- in /usr/src/sys/conf/genassym.c line
25-234(90)
- in /usr/src/sys/dev/Others/bk.c line
93
- in /usr/src/sys/dev/Others/dmc.c line
306-310(2),
328-332(2),
353-358(2),
399,
469
- in /usr/src/sys/dev/Others/du.c line
298-307(4),
408-417(4)
- in /usr/src/sys/dev/Others/dv.c line
212,
266,
287,
310-311(2),
319,
390,
402
- in /usr/src/sys/dev/Others/ft.c line
74,
104,
196
- in /usr/src/sys/dev/Others/ml.c line
105,
199
- in /usr/src/sys/dev/Others/mx1.c line
481
- in /usr/src/sys/dev/Others/pk0.c line
73
- in /usr/src/sys/dev/Others/pk2.c line
179
- in /usr/src/sys/dev/Others/rx.c line
138,
185,
245,
595,
630-636(5)
- in /usr/src/sys/dev/Others/rx2.c line
183
- in /usr/src/sys/dev/Others/rx3.c line
385,
445,
498,
670
- in /usr/src/sys/dev/cary.c line
215
- in /usr/src/sys/dev/dh.c line
211,
330
- in /usr/src/sys/dev/dvhp.c line
319,
330,
449
- in /usr/src/sys/dev/dz.c line
274
- in /usr/src/sys/dev/hk.c line
285-287(2),
301,
351,
357,
364,
637,
675,
689,
700
- in /usr/src/sys/dev/hp.badsect.c line
382,
404,
546,
601,
609
- in /usr/src/sys/dev/hp.c line
330,
341,
458
- in /usr/src/sys/dev/hs.c line
135
- in /usr/src/sys/dev/ht.c line
335
- in /usr/src/sys/dev/rf.c line
107-112(2)
- in /usr/src/sys/dev/rk.c line
118-123(2)
- in /usr/src/sys/dev/rl.c line
93,
178,
193
- in /usr/src/sys/dev/rm.badsect.c line
426,
451,
605,
660,
668
- in /usr/src/sys/dev/rm.c line
353,
364,
492
- in /usr/src/sys/dev/rp.c line
138-143(2)
- in /usr/src/sys/dev/tm.c line
518,
579
- in /usr/src/sys/dev/ts.c line
438-440(2),
447-457(5),
557
- in /usr/src/sys/dev/tty.c line
216
- in /usr/src/sys/dev/vp.c line
271,
323
- in /usr/src/sys/dev/xp.badsect.c line
217,
545,
571,
705,
761,
769
- in /usr/src/sys/dev/xp.c line
194,
487,
497,
606
- in /usr/src/sys/stand/bootstrap/boot.c line
107,
120-126(3),
174,
195,
248,
256-258(2),
265,
271,
287
- in /usr/src/sys/stand/libsa/SYS.c line
59,
81,
101,
131,
140,
166,
191-192(2),
199,
258,
460,
469,
477,
483,
507,
540,
549-577(11)
- in /usr/src/sys/stand/libsa/dvhp.c line
132
- in /usr/src/sys/stand/libsa/hk.c line
136
- in /usr/src/sys/stand/libsa/ht.c line
138-142(2),
150
- in /usr/src/sys/stand/libsa/rk.c line
56
- in /usr/src/sys/stand/libsa/rl.c line
104,
165
- in /usr/src/sys/stand/libsa/rm.c line
119
- in /usr/src/sys/stand/libsa/rp.c line
71
- in /usr/src/sys/stand/libsa/tm.c line
96-98(2),
106
- in /usr/src/sys/stand/libsa/ts.c line
283-286(2),
296,
303
- in /usr/src/sys/stand/libsa/xp.c line
160,
181
- in /usr/src/sys/stand/util/bcopy.c line
9-16(3)
- in /usr/src/sys/stand/util/cat.c line
7-9(2)
- in /usr/src/sys/stand/util/maketape.c line
56
- in /usr/src/sys/sys/alloc.c line
416
- in /usr/src/sys/sys/iget.c line
352
- in /usr/src/sys/sys/machdep.c line
154,
208,
326,
607,
626,
646-653(3),
695-712(7)
- in /usr/src/sys/sys/main.c line
46
- in /usr/src/sys/sys/malloc.c line
91,
215,
276
- in /usr/src/sys/sys/sigjcl.c line
395
- in /usr/src/sys/sys/slp.c line
89,
238
- in /usr/src/sys/sys/sys1.c line
671
- in /usr/src/sys/sys/trap.c line
113-123(6),
210-214(3),
243-247(2)
Defined variables
Defined struct's