Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sbmips/stand first cut at NetBSD/sbmips bootstrap p...



details:   https://anonhg.NetBSD.org/src/rev/3fe2deb2672f
branches:  trunk
changeset: 539135:3fe2deb2672f
user:      cgd <cgd%NetBSD.org@localhost>
date:      Sat Nov 09 06:20:37 2002 +0000

description:
first cut at NetBSD/sbmips bootstrap programs, cloned from NetBSD/alpha's
and then modified to work with CFE as the firmware.

diffstat:

 sys/arch/sbmips/stand/Makefile               |    7 +
 sys/arch/sbmips/stand/Makefile.bootprogs     |  143 +++++++
 sys/arch/sbmips/stand/Makefile.bootxx        |   36 +
 sys/arch/sbmips/stand/Makefile.inc           |   11 +
 sys/arch/sbmips/stand/boot/Makefile          |   31 +
 sys/arch/sbmips/stand/boot/filesystem.c      |   54 ++
 sys/arch/sbmips/stand/boot/version           |    7 +
 sys/arch/sbmips/stand/bootxx_cd9660/Makefile |   13 +
 sys/arch/sbmips/stand/bootxx_ffs/Makefile    |   12 +
 sys/arch/sbmips/stand/bootxx_lfs/Makefile    |   12 +
 sys/arch/sbmips/stand/common/bbinfo.h        |   54 ++
 sys/arch/sbmips/stand/common/blkdev.c        |  192 +++++++++
 sys/arch/sbmips/stand/common/blkdev.h        |   10 +
 sys/arch/sbmips/stand/common/boot.c          |  172 ++++++++
 sys/arch/sbmips/stand/common/booted_dev.c    |   63 +++
 sys/arch/sbmips/stand/common/bootxx.c        |  131 ++++++
 sys/arch/sbmips/stand/common/cfe.c           |   68 +++
 sys/arch/sbmips/stand/common/cfe_api.c       |  535 +++++++++++++++++++++++++++
 sys/arch/sbmips/stand/common/cfe_api.h       |  209 ++++++++++
 sys/arch/sbmips/stand/common/cfe_api_int.h   |  169 ++++++++
 sys/arch/sbmips/stand/common/cfe_error.h     |  102 +++++
 sys/arch/sbmips/stand/common/cfe_ioctl.h     |   74 +++
 sys/arch/sbmips/stand/common/checksize.sh    |   75 +++
 sys/arch/sbmips/stand/common/common.h        |   72 +++
 sys/arch/sbmips/stand/common/panic_putstr.c  |   42 ++
 sys/arch/sbmips/stand/common/putstr.c        |   41 ++
 sys/arch/sbmips/stand/common/start.S         |  112 +++++
 sys/arch/sbmips/stand/netboot/Makefile       |   31 +
 sys/arch/sbmips/stand/netboot/conf.c         |   25 +
 sys/arch/sbmips/stand/netboot/dev_net.c      |  264 +++++++++++++
 sys/arch/sbmips/stand/netboot/devopen.c      |  164 ++++++++
 sys/arch/sbmips/stand/netboot/getsecs.c      |   57 ++
 sys/arch/sbmips/stand/netboot/if_cfe.c       |  162 ++++++++
 sys/arch/sbmips/stand/netboot/version        |    7 +
 34 files changed, 3157 insertions(+), 0 deletions(-)

diffs (truncated from 3293 to 300 lines):

