Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc/stand Checkpoint of elf boot stuff:



details:   https://anonhg.NetBSD.org/src/rev/fe8a19036b55
branches:  trunk
changeset: 472373:fe8a19036b55
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Apr 28 15:22:25 1999 +0000

description:
Checkpoint of elf boot stuff:
- Use loadfile for both boot and installboot
- Fix problems with linking in bootxx
- Make installboot work with both a.out and ELF bootxx
- *WILL NOT BOOT YET ELF KERNELS* (a.out kernels work) I am working on it.

diffstat:

 sys/arch/sparc/stand/Makefile.buildboot        |    3 +-
 sys/arch/sparc/stand/boot/Makefile             |   34 +++--
 sys/arch/sparc/stand/boot/boot.c               |  104 ++---------------
 sys/arch/sparc/stand/boot/version              |    3 +-
 sys/arch/sparc/stand/installboot/Makefile      |   15 ++-
 sys/arch/sparc/stand/installboot/installboot.c |  138 ++++++++++++------------
 6 files changed, 122 insertions(+), 175 deletions(-)

diffs (truncated from 470 to 300 lines):

diff -r 284bf3d4f3b7 -r fe8a19036b55 sys/arch/sparc/stand/Makefile.buildboot
--- a/sys/arch/sparc/stand/Makefile.buildboot   Wed Apr 28 13:35:40 1999 +0000
+++ b/sys/arch/sparc/stand/Makefile.buildboot   Wed Apr 28 15:22:25 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.buildboot,v 1.5 1999/02/15 19:31:34 pk Exp $
+#      $NetBSD: Makefile.buildboot,v 1.6 1999/04/28 15:22:25 christos Exp $
 
 S=     ${.CURDIR}/../../../..
 
@@ -37,6 +37,7 @@
 
 ### find out what to use for libsa
 SA_AS=         library
+SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA=         ${SALIB}
 
diff -r 284bf3d4f3b7 -r fe8a19036b55 sys/arch/sparc/stand/boot/Makefile
--- a/sys/arch/sparc/stand/boot/Makefile        Wed Apr 28 13:35:40 1999 +0000
+++ b/sys/arch/sparc/stand/boot/Makefile        Wed Apr 28 15:22:25 1999 +0000
@@ -1,9 +1,11 @@
-#      $NetBSD: Makefile,v 1.11 1999/03/05 11:13:39 pk Exp $
+#      $NetBSD: Makefile,v 1.12 1999/04/28 15:22:25 christos Exp $
 
+STRIPFLAG=
 PROG=          boot
 PROGSOURCE=    boot.c net.c netif_sun.c conf.c openfirm.c
+FILES=         boot.net
 NEWVERSWHAT=   "Secondary Boot"
-CLEANFILES+=   vers.c vers.o
+CLEANFILES+=   vers.c vers.o boot.net
 
 INCLUDE_LIBZ=  yes
 SAMISCMAKEFLAGS= SA_USE_CREAD=yes
@@ -11,23 +13,25 @@
 .include "../Makefile.buildboot"
 
 RELOC=         0x300000
-LINKFLAGS=     -N -Ttext ${RELOC} -e start
+
+.include <bsd.own.mk>
+
+LINKFLAGS=-N -Ttext ${RELOC} -e start
+
+all: ${FILES}
 
 ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
        sh ${.CURDIR}/../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
        ${COMPILE.c} vers.c
-       ${LD} -o ${.TARGET} ${LINKFLAGS} ${OBJS} \
+       ${LD} -o ${.TARGET}.tmp ${LINKFLAGS} ${OBJS} \
            vers.o ${LIBSA} ${LIBZ} ${LIBKERN}
-       @size ${.TARGET}
-
-afterinstall:
-       # conjure up a magic header that is accepted by all Sun PROMS;
-       # see installboot.c for details.
-       printf '\01\03\01\07\060\200\0\07' | \
-               dd of=${DESTDIR}/${BINDIR}/boot.net bs=32 conv=sync
-       dd if=${DESTDIR}/${BINDIR}/boot of=${DESTDIR}/${BINDIR}/boot.net \
-               bs=32 skip=1 seek=1
-       chmod ${BINMODE} ${DESTDIR}/${BINDIR}/boot.net
-       chown ${BINOWN}.${BINGRP} ${DESTDIR}/${BINDIR}/boot.net
+       @size ${.TARGET}.tmp
+       @objcopy -O binary ${.TARGET}.tmp ${.TARGET}
+       @rm -f ${.TARGET}.tmp
+ 
+# conjure up a magic header that is accepted by all Sun PROMS;
+# see installboot.c for details.
+${FILES}: ${PROG}
+       (printf '\01\03\01\07\060\200\0\07'; cat ${.ALLSRC} ) > ${.TARGET}
 
 .include <bsd.prog.mk>
