Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/luna68k First cut at NetBSD/luna68k native bootloader.



details:   https://anonhg.NetBSD.org/src/rev/55460070ba90
branches:  trunk
changeset: 783716:55460070ba90
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Jan 05 17:44:24 2013 +0000

description:
First cut at NetBSD/luna68k native bootloader.

Based on 4.4BSD-Lite2/luna68k "Stinger" loader revision "Phase-31"
 http://svnweb.freebsd.org/csrg/sys/luna68k/stand/
and MI libsa glue stuff are taken from hp300 etc.

Tested on LUNA-I and old DK315C SCSI disk drive.

LUNA's monitor PROM can load only an a.out binary in 4.3BSD FFS partition
(i.e. created by "newfs -O 0") on disks with OMRON's UniOS disklabel,
but now we can load an ELF kernel in root partition via this bootloader.
(See luna68k/disksubr.c for details of UniOS label)

TODO:
 - LUNA-II support (check 68040 to adjust cpuspeed for DELAY())
 - secondary SCSI support for LUNA-II
 - netboot via le(4) (should be trivial)
 - support boot options on bootloader prompt
 - bootinfo (passing info about booted device and kernel symbols)
 - support "press return to boot now, any other key for boot menu" method
   like x86 bootloader (needs cnscan() like functions)
 - tapeboot (anyone wants it?)

diffstat:

 sys/arch/luna68k/include/loadfile_machdep.h   |    67 +
 sys/arch/luna68k/stand/boot/Makefile          |    86 +
 sys/arch/luna68k/stand/boot/autoconf.c        |   506 ++++
 sys/arch/luna68k/stand/boot/bmc.c             |   141 +
 sys/arch/luna68k/stand/boot/bmd.c             |   643 +++++
 sys/arch/luna68k/stand/boot/boot.c            |   212 +
 sys/arch/luna68k/stand/boot/boot.ldscript     |    48 +
 sys/arch/luna68k/stand/boot/conf.c            |    96 +
 sys/arch/luna68k/stand/boot/cons.c            |   144 +
 sys/arch/luna68k/stand/boot/device.h          |   153 +
 sys/arch/luna68k/stand/boot/devopen.c         |   177 +
 sys/arch/luna68k/stand/boot/disklabel.c       |   402 +++
 sys/arch/luna68k/stand/boot/font.c            |  2899 +++++++++++++++++++++++++
 sys/arch/luna68k/stand/boot/getline.c         |   119 +
 sys/arch/luna68k/stand/boot/init_main.c       |   200 +
 sys/arch/luna68k/stand/boot/ioconf.c          |    99 +
 sys/arch/luna68k/stand/boot/kbd.c             |   266 ++
 sys/arch/luna68k/stand/boot/kbdreg.h          |    91 +
 sys/arch/luna68k/stand/boot/locore.S          |   754 ++++++
 sys/arch/luna68k/stand/boot/machdep.c         |   198 +
 sys/arch/luna68k/stand/boot/omron_disklabel.h |    99 +
 sys/arch/luna68k/stand/boot/parse.c           |   165 +
 sys/arch/luna68k/stand/boot/preset.h          |    92 +
 sys/arch/luna68k/stand/boot/prf.c             |    78 +
 sys/arch/luna68k/stand/boot/rcvbuf.h          |   104 +
 sys/arch/luna68k/stand/boot/romcons.c         |   108 +
 sys/arch/luna68k/stand/boot/romvec.h          |   152 +
 sys/arch/luna68k/stand/boot/samachdep.h       |   210 +
 sys/arch/luna68k/stand/boot/sc.c              |   692 +++++
 sys/arch/luna68k/stand/boot/screen.c          |   132 +
 sys/arch/luna68k/stand/boot/scsi.c            |   243 ++
 sys/arch/luna68k/stand/boot/scsireg.h         |   462 +++
 sys/arch/luna68k/stand/boot/scsivar.h         |    99 +
 sys/arch/luna68k/stand/boot/sd.c              |   438 +++
 sys/arch/luna68k/stand/boot/sio.c             |   256 ++
 sys/arch/luna68k/stand/boot/sioreg.h          |   171 +
 sys/arch/luna68k/stand/boot/status.h          |    83 +
 sys/arch/luna68k/stand/boot/stinger.h         |    86 +
 sys/arch/luna68k/stand/boot/trap.c            |   115 +
 sys/arch/luna68k/stand/boot/ufs_disksubr.c    |   130 +
 sys/arch/luna68k/stand/boot/vectors.h         |    81 +
 sys/arch/luna68k/stand/boot/version           |     7 +
 42 files changed, 11304 insertions(+), 0 deletions(-)

