put vax headers in their place
[unix-history] / usr / src / sys / kern / subr_prf.c
index cb390fa..509c1ff 100644 (file)
@@ -1,11 +1,10 @@
-/*     subr_prf.c      4.10    %G%     */
+/*     subr_prf.c      4.22    82/10/10        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/seg.h"
 #include "../h/buf.h"
 #include "../h/conf.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/seg.h"
 #include "../h/buf.h"
 #include "../h/conf.h"
-#include "../h/mtpr.h"
 #include "../h/reboot.h"
 #include "../h/vm.h"
 #include "../h/msgbuf.h"
 #include "../h/reboot.h"
 #include "../h/vm.h"
 #include "../h/msgbuf.h"
  * panicstr contains argument to last
  * call to panic.
  */
  * panicstr contains argument to last
  * call to panic.
  */
-
 char   *panicstr;
 
 /*
  * Scaled down version of C Library printf.
 char   *panicstr;
 
 /*
  * Scaled down version of C Library printf.
- * Only %s %u %d (==%u) %o %x %D 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.
+ * Used to print diagnostic information directly on console tty.
+ * Since it is not interrupt driven, all system activities are
+ * suspended.  Printf should not be used for chit-chat.
+ *
+ * One additional format: %b is supported to decode error registers.
+ * Usage is:
+ *     printf("reg=%b\n", regval, "<base><arg>*");
+ * Where <base> is the output base expressed as a control character,
+ * e.g. \10 gives octal; \20 gives hex.  Each arg is a sequence of
+ * characters, the first of which gives the bit number to be inspected
+ * (origin 1), and the next characters (up to a control character, i.e.
+ * a character <= 32), give the name of the register.  Thus
+ *     printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
+ * would produce output:
+ *     reg=2<BITTWO,BITONE>
  */
 /*VARARGS1*/
 printf(fmt, x1)
  */
 /*VARARGS1*/
 printf(fmt, x1)
-register char *fmt;
-unsigned x1;
+       char *fmt;
+       unsigned x1;
 {
 
        prf(fmt, &x1, 0);
 }
 
 /*
 {
 
        prf(fmt, &x1, 0);
 }
 
 /*
- * print to the current users terminal,
- * guarantee not to sleep (so can be called by intr routine)
- * no watermark checking - so no verbose messages
+ * Uprintf prints to the current user's terminal,
+ * guarantees not to sleep (so can be called by interrupt routines)
+ * and does no watermark checking - (so no verbose messages).
  */
 /*VARARGS1*/
 uprintf(fmt, x1)
  */
 /*VARARGS1*/
 uprintf(fmt, x1)
-       char    *fmt;
+       char *fmt;
        unsigned x1;
 {
 
        prf(fmt, &x1, 2);
 }
 
        unsigned x1;
 {
 
        prf(fmt, &x1, 2);
 }
 
-/* THIS CODE IS VAX DEPENDENT */
 prf(fmt, adx, touser)
 prf(fmt, adx, touser)
-register char *fmt;
-register u_int *adx;
+       register char *fmt;
+       register u_int *adx;
 {
        register int b, c, i;
        char *s;
 {
        register int b, c, i;
        char *s;
@@ -71,6 +76,7 @@ loop:
        }
 again:
        c = *fmt++;
        }
 again:
        c = *fmt++;
+       /* THIS CODE IS VAX DEPENDENT IN HANDLING %l? AND %c */
        switch (c) {
 
        case 'l':
        switch (c) {
 
        case 'l':
@@ -85,7 +91,7 @@ again:
        case 'o': case 'O':
                b = 8;
 number:
        case 'o': case 'O':
                b = 8;
 number:
-               printn(*adx, b, touser);
+               printn((u_long)*adx, b, touser);
                break;
        case 'c':
                b = *adx;
                break;
        case 'c':
                b = *adx;
@@ -96,7 +102,7 @@ number:
        case 'b':
                b = *adx++;
                s = (char *)*adx;
        case 'b':
                b = *adx++;
                s = (char *)*adx;
-               printn(b, *s++, touser);
+               printn((u_long)b, *s++, touser);
                any = 0;
                if (b) {
                        putchar('<', touser);
                any = 0;
                if (b) {
                        putchar('<', touser);
@@ -111,7 +117,8 @@ number:
                                        for (; *s > 32; s++)
                                                ;
                        }
                                        for (; *s > 32; s++)
                                                ;
                        }
-                       putchar('>', touser);
+                       if (any)
+                               putchar('>', touser);
                }
                break;
 
                }
                break;
 
