Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sun68k/stand - implement putstr(), and use in vario...



details:   https://anonhg.NetBSD.org/src/rev/c6c2dfa98b73
branches:  trunk
changeset: 526973:c6c2dfa98b73
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed May 15 04:07:41 2002 +0000

description:
- implement putstr(), and use in various places instead of printf()
- wrap more debug stuff in #ifdef DEBUG
- for bootxx, provide minimal panic() which uses putstr() instead of printf()

bootxx is now < 7.5KB

diffstat:

 sys/arch/sun68k/stand/Makefile.inc          |   4 +-
 sys/arch/sun68k/stand/bootxx/Makefile       |   4 +-
 sys/arch/sun68k/stand/bootxx/bootxx.c       |   8 ++--
 sys/arch/sun68k/stand/bootxx/conf.c         |   4 ++-
 sys/arch/sun68k/stand/bootxx/panic_putstr.c |  18 +++++++++++++
 sys/arch/sun68k/stand/bootyy/conf.c         |   4 ++-
 sys/arch/sun68k/stand/libsa/Makefile        |   4 +-
 sys/arch/sun68k/stand/libsa/panic.c         |   4 +-
 sys/arch/sun68k/stand/libsa/promboot.c      |   8 +++++-
 sys/arch/sun68k/stand/libsa/promdev.c       |  18 +++++++-----
 sys/arch/sun68k/stand/libsa/putstr.c        |  40 +++++++++++++++++++++++++++++
 sys/arch/sun68k/stand/tapeboot/conf.c       |   4 ++-
 12 files changed, 97 insertions(+), 23 deletions(-)

diffs (295 lines):

diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/Makefile.inc
--- a/sys/arch/sun68k/stand/Makefile.inc        Wed May 15 02:36:11 2002 +0000
+++ b/sys/arch/sun68k/stand/Makefile.inc        Wed May 15 04:07:41 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.2 2002/02/09 09:36:02 lukem Exp $
+#      $NetBSD: Makefile.inc,v 1.3 2002/05/15 04:07:41 lukem Exp $
 
 # Must have S=/usr/src/sys (or equivalent)
 # But note: this is w.r.t. a subdirectory
@@ -29,7 +29,7 @@
        ${OBJCOPY} --output-target=binary ${SA_PROG} $@
 
 ${SA_PROG} : ${OBJS} ${DPADD} ${SRTLIB}
-       ${LD} -N -Ttext ${RELOC} -e start -o $@ \
+       ${LD} -N -Ttext ${RELOC} -e start ${SA_LDFLAGS} -o $@ \
          ${SRTOBJ} ${OBJS} ${LDADD} ${SRTLIB}
        @${SIZE} $@
 
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/bootxx/Makefile
--- a/sys/arch/sun68k/stand/bootxx/Makefile     Wed May 15 02:36:11 2002 +0000
+++ b/sys/arch/sun68k/stand/bootxx/Makefile     Wed May 15 04:07:41 2002 +0000
@@ -1,7 +1,7 @@
-#      $NetBSD: Makefile,v 1.4 2002/04/22 21:15:41 fredette Exp $
+#      $NetBSD: Makefile,v 1.5 2002/05/15 04:07:42 lukem Exp $
 
 SA_PROG= bootxx
