diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1997-09-17 10:46:26 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1997-09-17 10:46:26 +0000 |
commit | 6476cf829b28337c9b81bab966bbc4a4abe37982 (patch) | |
tree | 4c6323f69275a5aaa2d1e0a467f4f907e2f47314 /sys/arch/sparc/stand/bootxx | |
parent | 3e5a5259f8fb1b6393dd2cf83fb2c3eeda0ea959 (diff) |
Reorganizaed bootblocks. Builds like hp300 now.
Diffstat (limited to 'sys/arch/sparc/stand/bootxx')
-rw-r--r-- | sys/arch/sparc/stand/bootxx/Makefile | 36 | ||||
-rw-r--r-- | sys/arch/sparc/stand/bootxx/bootxx.c | 128 | ||||
-rw-r--r-- | sys/arch/sparc/stand/bootxx/closeall.c | 6 |
3 files changed, 157 insertions, 13 deletions
diff --git a/sys/arch/sparc/stand/bootxx/Makefile b/sys/arch/sparc/stand/bootxx/Makefile index 512405c14c6..3b07e62213c 100644 --- a/sys/arch/sparc/stand/bootxx/Makefile +++ b/sys/arch/sparc/stand/bootxx/Makefile @@ -1,24 +1,34 @@ -# $NetBSD: Makefile,v 1.5 1995/10/10 20:07:54 pk Exp $ +# $OpenBSD: Makefile,v 1.5 1997/09/17 10:46:16 downsj Exp $ +# $NetBSD: Makefile,v 1.2 1995/09/30 21:43:38 pk Exp $ + +.PATH: ${.CURDIR}/../common -R= .. -.PATH: ${.CURDIR}/${R} PROG= bootxx -SRCS= srt0.S bootxx.c promdev.c dvma.c -KOBJS= __main.o bzero.o urem.o udiv.o -NOMAN= 1 + +NOMAN= noman INSTALL_STRIP= -BINDIR= /usr/mdec -CFLAGS= -DBOOTXX -LIBS!= cd ${.CURDIR}/${R}; ${MAKE} sadep -KOBJDIR!= cd ${.CURDIR}/${R}; ${MAKE} kernlibdir -_KOBJS=${KOBJS:S,^,${KOBJDIR}/,g} +SRCS= srt0.S bootxx.c closeall.c dvma.c promdev.c -${PROG}:${OBJS} ${_KOBJS} ${LIBS} - ${LD} -N -T ${RELOC} -e start ${OBJS} ${_KOBJS} ${LIBS} +# pre-built bits of libkern +KOBJS= __main.o bzero.o urem.o udiv.o +_KOBJS=${KOBJS:S,^,${LIBKERNOBJDIR}/,g} +# pre-built bits of libsa +SOBJS= alloc.o exit.o printf.o memcpy.o memset.o +_SOBJS=${SOBJS:S,^,${LIBSAOBJDIR}/,g} + +CFLAGS= -O2 -I${.CURDIR}/../common -I${.CURDIR}/../../../../arch \ + -I${.CURDIR}/../../../.. -I${.CURDIR}/../../../../lib/libsa -DBOOTXX \ + ${DEFS} + +${PROG}: ${OBJS} + ${LD} -N -T ${RELOC} -e start ${OBJS} ${_SOBJS} ${_KOBJS} # convert to Sun magic @size a.out (echo -n 01 | tr 01 '\01\03'; tail +3c a.out) > ${.TARGET} @rm a.out +srt0.o: srt0.S + ${CC} ${CFLAGS} -D_LOCORE -c ${.IMPSRC} + .include <bsd.prog.mk> diff --git a/sys/arch/sparc/stand/bootxx/bootxx.c b/sys/arch/sparc/stand/bootxx/bootxx.c new file mode 100644 index 00000000000..bf7a4bfaaa2 --- /dev/null +++ b/sys/arch/sparc/stand/bootxx/bootxx.c @@ -0,0 +1,128 @@ +/* $OpenBSD: bootxx.c,v 1.1 1997/09/17 10:46:16 downsj Exp $ */ +/* $NetBSD: bootxx.c,v 1.2 1997/09/14 19:28:17 pk Exp $ */ + +/* + * Copyright (c) 1994 Paul Kranenburg + * 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 Paul Kranenburg. + * 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 <sys/param.h> +#include <sys/time.h> +#include <a.out.h> + +#include <lib/libsa/stand.h> + +#include <sparc/stand/common/promdev.h> + +int debug; +int netif_debug; + +/* + * Boot device is derived from ROM provided information. + */ +const char progname[] = "bootxx"; +struct open_file io; + +/* + * The contents of the block_* variables below is set by installboot(8) + * to hold the the filesystem data of the second-stage boot program + * (typically `/boot'): filesystem block size, # of filesystem blocks and + * the block numbers themselves. + */ +#define MAXBLOCKNUM 256 /* enough for a 2MB boot program (bs 8K) */ +int32_t block_size = 0; +int32_t block_count = MAXBLOCKNUM; +daddr_t block_table[MAXBLOCKNUM] = { 0 }; + + +void loadboot __P((struct open_file *, caddr_t)); + +int +main() +{ + char *dummy; + size_t n; + register void (*entry)__P((caddr_t)) = (void (*)__P((caddr_t)))LOADADDR; + + prom_init(); + io.f_flags = F_RAW; + if (devopen(&io, 0, &dummy)) { + panic("%s: can't open device", progname); + } + + (void)loadboot(&io, LOADADDR); + (io.f_dev->dv_close)(&io); + (*entry)(cputyp == CPU_SUN4 ? LOADADDR : (caddr_t)promvec); + _rtt(); +} + +void +loadboot(f, addr) + register struct open_file *f; + register char *addr; +{ + register int i; + register char *buf; + size_t n; + daddr_t blk; + + /* + * Allocate a buffer that we can map into DVMA space; only + * needed for sun4 architecture, but use it for all machines + * to keep code size down as much as possible. + */ + buf = alloc(block_size); + if (buf == NULL) + panic("%s: alloc failed", progname); + + for (i = 0; i < block_count; i++) { + if ((blk = block_table[i]) == 0) + panic("%s: block table corrupt", progname); + +#ifdef DEBUG + printf("%s: block # %d = %d\n", progname, i, blk); +#endif + if ((f->f_dev->dv_strategy)(f->f_devdata, F_READ, + blk, block_size, buf, &n)) { + panic("%s: read failure", progname); + } + bcopy(buf, addr, block_size); + if (n != block_size) + panic("%s: short read", progname); + if (i == 0) { + register int m = N_GETMAGIC(*(struct exec *)addr); + if (m == ZMAGIC || m == NMAGIC || m == OMAGIC) { + /* Move exec header out of the way */ + bcopy(addr, addr - sizeof(struct exec), n); + addr -= sizeof(struct exec); + } + } + addr += n; + } + +} diff --git a/sys/arch/sparc/stand/bootxx/closeall.c b/sys/arch/sparc/stand/bootxx/closeall.c new file mode 100644 index 00000000000..1d84dc0be92 --- /dev/null +++ b/sys/arch/sparc/stand/bootxx/closeall.c @@ -0,0 +1,6 @@ +/* $OpenBSD: closeall.c,v 1.1 1997/09/17 10:46:16 downsj Exp $ */ + +void +closeall() +{ +} |