1: /*
2: * Copyright (c) 1986 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)prf.c 1.4 (2.11BSD) 1996/06/04
7: */
8:
9: #include "../machine/cons.h"
10:
11: #define KLADDR ((struct dldevice *)0177560)
12:
13: #define CTRL(x) ('x' & 037)
14:
15: /*
16: * Scaled down version of C Library printf. Only %s %u %d (==%u) %o %x %D
17: * are recognized. Used to print diagnostic information directly on
18: * console tty. Since it is not interrupt driven, all system activities
19: * are pretty much suspended. Printf should not be used for chit-chat.
20: */
21: printf(fmt, x1)
22: register char *fmt;
23: unsigned x1;
24: {
25: register c;
26: register unsigned int *adx;
27: unsigned char *s;
28:
29: adx = &x1;
30: loop:
31: while ((c = *fmt++) != '%') {
32: if (c == '\0')
33: return;
34: putchar(c);
35: }
36: c = *fmt++;
37: if (c == 'd' || c == 'u' || c == 'o' || c == 'x')
38: printn((long)*adx, c=='o'? 8: (c=='x'? 16:10));
39: else if (c == 's') {
40: s = (unsigned char *)*adx;
41: while (c = *s++)
42: putchar(c);
43: } else if (c == 'D' || c == 'O') {
44: printn(*(long *)adx, c == 'D' ? 10 : 8);
45: adx += (sizeof(long) / sizeof(int)) - 1;
46: } else if (c == 'c')
47: putchar((char *)*adx);
48: adx++;
49: goto loop;
50: }
51:
52: /*
53: * Print an unsigned integer in base b.
54: */
55: printn(n, b)
56: long n;
57: register int b;
58: {
59: long a;
60:
61: if (n < 0) { /* shouldn't happen */
62: putchar('-');
63: n = -n;
64: }
65: if (a = n/b)
66: printn(a, b);
67: putchar("0123456789ABCDEF"[(int)(n%b)]);
68: }
69:
70: putchar(c)
71: register c;
72: {
73: register s;
74: register unsigned timo;
75:
76: #ifdef notdef
77: /*
78: * If last char was a break or null, don't print
79: */
80: if ((KLADDR->dlrbuf & 0177) == 0)
81: return;
82: #endif
83: /*
84: * If we got a XOFF, wait for a XON
85: */
86: if ((KLADDR->dlrcsr & DL_RDONE) != 0)
87: if ((KLADDR->dlrbuf & 0177) == 19)
88: while ((KLADDR->dlrbuf & 0177) != 17)
89: continue;
90: /*
91: * Try waiting for the console tty to come ready,
92: * otherwise give up after a reasonable time.
93: */
94: timo=60000;
95: while ((KLADDR->dlxcsr & DLXCSR_TRDY) == 0)
96: if (--timo == 0)
97: break;
98: if (c == 0)
99: return(c);
100: s = KLADDR->dlxcsr;
101: KLADDR->dlxcsr = 0;
102: KLADDR->dlxbuf = c;
103: if (c == '\n') {
104: putchar('\r');
105: putchar(0177);
106: }
107: putchar(0);
108: KLADDR->dlxcsr = s;
109: return(c);
110: }
111:
112: getchar()
113: {
114: register c;
115:
116: KLADDR->dlrcsr = DL_RE;
117: while ((KLADDR->dlrcsr & DL_RDONE) == 0)
118: continue;
119: c = KLADDR->dlrbuf & 0177;
120: if (c=='\r')
121: c = '\n';
122: return(c);
123: }
124:
125: gets(buf)
126: char *buf;
127: {
128: register char *lp, *cp;
129: register int c;
130:
131: lp = buf;
132: for (;;) {
133: c = getchar() & 0177;
134: switch (c) {
135: default:
136: if (c < ' ' || c >= 127)
137: putchar(CTRL(G));
138: else {
139: *lp++ = c;
140: putchar(c);
141: }
142: break;
143:
144: case '\n':
145: case '\r':
146: putchar('\n');
147: c = '\n';
148: *lp++ = '\0';
149: return;
150:
151: case '\177':
152: case '\b':
153: case '#':
154: if (lp <= buf)
155: putchar(CTRL(G));
156: else {
157: lp--;
158: putchar('\b');
159: putchar(' ');
160: putchar('\b');
161: }
162: break;
163:
164: case CTRL(U):
165: case '@':
166: while (lp > buf) {
167: lp--;
168: putchar('\b');
169: putchar(' ');
170: putchar('\b');
171: }
172: break;
173:
174: case CTRL(R):
175: putchar('^');
176: putchar('R');
177: putchar('\n');
178: for (cp = buf; cp < lp; cp++)
179: putchar(*cp);
180: break;
181: }
182: }
183: }
Defined functions
gets
defined in line
125; used 17 times
- in /usr/src/sys/pdpstand/boot.c line
181
- in /usr/src/sys/pdpstand/disklabel.c line
30,
236,
247,
257,
290,
352,
411,
419,
434,
449,
463,
640,
661
- in /usr/src/sys/pdpstand/sys.c line
663
- in /usr/src/sys/pdpstand/toyset.s line
32,
43
printf
defined in line
21; used 173 times
- in /usr/src/sys/pdpstand/boot.c line
156,
180,
191-196(2),
232,
265,
285,
337,
345-347(2),
354,
360,
425,
681,
689-692(2),
751
- in /usr/src/sys/pdpstand/br.c line
52,
88
- in /usr/src/sys/pdpstand/conf.c line
170
- in /usr/src/sys/pdpstand/disklabel.c line
25-29(2),
37,
43,
56,
63-64(2),
75,
92,
126,
144-145(2),
177-178(2),
224-225(2),
235,
246,
256,
288-289(2),
304-305(2),
341-342(2),
350,
361,
388-394(4),
409,
418,
433,
448,
455,
462,
469,
511-513(2),
554,
565,
574,
612,
623,
639,
646,
660,
667,
716-726(3),
753,
759,
780-782(3)
- in /usr/src/sys/pdpstand/displaylab.c line
25-54(19),
60-82(7),
88
- in /usr/src/sys/pdpstand/hk.c line
92
- in /usr/src/sys/pdpstand/ht.c line
134-138(2)
- in /usr/src/sys/pdpstand/label.c line
52,
61-69(3),
99,
165
- in /usr/src/sys/pdpstand/makesimtape.c line
116
- in /usr/src/sys/pdpstand/maketape.c line
74
- in /usr/src/sys/pdpstand/ra.c line
95,
124,
175-180(2),
186,
226,
256
- in /usr/src/sys/pdpstand/rk.c line
52
- in /usr/src/sys/pdpstand/rl.c line
116,
190
- in /usr/src/sys/pdpstand/rx.c line
98
- in /usr/src/sys/pdpstand/si.c line
80
- in /usr/src/sys/pdpstand/sys.c line
101,
124,
144,
174,
212,
234,
295,
307,
348,
476,
485,
518,
572,
607,
616-643(11),
662
- in /usr/src/sys/pdpstand/tm.c line
105-108(2)
- in /usr/src/sys/pdpstand/tmscp.c line
116,
124,
132-136(2),
149,
225,
258
- in /usr/src/sys/pdpstand/toyset.s line
32,
205,
230
- in /usr/src/sys/pdpstand/ts.c line
128-133(2)
- in /usr/src/sys/pdpstand/xp.c line
109,
223-229(3),
264-266(2)
putchar
defined in line
70; used 33 times
- in line 34,
42-47(2),
62-67(2),
104-107(3),
137-140(2),
146,
155-160(4),
168-179(7)
- in /usr/src/sys/pdpstand/disklabel.c line
514,
694-697(3)
- in /usr/src/sys/pdpstand/displaylab.c line
23,
79-81(2),
87-90(2)
- in /usr/src/sys/pdpstand/sys.c line
441
- in /usr/src/sys/pdpstand/ts.c line
141
Defined macros
CTRL
defined in line
13; used 4 times
KLADDR
defined in line
11; used 12 times