add memory filesystem initialization
[unix-history] / usr / src / sys / kern / subr_prf.c
index 63effe4..b2e04fe 100644 (file)
@@ -1,9 +1,9 @@
 /*
 /*
- * Copyright (c) 1982, 1986 Regents of the University of California.
+ * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)subr_prf.c  7.7 (Berkeley) %G%
+ *     @(#)subr_prf.c  7.14 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
 #include "reboot.h"
 #include "vm.h"
 #include "msgbuf.h"
 #include "reboot.h"
 #include "vm.h"
 #include "msgbuf.h"
-#include "dir.h"
 #include "user.h"
 #include "proc.h"
 #include "ioctl.h"
 #include "tty.h"
 #include "syslog.h"
 
 #include "user.h"
 #include "proc.h"
 #include "ioctl.h"
 #include "tty.h"
 #include "syslog.h"
 
-#include "../machine/mtpr.h"
-#ifdef KDB
-#include "../machine/kdbparam.h"
+#include "machine/mtpr.h"
+#ifdef KADB
+#include "machine/kdbparam.h"
 #endif
 
 #define TOCONS 0x1
 #endif
 
 #define TOCONS 0x1
@@ -64,6 +63,15 @@ int  (*v_console)() = cnputc;        /* routine to putc on virtual console */
  *     printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
  * would produce output:
  *     reg=3<BITTWO,BITONE>
  *     printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
  * would produce output:
  *     reg=3<BITTWO,BITONE>
+ *
+ * Another additional format: %r is used to pass an additional format string
+ * and argument list recursively.  Usage is typically:
+ *
+ * fn(otherstuff, fmt [, arg1, ... ] )
+ *     char *fmt;
+ *     u_int arg1, ...;
+ *
+ *     printf("prefix: %r, other stuff\n", fmt, &arg1);
  */
 #if defined(tahoe)
 int    consintr;
  */
 #if defined(tahoe)
 int    consintr;
@@ -171,6 +179,20 @@ logpri(level)
        putchar('>', TOLOG, (struct tty *)0);
 }
 
        putchar('>', TOLOG, (struct tty *)0);
 }
 
+/*VARARGS1*/
+addlog(fmt, x1)
+       char *fmt;
+       unsigned x1;
+{
+       register s = splhigh();
+
+       prf(fmt, &x1, TOLOG, (struct tty *)0);
+       splx(s);
+       if (!log_open)
+               prf(fmt, &x1, TOCONS, (struct tty *)0);
+       logwakeup();
+}
+
 prf(fmt, adx, flags, ttyp)
        register char *fmt;
        register u_int *adx;
 prf(fmt, adx, flags, ttyp)
        register char *fmt;
        register u_int *adx;
@@ -209,12 +231,12 @@ number:
                break;
        case 'c':
                b = *adx;
                break;
        case 'c':
                b = *adx;
-#if ENDIAN == LITTLE
+#if BYTE_ORDER == LITTLE_ENDIAN
                for (i = 24; i >= 0; i -= 8)
                        if (c = (b >> i) & 0x7f)
                                putchar(c, flags, ttyp);
 #endif
                for (i = 24; i >= 0; i -= 8)
                        if (c = (b >> i) & 0x7f)
                                putchar(c, flags, ttyp);
 #endif
-#if ENDIAN == BIG
+#if BYTE_ORDER == BIG_ENDIAN
                if (c = (b & 0x7f))
                        putchar(c, flags, ttyp);
 #endif
                if (c = (b & 0x7f))
                        putchar(c, flags, ttyp);
 #endif
@@ -246,6 +268,11 @@ number:
                        putchar(c, flags, ttyp);
                break;
 
                        putchar(c, flags, ttyp);
                break;
 
+       case 'r':
+               s = (char *)*adx++;
+               prf(s, (u_int *)*adx, flags, ttyp);
+               break;
+
        case '%':
                putchar('%', flags, ttyp);
                break;
        case '%':
                putchar('%', flags, ttyp);
                break;
@@ -299,12 +326,12 @@ panic(s)
                panicstr = s;
        }
        printf("panic: %s\n", s);
                panicstr = s;
        }
        printf("panic: %s\n", s);
-#ifdef KDB
+#ifdef KADB
        if (boothowto & RB_KDB) {
        if (boothowto & RB_KDB) {
-               int s = splnet();       /* below kdb pri */
+               int x = splnet();       /* below kdb pri */
 
                setsoftkdb();
 
                setsoftkdb();
-               splx(s);
+               splx(x);
        }
 #endif
        boot(bootopt);
        }
 #endif
        boot(bootopt);
@@ -320,19 +347,6 @@ tablefull(tab)
        log(LOG_ERR, "%s: table is full\n", tab);
 }
 
        log(LOG_ERR, "%s: table is full\n", tab);
 }
 
-/*
- * Hard error is the preface to plaintive error messages
- * about failing disk transfers.
- */
-harderr(bp, cp)
-       struct buf *bp;
-       char *cp;
-{
-
-       printf("%s%d%c: hard error sn%d ", cp,
-           minor(bp->b_dev) >> 3, '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
@@ -343,7 +357,7 @@ putchar(c, flags, tp)
        register int c;
        struct tty *tp;
 {
        register int c;
        struct tty *tp;
 {
-       int startflags = flags;
+       extern int msgbufmapped;
 
        if (panicstr)
                constty = 0;
 
        if (panicstr)
                constty = 0;
@@ -369,11 +383,8 @@ putchar(c, flags, tp)
                        constty = 0;
                splx(s);
        }
                        constty = 0;
                splx(s);
        }
-       /*
-        * Can send to log only after memory management enabled:
-        * this has happened by the time maxmem is set.
-        */
-       if ((flags & TOLOG) && c != '\0' && c != '\r' && c != 0177 && maxmem) {
+       if ((flags & TOLOG) && c != '\0' && c != '\r' && c != 0177 &&
+           msgbufmapped) {
                if (msgbuf.msg_magic != MSG_MAGIC) {
                        register int i;
 
                if (msgbuf.msg_magic != MSG_MAGIC) {
                        register int i;