-SRCS=   bootxx.c conf.c
+SRCS=   bootxx.c conf.c panic_putstr.c
 
 PROG=  ${SA_PROG}
 NOMAN= # defined
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/bootxx/bootxx.c
--- a/sys/arch/sun68k/stand/bootxx/bootxx.c     Wed May 15 02:36:11 2002 +0000
+++ b/sys/arch/sun68k/stand/bootxx/bootxx.c     Wed May 15 04:07:41 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootxx.c,v 1.6 2002/05/06 13:35:17 lukem Exp $ */
+/*     $NetBSD: bootxx.c,v 1.7 2002/05/15 04:07:42 lukem Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -84,7 +84,7 @@
 #endif
        f.f_flags = F_RAW;
        if (devopen(&f, 0, &addr)) {
-               printf("bootxx: devopen failed\n");
+               putstr("bootxx: devopen failed\n");
                return;
        }
 
@@ -126,11 +126,11 @@
                if ((fp->f_dev->dv_strategy)(fp->f_devdata, F_READ, blknum,
                                           bbinfo.bbi_block_size, buf, &n))
                {
-                       printf("bootxx: read failed\n");
+                       putstr("bootxx: read failed\n");
                        return -1;
                }
                if (n != bbinfo.bbi_block_size) {
-                       printf("bootxx: short read\n");
+                       putstr("bootxx: short read\n");
                        return -1;
                }
                bcopy(buf, addr, bbinfo.bbi_block_size);
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/bootxx/conf.c
--- a/sys/arch/sun68k/stand/bootxx/conf.c       Wed May 15 02:36:11 2002 +0000
+++ b/sys/arch/sun68k/stand/bootxx/conf.c       Wed May 15 04:07:41 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conf.c,v 1.1 2001/06/14 12:57:12 fredette Exp $        */
+/*     $NetBSD: conf.c,v 1.2 2002/05/15 04:07:42 lukem Exp $   */
 
 #include <stand.h>
 #include <dev_disk.h>
@@ -8,4 +8,6 @@
 };
 int    ndevs = 1;
 
+#ifdef DEBUG
 int debug;
+#endif /* DEBUG */
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/bootxx/panic_putstr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sun68k/stand/bootxx/panic_putstr.c       Wed May 15 04:07:41 2002 +0000
@@ -0,0 +1,18 @@
+/*     $NetBSD: panic_putstr.c,v 1.1 2002/05/15 04:07:42 lukem Exp $   */
+
+
+#include <machine/stdarg.h>
+#include <stand.h>
+#include "libsa.h"
+
+__dead void
+panic(const char *fmt, ...)
+{
+
+       putstr("panic: ");
+       putstr(fmt);
+       putchar('\n');
+
+       breakpoint();
+       exit();
+}
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/bootyy/conf.c
--- a/sys/arch/sun68k/stand/bootyy/conf.c       Wed May 15 02:36:11 2002 +0000
+++ b/sys/arch/sun68k/stand/bootyy/conf.c       Wed May 15 04:07:41 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conf.c,v 1.1 2001/06/14 12:57:13 fredette Exp $        */
+/*     $NetBSD: conf.c,v 1.2 2002/05/15 04:07:43 lukem Exp $   */
 
 #include <stand.h>
 #include <dev_disk.h>
@@ -8,4 +8,6 @@
 };
 int    ndevs = 1;
 
+#ifdef DEBUG
 int debug;
+#endif /* DEBUG */
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/libsa/Makefile
--- a/sys/arch/sun68k/stand/libsa/Makefile      Wed May 15 02:36:11 2002 +0000
+++ b/sys/arch/sun68k/stand/libsa/Makefile      Wed May 15 04:07:41 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.10 2002/04/22 21:13:34 fredette Exp $
+#      $NetBSD: Makefile,v 1.11 2002/05/15 04:07:43 lukem Exp $
 
 LIB=sa
 
@@ -41,7 +41,7 @@
 
 SRC_here= clock.c dev_disk.c devopen.c \
         gets.c idprom.c netif_sun.c panic.c \
-        promboot.c promcons.c promdev.c \
+        promboot.c promcons.c promdev.c putstr.c \
         sun2.c sun3.c sun3x.c vers.c xxboot.c
 
 SRCS= ${SRC_net} ${SRC_sa} ${SRC_kern} ${SRC_here}
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/libsa/panic.c
--- a/sys/arch/sun68k/stand/libsa/panic.c       Wed May 15 02:36:11 2002 +0000
+++ b/sys/arch/sun68k/stand/libsa/panic.c       Wed May 15 04:07:41 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: panic.c,v 1.1 2001/06/14 12:57:15 fredette Exp $       */
+/*     $NetBSD: panic.c,v 1.2 2002/05/15 04:07:43 lukem Exp $  */
 
 
 #include <machine/stdarg.h>
@@ -12,7 +12,7 @@
 
        va_start(ap, fmt);
        vprintf(fmt, ap);