diffs (truncated from 11472 to 300 lines):

diff -r 83565944d706 -r 55460070ba90 sys/arch/luna68k/include/loadfile_machdep.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/luna68k/include/loadfile_machdep.h       Sat Jan 05 17:44:24 2013 +0000
@@ -0,0 +1,67 @@
+/*     $NetBSD: loadfile_machdep.h,v 1.1 2013/01/05 17:44:24 tsutsui Exp $     */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#ifndef _LUNA68K_LOADFILE_MACHDEP_H_
+#define _LUNA68K_LOADFILE_MACHDEP_H_
+
+#define BOOT_AOUT
+#define BOOT_ELF32
+
+#define LOAD_KERNEL            LOAD_ALL
+#define COUNT_KERNEL           COUNT_ALL
+
+#define LOADADDR(a)            (((u_long)(a)) + offset)
+#define ALIGNENTRY(a)          ((u_long)(a))
+#define READ(f, b, c)          read((f), (void *)LOADADDR(b), (c))
+#define BCOPY(s, d, c)         memcpy((void *)LOADADDR(d), (void *)(s), (c))
+#define BZERO(d, c)            memset((void *)LOADADDR(d), 0, (c))
+
+#ifdef _STANDALONE
+
+#define        WARN(a)                 (void)(printf a, \
+                                   printf((errno ? ": %s\n" : "\n"), \
+                                   strerror(errno)))
+#define PROGRESS(a)            (void) printf a
+#define ALLOC(a)               alloc(a)
+#define DEALLOC(a, b)          dealloc(a, b)
+#define OKMAGIC(a)             ((a) == NMAGIC)
+
+#else
+
+#define WARN(a)                        warn a
+#define PROGRESS(a)            /* nothing */
+#define ALLOC(a)               malloc(a)
+#define DEALLOC(a, b)          free(a)
+#define OKMAGIC(a)             ((a) == NMAGIC || (a) == OMAGIC)
+
+#endif
+
+#endif /* !_LUNA68K_LOADFILE_MACHDEP_H_ */
diff -r 83565944d706 -r 55460070ba90 sys/arch/luna68k/stand/boot/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/luna68k/stand/boot/Makefile      Sat Jan 05 17:44:24 2013 +0000
@@ -0,0 +1,86 @@
+#      $NetBSD: Makefile,v 1.1 2013/01/05 17:44:24 tsutsui Exp $
+#      @(#)Makefile    8.2 (Berkeley) 8/15/93
+
+NOMAN= # defined
+
+.include <bsd.own.mk>
+.include <bsd.sys.mk>
+
+S= ${.CURDIR}/../../../..
+
+CPPFLAGS+=     -nostdinc -D_STANDALONE
+CPPFLAGS+=     -I${.CURDIR} -I${.OBJDIR} -I${S} -I${S}/arch
+
+CPPFLAGS+=     -DSUPPORT_DISK
+#CPPFLAGS+=    -DSUPPORT_TAPE
+#CPPFLAGS+=    -DSUPPORT_ETHERNET
+#CPPFLAGS+=    -DSUPPORT_DHCP -DSUPPORT_BOOTP
+#CPPFLAGS+=    -DBOOTP_DEBUG -DNETIF_DEBUG -DETHER_DEBUG -DNFS_DEBUG
+#CPPFLAGS+=    -DRPC_DEBUG -DRARP_DEBUG -DNET_DEBUG -DDEBUG -DPARANOID
+
+CFLAGS=                -Os -msoft-float
+CFLAGS+=       -ffreestanding
+CFLAGS+=       -Wall -Werror
+CFLAGS+=       -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
+CFLAGS+=       -Wno-pointer-sign
+
+LDSCRIPT=      ${.CURDIR}/boot.ldscript
+LINKFORMAT=    -static -N -T ${LDSCRIPT}
+
+SRCS=  locore.S
+SRCS+= init_main.c autoconf.c ioconf.c
+SRCS+= trap.c
+SRCS+= devopen.c
+SRCS+= conf.c
+SRCS+= machdep.c
+SRCS+= getline.c parse.c 
+SRCS+= boot.c
+SRCS+= cons.c prf.c
+SRCS+= romcons.c
+SRCS+= sio.c
+SRCS+= bmc.c bmd.c screen.c font.c kbd.c
+SRCS+= scsi.c sc.c sd.c
+#SRCS+=        st.c tape.c
+SRCS+= disklabel.c
+#SRCS+=        fsdump.c
+SRCS+= ufs_disksubr.c
+
+PROG=   boot
+
+SRCS+=          vers.c
+CLEANFILES+=    vers.c
+
+### find out what to use for libkern
+KERN_AS=       library
+.include "${S}/lib/libkern/Makefile.inc"
+
+### find out what to use for libz
+Z_AS=          library
+.include "${S}/lib/libz/Makefile.inc"
+
+### find out what to use for libsa
+SA_AS=         library
+SAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes SA_USE_CREAD=yes
+.include "${S}/lib/libsa/Makefile.inc"
+
+LIBS=  ${SALIB} ${ZLIB} ${KERNLIB}
+
+.PHONY: vers.c
+vers.c: ${.CURDIR}/version
+       ${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
+           ${.CURDIR}/version "${MACHINE}"
+
+${PROG}: ${LDSCRIPT} ${OBJS} ${LIBS}
+       ${LD} ${LINKFORMAT} -x -o ${PROG}.elf ${OBJS} ${LIBS}
+       ${ELF2AOUT} ${PROG}.elf ${PROG}.aout
+       mv ${PROG}.aout ${PROG}
+
+CLEANFILES+=   ${PROG}.map ${PROG}.elf ${PROG}.gz
+
+cleandir distclean: .WAIT cleanlibdir
+
+cleanlibdir:
+       -rm -rf lib
+
+.include <bsd.klinks.mk>
+.include <bsd.prog.mk>
diff -r 83565944d706 -r 55460070ba90 sys/arch/luna68k/stand/boot/autoconf.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/luna68k/stand/boot/autoconf.c    Sat Jan 05 17:44:24 2013 +0000
@@ -0,0 +1,506 @@
+/*     $NetBSD: autoconf.c,v 1.1 2013/01/05 17:44:24 tsutsui Exp $     */
+
+/*
+ * Copyright (c) 1992 OMRON Corporation.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * OMRON Corporation.
+ *
+ * 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 the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+ *
+ *     @(#)autoconf.c  8.1 (Berkeley) 6/10/93
+ */
+/*
+ * Copyright (c) 1992, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * OMRON Corporation.
+ *
+ * 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. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+ *
+ *     @(#)autoconf.c  8.1 (Berkeley) 6/10/93
+ */
+
+/* 
+ * autoconf.c -- Determine mass storage and memory configuration for a machine.
+ *          by A.Fujita, NOV-30-1991
+ *
+ * Modified by A.Fujita, FEB-04-1992
+ */
+
+
+#include <sys/param.h>
+#include <sys/dkstat.h>
+#include <lib/libkern/libkern.h>
+#include <luna68k/stand/boot/samachdep.h>
+#include <luna68k/stand/boot/device.h>
+
+int    dkn;                /* number of iostat dk numbers assigned so far */
+struct hp_hw sc_table[MAX_CTLR];
+
+#ifdef DEBUG
+int    acdebug = 1;
+#endif
+
+static int find_controller(struct hp_hw *);
+static int find_device(struct hp_hw *);
+static void find_slaves(struct hp_ctlr *);
+static int same_hw_device(struct hp_hw *, struct hp_device *);
+
+/*
+ * Determine mass storage and memory configuration for a machine.
+ */
+void
+configure(void)
+{
+       struct hp_hw *hw;
+       int found;
+
+       /*
+        * Look over each hardware device actually found and attempt
+        * to match it with an ioconf.c table entry.
+        */
+       for (hw = sc_table; hw->hw_type; hw++) {
+               if (hw->hw_type & CONTROLLER)
+                       found = find_controller(hw);
+               else
+                       found = find_device(hw);
+#ifdef DEBUG
+               if (!found) {
+                       printf("unconfigured %s ", hw->hw_name);
+                       printf("at 0x%x\n", hw->hw_addr);
+               }
+#endif
+       }
+
+}
+
+#define dr_type(d, s)  \
+       (strcmp((d)->d_name, (s)) == 0)
+
+#define same_hw_ctlr(hw, hc) \
+       ((hw)->hw_type == SCSI && dr_type((hc)->hp_driver, "sc"))
+
+int
+find_controller(struct hp_hw *hw)
+{



Home | Main Index | Thread Index | Old Index