@@ -120,14 +127,21 @@ number:
                while (c = *s++)
                        putchar(c, touser);
                break;
                while (c = *s++)
                        putchar(c, touser);
                break;
+
+       case '%':
+               putchar('%', touser);
+               break;
        }
        adx++;
        goto loop;
 }
        }
        adx++;
        goto loop;
 }
-/* END VAX DEPENDENT CODE */
 
 
+/*
+ * Printn prints a number n in base b.
+ * We don't use recursion to avoid deep kernel stacks.
+ */
 printn(n, b, touser)
 printn(n, b, touser)
-       unsigned long n;
+       u_long n;
 {
        char prbuf[11];
        register char *cp;
 {
        char prbuf[11];
        register char *cp;
@@ -148,39 +162,45 @@ printn(n, b, touser)
 
 /*
  * Panic is called on unresolvable fatal errors.
 
 /*
  * Panic is called on unresolvable fatal errors.
- * It syncs, prints "panic: mesg", and then reboots.
+ * It prints "panic: mesg", and then reboots.
+ * If we are called twice, then we avoid trying to
+ * sync the disks as this often leads to recursive panics.
  */
 panic(s)
  */
 panic(s)
-char *s;
+       char *s;
 {
 {
+       int bootopt = RB_AUTOBOOT;
 
 
+       if (panicstr)
+               bootopt |= RB_NOSYNC;
        panicstr = s;
        printf("panic: %s\n", s);
        panicstr = s;
        printf("panic: %s\n", s);
-       (void) spl0();
-       for(;;)
-               boot(RB_PANIC, RB_AUTOBOOT);
+       boot(RB_PANIC, bootopt);
 }
 
 /*
 }
 
 /*
- * 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.
+ * Warn that a system table is full.
  */
  */
-prdev(str, dev)
-       char *str;
-       dev_t dev;
+tablefull(tab)
+       char *tab;
 {
 
 {
 
-       printf("%s on dev %d/%d\n", str, major(dev), minor(dev));
+       printf("%s: table is full\n", tab);
 }
 
 }
 
-harderr(bp)
+/*
+ * Hard error is the preface to plaintive error messages
+ * about failing disk transfers.
+ */
+harderr(bp, cp)
        struct buf *bp;
        struct buf *bp;
+       char *cp;
 {
 
 {
 
-       printf("hard err bn %d ", bp->b_blkno);
+       printf("%s%d%c: hard error sn%d ", cp,
+           dkunit(bp), 'a'+(minor(bp->b_dev)&07), bp->b_blkno);
 }
 }
+
 /*
  * Print a character on console or users terminal.
  * If destination is console then the last MSGBUFS characters
 /*
  * Print a character on console or users terminal.
  * If destination is console then the last MSGBUFS characters
@@ -194,16 +214,17 @@ putchar(c, touser)
        if (touser) {
                register struct tty *tp = u.u_ttyp;
 
        if (touser) {
                register struct tty *tp = u.u_ttyp;
 
-               if (tp && (tp->t_state&CARR_ON)) {
+               if (tp && (tp->t_state&TS_CARR_ON)) {
                        register s = spl6();
                        if (c == '\n')
                        register s = spl6();
                        if (c == '\n')
-                               ttyoutput('\r', tp);
-                       ttyoutput(c, tp);
+                               (void) ttyoutput('\r', tp);
+                       (void) ttyoutput(c, tp);
                        ttstart(tp);
                        splx(s);
                }
                return;
        }
                        ttstart(tp);
                        splx(s);
                }
                return;
        }
+#include "../vax/mtpr.h"               /* XXX */
        if (c != '\0' && c != '\r' && c != 0177 && mfpr(MAPEN)) {
                if (msgbuf.msg_magic != MSG_MAGIC) {
                        msgbuf.msg_bufx = 0;
        if (c != '\0' && c != '\r' && c != 0177 && mfpr(MAPEN)) {
                if (msgbuf.msg_magic != MSG_MAGIC) {
                        msgbuf.msg_bufx = 0;