diff -r 284bf3d4f3b7 -r fe8a19036b55 sys/arch/sparc/stand/boot/boot.c
--- a/sys/arch/sparc/stand/boot/boot.c  Wed Apr 28 13:35:40 1999 +0000
+++ b/sys/arch/sparc/stand/boot/boot.c  Wed Apr 28 15:22:25 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.4 1999/02/15 18:59:36 pk Exp $ */
+/*     $NetBSD: boot.c,v 1.5 1999/04/28 15:22:25 christos Exp $ */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -40,12 +40,12 @@
 #include <a.out.h>
 
 #include <lib/libsa/stand.h>
+#include <lib/libsa/loadfile.h>
 
 #include <machine/promlib.h>
 #include <sparc/stand/common/promdev.h>
 
 static int     bootoptions __P((char *));
-void           loadfile __P((int, caddr_t));
 #if 0
 static void    promsyms __P((int, struct exec *));
 #endif
@@ -117,6 +117,8 @@
        int     io, i;
        char    *kernel;
        int     how;
+       u_long  marks[MARK_MAX];
+       void    *arg;
 
        prom_init();
 
@@ -160,10 +162,11 @@
                        }
                }
 
-               if ((io = open(kernel, 0)) >= 0)
+               marks[MARK_START] = 0;
+               printf("Booting %s\n", kernel);
+               if ((io = loadfile(kernel, marks, LOAD_KERNEL)) != -1)
                        break;
-               printf("open: %s: %s", kernel, strerror(errno));
-
+                       
                /*
                 * if we have are not in askname mode, and we aren't using the
                 * prom bootfile, try the next one (if it exits).  otherwise,
@@ -179,95 +182,20 @@
                }
        }
 
+       marks[MARK_END] = (((u_long)marks[MARK_END] + sizeof(int) - 1)) &
+           (-sizeof(int));
        /*
-        * XXX
-        * make loadfile() return a value, so that if the load of the kernel
-        * fails, we can jump back and try another kernel in the list.
+        * XXX: Fix me properly (struct bootinfo)
         */
-       printf("Booting %s @ %p\n", kernel, PROM_LOADADDR);
-       loadfile(io, PROM_LOADADDR);
+       marks[MARK_END] |= 0xf0000000;
+       arg = (prom_version() == PROM_OLDMON) ? PROM_LOADADDR : romp;
+printf("entry = 0x%lx, arg = 0x%lx, end = 0x%lx\n", marks[MARK_ENTRY], (u_long)arg, marks[MARK_END]);
+       (*(entry_t)marks[MARK_ENTRY])(arg, 0, 0, 0, marks[MARK_END],
+           DDB_MAGIC1);
 
        _rtt();
 }
 
