Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mipsco/stand Initial commit of a 2 stage bootloader...
details: https://anonhg.NetBSD.org/src/rev/17d9ee844e7b
branches: trunk
changeset: 497067:17d9ee844e7b
user: wdk <wdk%NetBSD.org@localhost>
date: Mon Sep 18 11:40:46 2000 +0000
description:
Initial commit of a 2 stage bootloader for NetBSD/mipsco. Based on pmax
and alpha ports.
Uses PROM standalone I/O functions but due to the lack of a lseek function
it currently only works with version 5.40 of the firmware. A more portable
solution is being worked on.
installboot utility requires several changes in order to correctly install
the bootstrap code - there is a "volume directory" which contains a list
of filenames, start sectors and length. We need to add a "boot" entry of
the correct length starting at block 2. The boot file has to be ecoff
which means we waste another 0.5k
Normally the Mips filesystem has a ~500k partition for this purpose but it
should be possible to squeeze it all into the first 7k "BSD Style" (1k is
required for 2 different copies of the partition table)
Only the bootxx_ffs first stage bootstrap has been tested via bootp() which
loads the second stage off disk and then boots the kernel.
diffstat:
sys/arch/mipsco/stand/Makefile | 14 +
sys/arch/mipsco/stand/Makefile.booters | 128 ++++++++++++++
sys/arch/mipsco/stand/Makefile.inc | 11 +
sys/arch/mipsco/stand/boot/Makefile | 15 +
sys/arch/mipsco/stand/boot/version | 7 +
sys/arch/mipsco/stand/bootxx_cd9660/Makefile | 10 +
sys/arch/mipsco/stand/bootxx_ffs/Makefile | 9 +
sys/arch/mipsco/stand/common/boot.c | 231 +++++++++++++++++++++++++++
sys/arch/mipsco/stand/common/bootinfo.c | 82 +++++++++
sys/arch/mipsco/stand/common/bootinfo.h | 42 ++++
sys/arch/mipsco/stand/common/bootxx.c | 184 +++++++++++++++++++++
sys/arch/mipsco/stand/common/callvec.c | 64 +++++++
sys/arch/mipsco/stand/common/checksize.sh | 74 ++++++++
sys/arch/mipsco/stand/common/common.h | 53 ++++++
sys/arch/mipsco/stand/common/conf.c | 117 +++++++++++++
sys/arch/mipsco/stand/common/devopen.c | 134 +++++++++++++++
sys/arch/mipsco/stand/common/prom.S | 101 +++++++++++
sys/arch/mipsco/stand/common/saio.c | 227 ++++++++++++++++++++++++++
sys/arch/mipsco/stand/common/saio.h | 42 ++++
sys/arch/mipsco/stand/common/start.S | 67 +++++++
20 files changed, 1612 insertions(+), 0 deletions(-)
diffs (truncated from 1692 to 300 lines):
diff -r 11a85b15a4f4 -r 17d9ee844e7b sys/arch/mipsco/stand/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mipsco/stand/Makefile Mon Sep 18 11:40:46 2000 +0000
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2000/09/18 11:40:46 wdk Exp $
+
+# first stage bootloader
+SUBDIR+= bootxx_ffs
+SUBDIR+= bootxx_cd9660
+#SUBDIR+= bootxx_lfs
+
+# second stage bootloader
+SUBDIR+= boot
+
+# program to install bootstrap
+#SUBDIR+= installboot
+
+.include <bsd.subdir.mk>
diff -r 11a85b15a4f4 -r 17d9ee844e7b sys/arch/mipsco/stand/Makefile.booters
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mipsco/stand/Makefile.booters Mon Sep 18 11:40:46 2000 +0000
@@ -0,0 +1,128 @@
+# $NetBSD: Makefile.booters,v 1.1 2000/09/18 11:40:46 wdk Exp $
+
+S= ${.CURDIR}/../../../..
+MIPS= ${S}/arch/mips
+MIPSCO= ${S}/arch/mipsco
+
+.PATH: ${.CURDIR}/../common
+.BEGIN: machine mipsco mips
+
+realdepend realall: machine mipsco mips
+CLEANFILES+= machine mipsco mips
+
+machine mipsco::
+ -rm -f ${.TARGET}
+ ln -s ${MIPSCO}/include ${.TARGET}
+
+mips::
+ -rm -f ${.TARGET}
+ ln -s ${MIPS}/include ${.TARGET}
+
+BINMODE?= 444
+
+AFLAGS+= -D_LOCORE -D_KERNEL
+# -I${.CURDIR}/../.. done by Makefile.inc
+CPPFLAGS+= -nostdinc -D_STANDALONE -DNO_ABICALLS -D_NO_PROM_DEFINES
+CPPFLAGS+= -I${.OBJDIR} -I${S}
+# compiler flags for smallest code size
+CFLAGS= -Os -mmemcpy -mno-abicalls -G 128
+
+NETBSD_VERS!= sh ${S}/conf/osrelease.sh
+CPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
+
+PRIMARY_LOAD_ADDRESS?= 0x80600000
+SECONDARY_LOAD_ADDRESS?=0x80610000
+
+PRIMARY_LDSCRIPT?= ${MIPSCO}/conf/stand.ldscript
+SECONDARY_LDSCRIPT?= ${MIPS}/conf/stand.ldscript.be
+
+.if defined(PRIMARY_PROG)
+PROG= ${PRIMARY_PROG}
+SRCS = start.S bootxx.c callvec.c
+SRCS+= devopen.c conf.c saio.c
+SRCS+= prom.S
+
+LOAD_ADDRESS= ${PRIMARY_LOAD_ADDRESS}
+LDSCRIPT= ${PRIMARY_LDSCRIPT}
+# Pick a number, any number...
+PRIMARY_MAX_TOTAL!= expr 16 \* 1024
+
+CPPFLAGS+= -DPRIMARY_BOOTBLOCK \
+ -DPRIMARY_LOAD_ADDRESS="${PRIMARY_LOAD_ADDRESS}" \
+ -DNO_GETCHAR \
+ -DLIBSA_NO_FS_SYMLINK -DLIBSA_NO_FS_WRITE \
+ -DLIBSA_NO_FS_CLOSE \
+ -DLIBSA_NO_DEV_CLOSE \
+ -DLIBSA_SINGLE_DEVICE=saio \
+ -D"saioioctl(x,y,z)=EINVAL" -D"saioclose(f)=0" \
+ -DLIBSA_NO_TWIDDLE \
+ -DLIBSA_NO_FD_CHECKING \
+ -DLIBSA_NO_DISKLABEL_MSGS \
+ -DLIBSA_NO_RAW_ACCESS \
+ -DALLOC_FIRST_FIT \
+ -DLIBSA_USE_MEMCPY -DLIBSA_USE_MEMSET
+
+
+CHECKSIZE_CMD?= SIZE=${SIZE} sh ${.CURDIR}/../common/checksize.sh
+
+.elif defined(SECONDARY_PROG)
+PROG= ${SECONDARY_PROG}
+LOAD_ADDRESS= ${SECONDARY_LOAD_ADDRESS}
+LDSCRIPT= ${SECONDARY_LDSCRIPT}
+CPPFLAGS+= -DSECONDARY_BOOTBLOCK
+SRCS+= vers.c
+CLEANFILES+= vers.c
+.else
+
+.endif
+
+### find out what to use for libkern
+KERN_AS= library
+.include "${S}/lib/libkern/Makefile.inc"
+LIBKERN= ${KERNLIB}
+
+### find out what to use for libz
+.if defined(PRIMARY_PROG)
+LIBZ=
+.else
+Z_AS= library
+.include "${S}/lib/libz/Makefile.inc"
+LIBZ= ${ZLIB}
+.endif
+
+### find out what to use for libsa
+SA_AS= library
+.if defined(PRIMARY_PROG)
+SAMISCMAKEFLAGS+=SA_INCLUDE_NET=no
+.endif
+.if defined(SECONDARY_PROG)
+SAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes SA_USE_CREAD=yes
+# for now:
+SAMISCMAKEFLAGS+=SA_INCLUDE_NET=no
+.endif
+.include "${S}/lib/libsa/Makefile.inc"
+LIBSA= ${SALIB}
+
+LIBS= ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN}
+
+.PHONY: vers.c
+vers.c: ${.CURDIR}/version
+ sh ${S}/conf/newvers_stand.sh -N ${.CURDIR}/version "mipsco"
+
+${PROG}: machine mips mipsco ${LDSCRIPT} ${OBJS} ${LIBS}
+ ${LD} -Map ${PROG}.map -N -x -Ttext ${LOAD_ADDRESS} -T ${LDSCRIPT} \
+ -e start -o ${PROG} ${OBJS} ${LIBS}
+ @${SIZE} ${PROG}
+.if defined(CHECKSIZE_CMD)
+ @${CHECKSIZE_CMD} ${PROG} ${PRIMARY_MAX_LOAD} ${PRIMARY_MAX_TOTAL} || \
+ (rm -f ${PROG} ; false)
+.endif
+
+CLEANFILES+= ${PROG}.map
+
+cleandir distclean: cleanlibdir
+
+cleanlibdir:
+ rm -rf lib
+
+.include <bsd.prog.mk>
diff -r 11a85b15a4f4 -r 17d9ee844e7b sys/arch/mipsco/stand/Makefile.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mipsco/stand/Makefile.inc Mon Sep 18 11:40:46 2000 +0000
@@ -0,0 +1,11 @@
+# $NetBSD: Makefile.inc,v 1.1 2000/09/18 11:40:46 wdk Exp $
+
+.include <bsd.own.mk>
+
+BINDIR?= /usr/mdec
+
+WARNS?= 1
+MKMAN= no
+
+CPPFLAGS+= -I${.CURDIR}/../..
+LDSTATIC?= -static
diff -r 11a85b15a4f4 -r 17d9ee844e7b sys/arch/mipsco/stand/boot/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mipsco/stand/boot/Makefile Mon Sep 18 11:40:46 2000 +0000
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile,v 1.1 2000/09/18 11:40:47 wdk Exp $
+# @(#)Makefile 8.3 (Berkeley) 2/16/94
+
+SECONDARY_PROG= boot.mipsco
+
+SRCS= start.S boot.c
+SRCS+= bootinfo.c callvec.c conf.c devopen.c saio.c
+SRCS+= prom.S
+
+CPPFLAGS+= -DBOOT_TYPE_NAME='"Secondary"'
+
+afterinstall:
+ cp -p ${DESTDIR}${BINDIR}/${PROG} ${DESTDIR}/
+
+.include "../Makefile.booters"
diff -r 11a85b15a4f4 -r 17d9ee844e7b sys/arch/mipsco/stand/boot/version
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mipsco/stand/boot/version Mon Sep 18 11:40:46 2000 +0000
@@ -0,0 +1,7 @@
+$NetBSD: version,v 1.1 2000/09/18 11:40:47 wdk Exp $
+
+NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
+file is important - make sure the entries are appended on end, last item
+is taken as the current.
+
+1.0: Initial 2 stage bootloader for Mips Computer Corp. machines
diff -r 11a85b15a4f4 -r 17d9ee844e7b sys/arch/mipsco/stand/bootxx_cd9660/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mipsco/stand/bootxx_cd9660/Makefile Mon Sep 18 11:40:46 2000 +0000
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2000/09/18 11:40:47 wdk Exp $
+
+PRIMARY_PROG= bootxx_cd9660
+CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=cd9660 \
+ -DBOOTXX_FS_NAME='"ISO 9660"'
+
+# XXX the following could probably be increased
+PRIMARY_MAX_LOAD!= expr 8192 - 512
+
+.include "../Makefile.booters"
diff -r 11a85b15a4f4 -r 17d9ee844e7b sys/arch/mipsco/stand/bootxx_ffs/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mipsco/stand/bootxx_ffs/Makefile Mon Sep 18 11:40:46 2000 +0000
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1 2000/09/18 11:40:47 wdk Exp $
+
+PRIMARY_PROG= bootxx_ffs
+CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=ufs \
+ -DBOOTXX_FS_NAME='"FFS"'
+
+PRIMARY_MAX_LOAD!= expr 8192 - 1024
+
+.include "../Makefile.booters"
diff -r 11a85b15a4f4 -r 17d9ee844e7b sys/arch/mipsco/stand/common/boot.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mipsco/stand/common/boot.c Mon Sep 18 11:40:46 2000 +0000
@@ -0,0 +1,231 @@
+/* $NetBSD: boot.c,v 1.1 2000/09/18 11:40:48 wdk Exp $ */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jonathan Stone, Michael Hitch, Simon Burge and Wayne Knowles.
+ *
+ * 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 NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 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.
+ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * 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.
+ *
+ * @(#)boot.c 8.1 (Berkeley) 6/10/93
Home |
Main Index |
Thread Index |
Old Index