|
|
1.1 ! root 1: #include "sys/param.h" ! 2: #include "sys/buf.h" ! 3: #include "sys/mtpr.h" ! 4: #include "sys/msgbuf.h" ! 5: #include "sys/user.h" ! 6: #include "sys/pte.h" ! 7: ! 8: /* ! 9: * In case console is off, ! 10: * panicstr contains argument to last ! 11: * call to panic. ! 12: */ ! 13: char *panicstr; ! 14: ! 15: /* ! 16: * Scaled down version of C Library printf. ! 17: * Used to print diagnostic information directly on console tty. ! 18: * Since it is not interrupt driven, all system activities are ! 19: * suspended. Printf should not be used for chit-chat. ! 20: */ ! 21: /*VARARGS1*/ ! 22: printf(fmt, x1) ! 23: char *fmt; ! 24: unsigned x1; ! 25: { ! 26: ! 27: prf(fmt, &x1, 0); ! 28: } ! 29: ! 30: prf(fmt, adx, touser) ! 31: register char *fmt; ! 32: register u_int *adx; ! 33: { ! 34: register int b, c, i; ! 35: char *s; ! 36: int any; ! 37: ! 38: loop: ! 39: while ((c = *fmt++) != '%') { ! 40: if(c == '\0') ! 41: return; ! 42: putchar(c, touser); ! 43: } ! 44: again: ! 45: c = *fmt++; ! 46: /* THIS CODE IS VAX DEPENDENT IN HANDLING %l? AND %c */ ! 47: switch (c) { ! 48: ! 49: case 'l': ! 50: goto again; ! 51: case 'x': case 'X': ! 52: b = 16; ! 53: goto number; ! 54: case 'd': case 'D': ! 55: case 'u': /* what a joke */ ! 56: b = 10; ! 57: goto number; ! 58: case 'o': case 'O': ! 59: b = 8; ! 60: number: ! 61: printn((u_long)*adx, b, touser); ! 62: break; ! 63: case 'c': ! 64: b = *adx; ! 65: for (i = 24; i >= 0; i -= 8) ! 66: if (c = (b >> i) & 0x7f) ! 67: putchar(c, touser); ! 68: break; ! 69: case 'b': ! 70: b = *adx++; ! 71: s = (char *)*adx; ! 72: printn((u_long)b, *s++, touser); ! 73: any = 0; ! 74: if (b) { ! 75: putchar('<', touser); ! 76: while (i = *s++) { ! 77: if (b & (1 << (i-1))) { ! 78: if (any) ! 79: putchar(',', touser); ! 80: any = 1; ! 81: for (; (c = *s) > 32; s++) ! 82: putchar(c, touser); ! 83: } else ! 84: for (; *s > 32; s++) ! 85: ; ! 86: } ! 87: if (any) ! 88: putchar('>', touser); ! 89: } ! 90: break; ! 91: ! 92: case 's': ! 93: s = (char *)*adx; ! 94: while (c = *s++) ! 95: putchar(c, touser); ! 96: break; ! 97: ! 98: case '%': ! 99: putchar('%', touser); ! 100: break; ! 101: } ! 102: adx++; ! 103: goto loop; ! 104: } ! 105: ! 106: /* ! 107: * Printn prints a number n in base b. ! 108: * We don't use recursion to avoid deep kernel stacks. ! 109: */ ! 110: printn(n, b, touser) ! 111: u_long n; ! 112: { ! 113: char prbuf[11]; ! 114: register char *cp; ! 115: ! 116: if (b == 10 && (int)n < 0) { ! 117: putchar('-', touser); ! 118: n = (unsigned)(-(int)n); ! 119: } ! 120: cp = prbuf; ! 121: do { ! 122: *cp++ = "0123456789abcdef"[n%b]; ! 123: n /= b; ! 124: } while (n); ! 125: do ! 126: putchar(*--cp, touser); ! 127: while (cp > prbuf); ! 128: } ! 129: ! 130: /* ! 131: * Panic is called on unresolvable fatal errors. ! 132: * print `panic: mesg' and boot ! 133: * reboot may call update if it seems safe ! 134: */ ! 135: panic(s) ! 136: char *s; ! 137: { ! 138: static int panicked = 0; ! 139: ! 140: panicstr = s; ! 141: if (panicked++) { ! 142: printf("panic again: %s\n", s); ! 143: reboot(0); /* no sync, so probably won't reenter again */ ! 144: } ! 145: printf("panic: %s\n", s); ! 146: reboot(1); ! 147: } ! 148: ! 149: /* ! 150: * Warn that a system table is full. ! 151: */ ! 152: tablefull(tab) ! 153: char *tab; ! 154: { ! 155: ! 156: printf("%s: table is full\n", tab); ! 157: } ! 158: ! 159: /* ! 160: * Hard error is the preface to plaintive error messages ! 161: * about failing disk transfers. ! 162: * this is hopeless; the driver should do it. ! 163: * the magic constant 07 shows why. ! 164: */ ! 165: harderr(bp, cp) ! 166: struct buf *bp; ! 167: char *cp; ! 168: { ! 169: ! 170: printf("%s%d%o: hard error sn%d ", cp, ! 171: dkunit(bp), minor(bp->b_dev)&07, bp->b_blkno); ! 172: } ! 173: ! 174: struct pte *msgbufmap; ! 175: struct msgbuf *msgbuf; ! 176: ! 177: /* ! 178: * Print a character on console or users terminal. ! 179: * If destination is console then the last MSGBUFS characters ! 180: * are saved in msgbuf for inspection later. ! 181: */ ! 182: /*ARGSUSED*/ ! 183: putchar(c, touser) ! 184: register int c; ! 185: { ! 186: ! 187: if (touser) { ! 188: /* put them on user's stdout instead */ ! 189: return; ! 190: } ! 191: if (c != '\0' && c != '\r' && c != 0177 && mfpr(MAPEN)) { ! 192: if (msgbuf->msg_magic != MSG_MAGIC) { ! 193: msgbuf->msg_bufx = 0; ! 194: msgbuf->msg_magic = MSG_MAGIC; ! 195: } ! 196: if (msgbuf->msg_bufx < 0 || msgbuf->msg_bufx >= MSG_BSIZE) ! 197: msgbuf->msg_bufx = 0; ! 198: msgbuf->msg_bufc[msgbuf->msg_bufx++] = c; ! 199: } ! 200: if (c == 0) ! 201: return; ! 202: cnputc(c); ! 203: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.