-void
-loadfile(io, addr)
-       int     io;
-       caddr_t addr;
-{
-       entry_t entry = (entry_t)PROM_LOADADDR;
-       void *arg;
-       struct exec x;
-       int i;
-
-       i = read(io, (char *)&x, sizeof(x));
-       if (i != sizeof(x) ||
-           N_BADMAG(x)) {
-               printf("Bad format\n");
-               return;
-       }
-       printf("%ld", x.a_text);
-       if (N_GETMAGIC(x) == ZMAGIC) {
-               entry = (entry_t)(addr+sizeof(struct exec));
-               addr += sizeof(struct exec);
-       }
-       if (read(io, (char *)addr, x.a_text) != x.a_text)
-               goto shread;
-       addr += x.a_text;
-       if (N_GETMAGIC(x) == ZMAGIC || N_GETMAGIC(x) == NMAGIC)
-               while ((int)addr & __LDPGSZ)
-                       *addr++ = 0;
-       printf("+%ld", x.a_data);
-       if (read(io, addr, x.a_data) != x.a_data)
-               goto shread;
-       addr += x.a_data;
-       printf("+%ld", x.a_bss);
-       for (i = 0; i < x.a_bss; i++)
-               *addr++ = 0;
-       if (x.a_syms != 0) {
-               bcopy(&x.a_syms, addr, sizeof(x.a_syms));
-               addr += sizeof(x.a_syms);
-               printf("+[%ld", x.a_syms);
-               if (read(io, addr, x.a_syms) != x.a_syms)
-                       goto shread;
-               addr += x.a_syms;
-
-               if (read(io, &strtablen, sizeof(int)) != sizeof(int))
-                       goto shread;
-
-               bcopy(&strtablen, addr, sizeof(int));
-               if ((i = strtablen) != 0) {
-                       i -= sizeof(int);
-                       addr += sizeof(int);
-                       if (read(io, addr, i) != i)
-                           goto shread;
-                       addr += i;
-               }
-               printf("+%d]", i);
-               esym = ((u_int)x.a_entry - (u_int)PROM_LOADADDR) +
-                       (((int)addr + sizeof(int) - 1) & ~(sizeof(int) - 1));
-#if 0
-               /*
-                * The FORTH word `loadsyms' is mentioned in the
-                * "Openboot command reference" book, but it seems it has
-                * not been implemented on at least one machine..
-                */
-               promsyms(io, &x);
-#endif
-       }
-       printf("=%p\n", addr);
-       close(io);
-
-       /* Note: args 2-4 not used due to conflicts with SunOS loaders */
-       arg = (prom_version() == PROM_OLDMON) ? PROM_LOADADDR : romp;
-       (*entry)(arg, 0, 0, 0, esym, DDB_MAGIC1);
-       return;
-
-shread:
-       printf("boot: short read\n");
-       return;
-}
-
 #if 0
 struct syms {
        u_int32_t       value;
diff -r 284bf3d4f3b7 -r fe8a19036b55 sys/arch/sparc/stand/boot/version
--- a/sys/arch/sparc/stand/boot/version Wed Apr 28 13:35:40 1999 +0000
+++ b/sys/arch/sparc/stand/boot/version Wed Apr 28 15:22:25 1999 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.9 1999/01/15 00:48:03 mrg Exp $
+$NetBSD: version,v 1.10 1999/04/28 15:22:25 christos Exp $
 
 # The newvers.sh looks for the line below.  We use this method
 # rather than $3 of the dollar-NetBSD-dollar line above so that
@@ -12,3 +12,4 @@
 1.6:   reorganization of boot program sources.
 1.7:   add libz, and re-reorganize sources into their correct subdirectories.
 1.8:   add support for automatically finding kernels other than /netbsd.
+1.9:   add ELF support
diff -r 284bf3d4f3b7 -r fe8a19036b55 sys/arch/sparc/stand/installboot/Makefile
--- a/sys/arch/sparc/stand/installboot/Makefile Wed Apr 28 13:35:40 1999 +0000
+++ b/sys/arch/sparc/stand/installboot/Makefile Wed Apr 28 15:22:25 1999 +0000
@@ -1,9 +1,18 @@
-#      $NetBSD: Makefile,v 1.8 1999/02/13 02:54:49 lukem Exp $
+#      $NetBSD: Makefile,v 1.9 1999/04/28 15:22:25 christos Exp $
 
 .include <bsd.own.mk>
 
-PROG=          installboot
-MKMAN=         no
+WARNS?=1
+PROG=  installboot
+SRCS=  installboot.c loadfile.c
+MKMAN= no
+CFLAGS+=-g
+
+LIBSA=${.CURDIR}/../../../../lib/libsa
+
+.PATH.c: ${LIBSA}
+
+CPPFLAGS+=-I${LIBSA}
 
 LDSTATIC?=     -static
 
diff -r 284bf3d4f3b7 -r fe8a19036b55 sys/arch/sparc/stand/installboot/installboot.c
--- a/sys/arch/sparc/stand/installboot/installboot.c    Wed Apr 28 13:35:40 1999 +0000
+++ b/sys/arch/sparc/stand/installboot/installboot.c    Wed Apr 28 15:22:25 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: installboot.c,v 1.3 1998/09/05 13:52:15 pk Exp $ */
+/*     $NetBSD: installboot.c,v 1.4 1999/04/28 15:22:25 christos Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -53,17 +53,30 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "loadfile.h"
+
 int    verbose, nowrite, hflag;
 char   *boot, *proto, *dev;
 
+#if 0
+#ifdef __ELF__
+#define SYMNAME(a)     a
+#else
+#define SYMNAME(a)     __CONCAT("_",a)
+#endif
+#else
+/* XXX: Hack in libc nlist works with both formats */
+#define SYMNAME(a)     __CONCAT("_",a)
+#endif
+
 struct nlist nl[] = {
 #define X_BLOCKTABLE   0
-       {"_block_table"},
+       { {SYMNAME("block_table")} },
 #define X_BLOCKCOUNT   1
-       {"_block_count"},
+       { {SYMNAME("block_count")} },
 #define X_BLOCKSIZE    2



Home | Main Index | Thread Index | Old Index