This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.0'.
[unix-history] / sys / kern / subr_prf.c
index 248b85a..e8ecca2 100644 (file)
@@ -30,7 +30,8 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     @(#)subr_prf.c  7.30 (Berkeley) 6/29/91
+ *     from: @(#)subr_prf.c    7.30 (Berkeley) 6/29/91
+ *     $Id$
  */
 
 #include "param.h"
  */
 
 #include "param.h"
 
 struct tty *constty;                   /* pointer to console "window" tty */
 
 
 struct tty *constty;                   /* pointer to console "window" tty */
 
-#ifdef KADB
+#if defined(KADB) || defined(PANICWAIT)
 extern cngetc();                       /* standard console getc */
 extern cngetc();                       /* standard console getc */
+#endif
+#ifdef KADB
 int    (*v_getc)() = cngetc;           /* "" getc from virtual console */
 extern cnpoll();
 int    (*v_poll)() = cnpoll;           /* kdb hook to enable input polling */
 int    (*v_getc)() = cngetc;           /* "" getc from virtual console */
 extern cnpoll();
 int    (*v_poll)() = cnpoll;           /* kdb hook to enable input polling */
@@ -77,21 +80,33 @@ static void  logpri __P((int level));
 static void  putchar __P((int ch, int flags, struct tty *tp));
 static char *ksprintn __P((u_long num, int base, int *len));
 void  kprintf __P((const char *fmt, int flags, struct tty *tp, va_list));
 static void  putchar __P((int ch, int flags, struct tty *tp));
 static char *ksprintn __P((u_long num, int base, int *len));
 void  kprintf __P((const char *fmt, int flags, struct tty *tp, va_list));
+volatile void boot(int bootopt);
 
 /*
  * Variable panicstr contains argument to first call to panic; used
  * as flag to indicate that the kernel has already called panic.
  */
 
 /*
  * Variable panicstr contains argument to first call to panic; used
  * as flag to indicate that the kernel has already called panic.
  */
-char   *panicstr;
+const char     *panicstr;
+
+/*
+ * Message buffer
+ */
+struct msgbuf *msgbufp;
+int msgbufmapped;
 
 /*
  * Panic is called on unresolvable fatal errors.  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 is called on unresolvable fatal errors.  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.
  */
+#ifdef __STDC__
+volatile void
+panic(const char *msg)
+#else
 void
 panic(msg)
        char *msg;
 void
 panic(msg)
        char *msg;
+#endif
 {
        int bootopt = RB_AUTOBOOT | RB_DUMP;
 
 {
        int bootopt = RB_AUTOBOOT | RB_DUMP;
 
@@ -116,7 +131,14 @@ panic(msg)
 #if NDDB > 0
        Debugger ();
 #else
 #if NDDB > 0
        Debugger ();
 #else
-/* pg("press key to boot/dump");*/
+#ifdef PANICWAIT
+       printf("hit any key to boot/dump...\n>");
+       cngetc();
+#endif /* PANICWAIT */
+#ifdef PANICDELAY
+       printf("Waiting 20 secs....\n");
+       DELAY(20000000);
+#endif /* PANICDELAY */
 #endif
        boot(bootopt);
 }
 #endif
        boot(bootopt);
 }
@@ -272,7 +294,7 @@ logpri(level)
        putchar('>', TOLOG, NULL);
 }
 
        putchar('>', TOLOG, NULL);
 }
 
-void
+int
 #ifdef __STDC__
 addlog(const char *fmt, ...)
 #else
 #ifdef __STDC__
 addlog(const char *fmt, ...)
 #else
@@ -294,11 +316,12 @@ addlog(fmt /*, va_alist */)
                va_end(ap);
        }
        logwakeup();
                va_end(ap);
        }
        logwakeup();
+       return (0);
 }
 
 int    consintr = 1;                   /* ok to handle console interrupts? */
 
 }
 
 int    consintr = 1;                   /* ok to handle console interrupts? */
 
-void
+int
 #ifdef __STDC__
 printf(const char *fmt, ...)
 #else
 #ifdef __STDC__
 printf(const char *fmt, ...)
 #else
@@ -317,6 +340,8 @@ printf(fmt /*, va_alist */)
        if (!panicstr)
                logwakeup();
        consintr = savintr;             /* reenable interrupts */
        if (!panicstr)
                logwakeup();
        consintr = savintr;             /* reenable interrupts */
+
+       return 0;       /* for compatibility with libc's printf() */
 }
 
 /*
 }
 
 /*
@@ -362,7 +387,7 @@ kprintf(fmt, flags, tp, ap)
        struct tty *tp;
        va_list ap;
 {
        struct tty *tp;
        va_list ap;
 {
-       register char *p;
+       register char *p, *p2;
        register int ch, n;
        u_long ul;
        int base, lflag, tmp, width;
        register int ch, n;
        u_long ul;
        int base, lflag, tmp, width;
@@ -396,7 +421,7 @@ reswitch:   switch (ch = *(u_char *)fmt++) {
                case 'b':
                        ul = va_arg(ap, int);
                        p = va_arg(ap, char *);
                case 'b':
                        ul = va_arg(ap, int);
                        p = va_arg(ap, char *);
-                       for (p = ksprintn(ul, *p++, NULL); ch = *p--;)
+                       for (p2 = ksprintn(ul, *p++, NULL); ch = *p2--;)
                                putchar(ch, flags, tp);
 
                        if (!ul)
                                putchar(ch, flags, tp);
 
                        if (!ul)
@@ -474,7 +499,6 @@ putchar(c, flags, tp)
        int flags;
        struct tty *tp;
 {
        int flags;
        struct tty *tp;
 {
-       extern int msgbufmapped;
        register struct msgbuf *mbp;
 
        if (panicstr)
        register struct msgbuf *mbp;
 
        if (panicstr)
@@ -505,8 +529,10 @@ putchar(c, flags, tp)
  * Scaled down version of sprintf(3).
  */
 #ifdef __STDC__
  * Scaled down version of sprintf(3).
  */
 #ifdef __STDC__
+int
 sprintf(char *buf, const char *cfmt, ...)
 #else
 sprintf(char *buf, const char *cfmt, ...)
 #else
+int
 sprintf(buf, cfmt /*, va_alist */)
        char *buf, *cfmt;
 #endif
 sprintf(buf, cfmt /*, va_alist */)
        char *buf, *cfmt;
 #endif