diff -r 5e41a524d210 -r 3fe2deb2672f sys/arch/sbmips/stand/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sbmips/stand/Makefile    Sat Nov 09 06:20:37 2002 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: Makefile,v 1.1 2002/11/09 06:20:37 cgd Exp $
+
+SUBDIR=                boot bootxx_cd9660 bootxx_ffs bootxx_lfs netboot
+#SUBDIR+=      installboot
+
+
+.include <bsd.subdir.mk>
diff -r 5e41a524d210 -r 3fe2deb2672f sys/arch/sbmips/stand/Makefile.bootprogs
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sbmips/stand/Makefile.bootprogs  Sat Nov 09 06:20:37 2002 +0000
@@ -0,0 +1,143 @@
+# $NetBSD: Makefile.bootprogs,v 1.1 2002/11/09 06:20:37 cgd Exp $
+
+S=     ${.CURDIR}/../../../..
+
+.PATH: ${.CURDIR}/../common
+
+STRIPFLAG=
+BINMODE= 444
+
+STRIP?=        strip
+
+CHECKSIZE_CMD= SIZE=${SIZE} sh ${.CURDIR}/../common/checksize.sh
+
+.PHONY: machine-links
+beforedepend: machine-links
+# ${MACHINE} then ${MACHINE_ARCH}
+machine-links:
+       -rm -f machine && \
+           ln -s $S/arch/sbmips/include machine
+       -rm -f mips && \
+           ln -s $S/arch/mips/include mips
+CLEANFILES+=machine mips
+
+realall: machine-links ${PROG}
+
+AFLAGS+=       -DASSEMBLER -D_LOCORE
+# -I${.CURDIR}/../.. done by Makefile.inc
+CPPFLAGS+=     -nostdinc -I${.OBJDIR} -D_STANDALONE -I${S}
+CFLAGS=                -Os -g -ffreestanding -mno-abicalls -mno-half-pic -G 0
+
+NETBSD_VERS!=sh ${.CURDIR}/../../../../conf/osrelease.sh
+CPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
+
+CWARNFLAGS+=   -Wno-main 
+
+# if there is a 'version' file, add rule for vers.c and add it to SRCS
+# and CLEANFILES
+.if exists(version)
+.PHONY: vers.c
+vers.c: version
+       sh ${S}/conf/newvers_stand.sh -N ${.CURDIR}/version "sbmips"
+
+SRCS+= vers.c
+CLEANFILES+= vers.c
+.endif
+
+# 
+# Refer to CFE documentation for a description of these regions.
+# 
+
+REGION1_START=         0x20000000              # "Region 1 start"
+REGION1_SIZE!=         expr 256 \* 1024        # 256k
+
+# our memory lauout:
+
+#      'unified' boot loaders (e.g. netboot) can consume all of region
+#      1 for their text+data, or text+data+bss.
+
+UNIFIED_LOAD_ADDRESS=  ${REGION1_START}
+UNIFIED_MAX_LOAD!=     expr ${REGION1_SIZE}
+UNIFIED_MAX_TOTAL!=    expr ${REGION1_SIZE}
+
+#UNIFIED_HEAP_START=   right after secondary bss
+UNIFIED_HEAP_LIMIT=    (${REGION1_START} + ${REGION1_SIZE})
+
+#      two-stage boot loaders must share region 1.  The first stage
+#      loads into the lowest portion, and uses the higest portion
+#      for its heap.  The second stage loads in between the primary image
+#      and the heap, and can reuse the memory after it (i.e. the primary's
+#      heap) for its own heap.
+
+PRIMARY_LOAD_ADDRESS=  ${REGION1_START}
+#PRIMARY_MAX_LOAD=     booter dependent, no more than ${PRIMARY_MAX_TOTAL}
+PRIMARY_MAX_TOTAL!=    expr 16 \* 1024
+
+# XXX SECONDARY_LOAD_ADDRESS should be
+# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
+# XXX way to do that calculation and 'ld' wants a single number.
+SECONDARY_LOAD_ADDRESS=        0x20004000      # XXX
+SECONDARY_MAX_LOAD!=   expr 112 \* 1024
+SECONDARY_MAX_TOTAL!=  expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
+
+PRIMARY_HEAP_START=    (${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
+PRIMARY_HEAP_LIMIT=    (${REGION1_START} + ${REGION1_SIZE})
+
+#SECONDARY_HEAP_START= right after secondary bss
+SECONDARY_HEAP_LIMIT=  (${REGION1_START} + ${REGION1_SIZE})
+
+#      standalone programs are like kernels.  They load at
+#      0xfffffc0000300000 and can use the rest of memory.
+
+STANDPROG_LOAD_ADDRESS=        0xfffffc0000300000
+
+
+FILE_FORMAT_CPPFLAGS=  -DBOOT_ECOFF -DBOOT_ELF
+
+UNIFIED_CPPFLAGS=      -DUNIFIED_BOOTBLOCK \
+                       -DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
+                       ${FILE_FORMAT_CPPFLAGS}
+
+PRIMARY_CPPFLAGS=      -DPRIMARY_BOOTBLOCK \
+                       -DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
+                       -DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
+                       -DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
+                       -DHEAP_START="${PRIMARY_HEAP_START}"
+
+SECONDARY_CPPFLAGS=    -DSECONDARY_BOOTBLOCK \
+                       -DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
+                       ${FILE_FORMAT_CPPFLAGS}
+
+STANDPROG_CPPFLAGS=    -DSTANDALONE_PROGRAM
+
+.include <bsd.prog.mk>
+
+### 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
+Z_AS=          library
+.include "${S}/lib/libz/Makefile.inc"
+LIBZ=          ${ZLIB}
+
+### find out what to use for libsa
+SA_AS=         library
+SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
+.include "${S}/lib/libsa/Makefile.inc"
+LIBSA=         ${SALIB}
+
+
+/usr/lib/crt0.o:
+       true
+
+/usr/lib/crtbegin.o:
+       true
+
+/usr/lib/crtend.o:
+       true
+
+cleandir: cleandirlocal
+cleandirlocal:
+       rm -rf lib
diff -r 5e41a524d210 -r 3fe2deb2672f sys/arch/sbmips/stand/Makefile.bootxx
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sbmips/stand/Makefile.bootxx     Sat Nov 09 06:20:37 2002 +0000
@@ -0,0 +1,36 @@
+# $NetBSD: Makefile.bootxx,v 1.1 2002/11/09 06:20:37 cgd Exp $
+
+SRCS = start.S bootxx.c booted_dev.c blkdev.c cfe.c cfe_api.c \
+       putstr.c panic_putstr.c 
+
+BOOT_RELOC = ${PRIMARY_LOAD_ADDRESS}
+
+CPPFLAGS += ${PRIMARY_CPPFLAGS} \
+               -DLIBSA_FS_SINGLECOMPONENT -DLIBSA_NO_FS_WRITE \
+               -DLIBSA_NO_FS_CLOSE -DLIBSA_NO_FS_SEEK \
+               -DLIBSA_SINGLE_DEVICE=blkdev \
+                 -D"blkdevioctl(x,y,z)=EINVAL" -D"blkdevclose(f)=0" \
+               -DLIBSA_NO_TWIDDLE \
+               -DLIBSA_NO_FD_CHECKING \
+               -DLIBSA_NO_RAW_ACCESS \
+               -DLIBSA_NO_DISKLABEL_MSGS \
+               -DLIBSA_USE_MEMCPY
+
+CLEANFILES+= ${PROG}.sym
+
+${PROG}: ${PROG}.sym
+       @echo creating ${PROG} from ${PROG}.sym...
+       @${OBJCOPY} --output-target=binary -R .reginfo ${PROG}.sym ${PROG}
+       @chmod 644 ${PROG}
+       @ls -l ${PROG}
+       @${CHECKSIZE_CMD} ${PROG}.sym ${PROG} ${PRIMARY_MAX_LOAD} \
+           ${PRIMARY_MAX_TOTAL} || (rm -f ${PROG} ; false)
+
+SAMISCMAKEFLAGS= SA_INCLUDE_NET=no SA_USE_CREAD=no
+.include "../Makefile.bootprogs"
+
+${PROG}.sym: ${OBJS} ${LIBSA} ${LIBKERN}
+       ${LD} -Ttext ${BOOT_RELOC} -N -e start -o ${PROG}.sym \
+           ${OBJS} ${LIBSA} ${LIBKERN}
+       @chmod 644 ${PROG}.sym
+       @${SIZE} ${PROG}.sym
diff -r 5e41a524d210 -r 3fe2deb2672f sys/arch/sbmips/stand/Makefile.inc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sbmips/stand/Makefile.inc        Sat Nov 09 06:20:37 2002 +0000
@@ -0,0 +1,11 @@
+# $NetBSD: Makefile.inc,v 1.1 2002/11/09 06:20:37 cgd Exp $
+
+.include <bsd.own.mk>
+
+BINDIR?=               /usr/mdec
+WARNS?=                        1
+
+MKMAN=                 no
+
+CPPFLAGS+=             -I${.CURDIR}/../..
+LDSTATIC?=             -static
diff -r 5e41a524d210 -r 3fe2deb2672f sys/arch/sbmips/stand/boot/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sbmips/stand/boot/Makefile       Sat Nov 09 06:20:37 2002 +0000
@@ -0,0 +1,31 @@
+# $NetBSD: Makefile,v 1.1 2002/11/09 06:20:37 cgd Exp $
+
+PROG = boot
+
+SRCS = start.S boot.c blkdev.c cfe.c cfe_api.c 
+SRCS+= filesystem.c booted_dev.c
+
+BOOT_RELOC = ${SECONDARY_LOAD_ADDRESS}
+
+CPPFLAGS += ${SECONDARY_CPPFLAGS} \
+               -DBOOT_TYPE_NAME='"Secondary"' \
+               -DLIBSA_SINGLE_DEVICE=blkdev \
+                 -D"blkdevioctl(x,y,z)=EINVAL"
+
+CLEANFILES+= ${PROG}.sym
+
+${PROG}: ${PROG}.sym
+       @echo creating ${PROG} from ${PROG}.sym...
+       @${OBJCOPY} --output-target=binary -R .reginfo ${PROG}.sym ${PROG}
+       @chmod 644 ${PROG}
+       @ls -l ${PROG}
+       @${CHECKSIZE_CMD} ${PROG}.sym ${PROG} ${SECONDARY_MAX_LOAD} \
+           ${SECONDARY_MAX_TOTAL} || (rm -f ${PROG} ; false)
+
+SAMISCMAKEFLAGS= SA_INCLUDE_NET=no SA_USE_CREAD=yes
+.include "../Makefile.bootprogs"
+
+${PROG}.sym: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
+       ${LD} -Ttext ${BOOT_RELOC} -N -e start -o ${PROG}.sym \
+           ${OBJS} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN}
+       ${SIZE} ${PROG}.sym
diff -r 5e41a524d210 -r 3fe2deb2672f sys/arch/sbmips/stand/boot/filesystem.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sbmips/stand/boot/filesystem.c   Sat Nov 09 06:20:37 2002 +0000
@@ -0,0 +1,54 @@
+/* $NetBSD: filesystem.c,v 1.1 2002/11/09 06:20:37 cgd Exp $ */
+
+/*
+ * Copyright (c) 1993 Philip A. Nelson.
+ * 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 Philip A. Nelson.
+ * 4. The name of Philip A. Nelson may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``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 PHILIP NELSON 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.
+ *
+ *     filesystem.c
+ */
+
+#include <lib/libsa/stand.h>
+#include <lib/libsa/ufs.h>
+#include <lib/libsa/ustarfs.h>
+#include <lib/libsa/cd9660.h>
+#include <lib/libsa/lfs.h>
+ 
+struct fs_ops file_system[] = {
+    { ustarfs_open, ustarfs_close, ustarfs_read, ustarfs_write, ustarfs_seek,
+       ustarfs_stat }, /* this one can work from tape, so put it first */
+    { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek,
+       ufs_stat },
+    { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek,
+       cd9660_stat },



Home | Main Index | Thread Index | Old Index