-       printf("\n");
+       putchar('\n');
        va_end(ap);
        breakpoint();
        exit();
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/libsa/promboot.c
--- a/sys/arch/sun68k/stand/libsa/promboot.c    Wed May 15 02:36:11 2002 +0000
+++ b/sys/arch/sun68k/stand/libsa/promboot.c    Wed May 15 04:07:41 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: promboot.c,v 1.1 2001/06/14 12:57:15 fredette Exp $    */
+/*     $NetBSD: promboot.c,v 1.2 2002/05/15 04:07:43 lukem Exp $       */
 
 
 #include <sys/param.h>
@@ -9,7 +9,9 @@
 #include "stand.h"
 #include "libsa.h"
 
+#ifdef DEBUG
 int    debug = 0;
+#endif /* DEBUG */
 int    prom_boothow;
 char * prom_bootfile;
 char   prom_bootdev[32];
@@ -61,15 +63,19 @@
                                break;
                        case 'd':
                                prom_boothow |= RB_KDB;
+#ifdef DEBUG
                                debug++;
+#endif /* DEBUG */
                                break;
                        }
                }
        }
 
+#ifdef DEBUG
        if (debug) {
                printf("Debug level %d - enter c to continue...", debug);
                /* This will print "\nAbort at ...\n" */
                breakpoint();
        }
+#endif /* DEBUG */
 }
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/libsa/promdev.c
--- a/sys/arch/sun68k/stand/libsa/promdev.c     Wed May 15 02:36:11 2002 +0000
+++ b/sys/arch/sun68k/stand/libsa/promdev.c     Wed May 15 04:07:41 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: promdev.c,v 1.1 2001/06/14 12:57:15 fredette Exp $ */
+/*     $NetBSD: promdev.c,v 1.2 2002/05/15 04:07:43 lukem Exp $ */
 
 /*
  * Copyright (c) 1995 Gordon W. Ross
@@ -88,7 +88,7 @@
 
        if (dip->d_devbytes && dip->d_stdcount) {
                if (ctlr >= dip->d_stdcount) {
-                       printf("Invalid controller number\n");
+                       putstr("Invalid controller number\n");
                        return(ENXIO);
                }
                si->si_devaddr = dev_mapin(dip->d_devtype,
@@ -122,15 +122,19 @@
                printf("prom_iopen: calling prom open...\n");
 #endif
        error = (*ops->b_open)(si);
-       if (error != 0) {
-               printf("prom_iopen: \"%s\" error=%d\n",
-                          ops->b_desc, error);
-               return (ENXIO);
-       }
 #ifdef DEBUG_PROM
        if (debug)
                printf("prom_iopen: prom open returned %d\n", error);
 #endif
+       if (error != 0) {
+#if 0  /* XXX: printf is too big for bootxx */
+               printf("prom_iopen: \"%s\" error=%d\n",
+                          ops->b_desc, error);
+#else
+               putstr("prom_iopen: prom open failed");
+#endif
+               return (ENXIO);
+       }
 
        promdev_inuse++;
        return (0);
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/libsa/putstr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sun68k/stand/libsa/putstr.c      Wed May 15 04:07:41 2002 +0000
@@ -0,0 +1,40 @@
+/* $NetBSD: putstr.c,v 1.1 2002/05/15 04:07:43 lukem Exp $ */
+
+/*
+ * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Christopher G. Demetriou
+ *     for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <lib/libsa/stand.h>
+
+void
+putstr(const char *s)
+{
+       while (*s)
+               putchar(*s++);
+}
diff -r c4c6341efc85 -r c6c2dfa98b73 sys/arch/sun68k/stand/tapeboot/conf.c
--- a/sys/arch/sun68k/stand/tapeboot/conf.c     Wed May 15 02:36:11 2002 +0000
+++ b/sys/arch/sun68k/stand/tapeboot/conf.c     Wed May 15 04:07:41 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conf.c,v 1.1 2001/06/14 12:57:16 fredette Exp $        */
+/*     $NetBSD: conf.c,v 1.2 2002/05/15 04:07:44 lukem Exp $   */
 
 #include <stand.h>
 #include <rawfs.h>
@@ -17,4 +17,6 @@
 };
 int    ndevs = 1;
 
+#ifdef DEBUG
 int debug;
+#endif /* DEBUG */



Home | Main Index | Thread Index | Old Index