diff options
author | Steve Murphree <smurph@cvs.openbsd.org> | 1998-12-15 06:09:52 +0000 |
---|---|---|
committer | Steve Murphree <smurph@cvs.openbsd.org> | 1998-12-15 06:09:52 +0000 |
commit | ee313f9cb07de5488da8b539c105ade3d6864c74 (patch) | |
tree | 2e3564ac9f28dc74a88d6659cfffae080f422dcd /sys/arch | |
parent | a3ede25132630f472db68bca912ef60793ae9073 (diff) |
Greatly improved tapeboot. From mvme68k.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/mvme88k/stand/bootst/Makefile | 20 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bootst/bcopy.c | 138 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bootst/boot.c | 73 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bootst/bootst.c | 428 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bootst/conf.c | 19 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bootst/dev_tape.c | 165 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bootst/dev_tape.h | 7 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bootst/rawfs.c | 178 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bootst/rawfs.h | 15 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bootst/version.c | 6 |
10 files changed, 469 insertions, 580 deletions
diff --git a/sys/arch/mvme88k/stand/bootst/Makefile b/sys/arch/mvme88k/stand/bootst/Makefile index ea323b62353..e704666e79e 100644 --- a/sys/arch/mvme88k/stand/bootst/Makefile +++ b/sys/arch/mvme88k/stand/bootst/Makefile @@ -1,27 +1,25 @@ # from: @(#)Makefile 8.1 (Berkeley) 6/10/93 -# $Id: Makefile,v 1.3 1998/08/22 09:25:07 smurph Exp $ +# $OpenBSD: Makefile,v 1.4 1998/12/15 06:09:51 smurph Exp $ -RELOC=0x3F0000 +RELOC=0xAF0000 +SIZE?= size S= ${.CURDIR}/../../../.. -DEFS= -DSTANDALONE -DCOMPAT_NOLABEL # -DROMPRF +DEFS= -DSTANDALONE -DCOMPAT_NOLABEL INCPATH=-I${.CURDIR} -I${.CURDIR}/../libsa -I${.CURDIR}/../libbug \ -I${.CURDIR}/../../include -I${S} -I${S}/lib/libsa CFLAGS= -O2 ${INCPATH} ${DEFS} ${COPTS} CLEANFILES+=stboot bootst bootst.bug -#.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH} -#.PATH: ${S}/lib/libsa - -.include "${S}/arch/mvme88k/stand/libsa/Makefile.inc" -.include "${S}/arch/mvme88k/stand/libbug/Makefile.inc" +.include "${S}/arch/mvme88k/stand/wrtvid/Makefile.inc" .include "${S}/arch/mvme88k/stand/bugcrt/Makefile.inc" +.include "${S}/arch/mvme88k/stand/libbug/Makefile.inc" +.include "${S}/arch/mvme88k/stand/libsa/Makefile.inc" .include "${S}/arch/mvme88k/stand/libz/Makefile.inc" -.include "${S}/arch/mvme88k/stand/wrtvid/Makefile.inc" -SRCS= bootst.c bcopy.c version.c +SRCS= boot.c conf.c dev_tape.c rawfs.c version.c -LIBS= ${LIBSA} ${LIBBUG} ${LIBZ} +LIBS= ${LIBSA} ${LIBBUG} ${LIBZ} libgcc.a OBJS= ${SRCS:N*.h:R:S/$/.o/g} diff --git a/sys/arch/mvme88k/stand/bootst/bcopy.c b/sys/arch/mvme88k/stand/bootst/bcopy.c deleted file mode 100644 index 38896e80127..00000000000 --- a/sys/arch/mvme88k/stand/bootst/bcopy.c +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: bcopy.c,v 1.1 1998/08/18 04:21:25 smurph Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include <string.h> - -/* - * sizeof(word) MUST BE A POWER OF TWO - * SO THAT wmask BELOW IS ALL ONES - */ -typedef long word; /* "word" used for optimal copy speed */ - -#define wsize sizeof(word) -#define wmask (wsize - 1) - -/* - * Copy a block of memory, handling overlap. - * This is the routine that actually implements - * (the portable versions of) bcopy, memcpy, and memmove. - */ -#ifdef MEMCOPY -void * -memcpy(dst0, src0, length) -#else -#ifdef MEMMOVE -void * -memmove(dst0, src0, length) -#else -void -bcopy(src0, dst0, length) -#endif -#endif - void *dst0; - const void *src0; - register size_t length; -{ - register char *dst = dst0; - register const char *src = src0; - register size_t t; - - if (length == 0 || dst == src) /* nothing to do */ - goto done; - - /* - * Macros: loop-t-times; and loop-t-times, t>0 - */ -#define TLOOP(s) if (t) TLOOP1(s) -#define TLOOP1(s) do { s; } while (--t) - - if ((unsigned long)dst < (unsigned long)src) { - /* - * Copy forward. - */ - t = (long)src; /* only need low bits */ - if ((t | (long)dst) & wmask) { - /* - * Try to align operands. This cannot be done - * unless the low bits match. - */ - if ((t ^ (long)dst) & wmask || length < wsize) - t = length; - else - t = wsize - (t & wmask); - length -= t; - TLOOP1(*dst++ = *src++); - } - /* - * Copy whole words, then mop up any trailing bytes. - */ - t = length / wsize; - TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); - t = length & wmask; - TLOOP(*dst++ = *src++); - } else { - /* - * Copy backwards. Otherwise essentially the same. - * Alignment works as before, except that it takes - * (t&wmask) bytes to align, not wsize-(t&wmask). - */ - src += length; - dst += length; - t = (long)src; - if ((t | (long)dst) & wmask) { - if ((t ^ (long)dst) & wmask || length <= wsize) - t = length; - else - t &= wmask; - length -= t; - TLOOP1(*--dst = *--src); - } - t = length / wsize; - TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); - t = length & wmask; - TLOOP(*--dst = *--src); - } -done: -#if defined(MEMCOPY) || defined(MEMMOVE) - return (dst0); -#else - return; -#endif -} diff --git a/sys/arch/mvme88k/stand/bootst/boot.c b/sys/arch/mvme88k/stand/bootst/boot.c new file mode 100644 index 00000000000..cfd82c463da --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/boot.c @@ -0,0 +1,73 @@ +/* $OpenBSD: boot.c,v 1.1 1998/12/15 06:09:51 smurph Exp $ */ +/*- + * Changes Copyright (c) 1998 steve Murphree, Jr. + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. 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 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 + */ + +#include <sys/param.h> +#include <sys/reboot.h> +#include <machine/prom.h> + +#include "stand.h" +#include "libsa.h" + +#define LOADADDR 0x10000 + +extern char *version; +extern int errno; + +int main() +{ + static char dnm[32] = "2"; + char line[80]; + char *cp, *filename; + int bflag = 0; + printf(">> OpenBSD MVME%x tapeboot [%s]\n", bugargs.cputyp, version); + + *bugargs.arg_end = 0; /* ensure */ + parse_args(&filename, &bflag); + filename = dnm; /* override */ + + if (bflag & RB_ASKNAME) { + printf("tapeboot: segment? [%s] ", dnm); + gets(line); + if (line[0]) + filename = line; + } + + exec_mvme(filename, bflag); + + printf("tapeboot: %s: %s\n", filename, strerror(errno)); + return(0); +} diff --git a/sys/arch/mvme88k/stand/bootst/bootst.c b/sys/arch/mvme88k/stand/bootst/bootst.c deleted file mode 100644 index 88da6c9cdc4..00000000000 --- a/sys/arch/mvme88k/stand/bootst/bootst.c +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Changes Copyright (c) 1998 steve Murphree, Jr. - * 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/types.h> -#include <sys/param.h> -#include <sys/reboot.h> -#include <sys/exec.h> -#include <sys/param.h> -#include <sys/reboot.h> -#include <machine/prom.h> - -#include "stand.h" -#include "libsa.h" - -#ifndef RB_NOSYM -#define RB_NOSYM 0x400 -#endif - -void parse_bugargs __P((struct mvmeprom_args *pbugargs)); -int load_kern(); -int read_tape_block __P((short ctrl, short dev, short *status, - void *addr, int *cnt, int blk_num, u_char *flags, int verbose)); - -struct kernel { - void *entry; - void *symtab; - void *esym; - int bflags; - int bdev; - char *kname; - void *smini; - void *emini; - u_int end_loaded; -} kernel; - -typedef(*kernel_entry) __P((struct mvmeprom_args *, struct kernel *)); - -struct mvmeprom_brdid2 { - u_long eye_catcher; - u_char rev; - u_char month; - u_char day; - u_char year; - u_short size; - u_short rsv1; - u_short model; - u_short suffix; - u_long options:24; - u_char family:4; - u_char cpu:4; - u_short ctrlun; - u_short devlun; - u_short devtype; - u_short devnum; - u_long bug; - u_char xx1[16]; - u_char xx2[4]; - u_char longname[12]; - u_char xx3[16]; - u_char speed[4]; - u_char xx4[12]; -}; -extern char *version; - -int -main() -{ - kernel_entry addr; - struct mvmeprom_brdid2 *brdid; - brdid = (struct mvmeprom_brdid2 *) mvmeprom_brdid(); - printf(">> OpenBSD stboot [%s]\n\n", version); - printf(" MVME%x%xs\n", brdid->model, brdid->suffix); - printf(" Booting from Controler %x, Drive %x\n", brdid->ctrlun, brdid->devlun); - printf(" Speed %s\n", brdid->speed); - if (bugargs.arg_start != bugargs.arg_end) - printf(" Args %s\n", bugargs.arg_start); - printf("\n"); - - parse_bugargs(&bugargs); - if (load_kern(bugargs) == 1) { - printf("unsuccessful in loading kernel\n"); - } else { - addr = kernel.entry; - if(kernel.esym == 0) kernel.esym = (int*)kernel.end_loaded; - printf("kernel loaded at %x\n", addr); - printf("kernel.entry %x\n", kernel.entry); - printf("kernel.symtab %x\n", kernel.symtab); - printf("kernel.esym %x\n", kernel.esym); - printf("kernel.bflags %x\n", kernel.bflags); - printf("kernel.bdev %x\n", kernel.bdev); - if (kernel.kname) - printf("kernel.kname <%s>\n", kernel.kname); - else - printf("kernel.kname <null>\n"); - printf("kernel.end_loaded %x\n", kernel.end_loaded); - - if (kernel.bflags & RB_MINIROOT) - loadmini(kernel.end_loaded, bugargs); - - printf("kernel.smini %x\n", kernel.smini); - printf("kernel.emini %x\n", kernel.emini); - printf("kernel.end_loaded %x\n", kernel.end_loaded); - if (kernel.bflags & RB_HALT) - mvmeprom_return(); - if (((u_long)addr &0xf) == 0x2) { - (addr)(&bugargs, &kernel); - } else { - /* is type fixing anything like price fixing? */ - typedef (* kernel_start) __P((int, int, void *,void *, void *)); - kernel_start addr1; - addr1 = (void *)addr; - (addr1)(kernel.bflags, bugargs.ctrl_addr, kernel.esym, kernel.smini, kernel.emini); - } - } - return (0); -} - -#define MVMEPROM_SCALE (512/MVMEPROM_BLOCK_SIZE) - -int -read_tape_block(ctrl, dev, status, addr, cnt, blk_num, flags, verbose) - short ctrl; - short dev; - short *status; - void *addr; - int *cnt; - int blk_num; - u_char *flags; - int verbose; -{ - struct mvmeprom_dskio dio; - int ret; - - dio.ctrl_lun = ctrl; - dio.dev_lun = dev; - dio.status = *status; - dio.pbuffer = addr; - dio.blk_num = blk_num; - dio.blk_cnt = *cnt / (512 / MVMEPROM_SCALE); - dio.flag = *flags; - dio.addr_mod = 0; - - if (verbose) - printf("saddr %x eaddr %x ", dio.pbuffer, - (int) dio.pbuffer + (dio.blk_cnt * MVMEPROM_BLOCK_SIZE)); - ret = mvmeprom_diskrd(&dio); - - *status = dio.status; - *cnt = (dio.blk_cnt / MVMEPROM_SCALE) * 512; - if (verbose) { - printf("status %x ret %d ", *status, ret); - printf("flags %x blocks read %x cnt %x\n", - *flags, dio.blk_cnt, *cnt); - } - return (ret); -} - -#ifdef DEBUG -int verbose = 1; -#else -int verbose = 0; -#endif - -int -load_kern(pbugargs) - struct mvmeprom_args *pbugargs; -{ - int ret; - char *addr; - u_char flags; - short status = 0; - int blk_num; - struct exec *pexec; - int len2; - int magic; - int *esym; - int *symtab; - int cnt, len, endsym; - char buf[512]; - int mid = 0; - - blk_num = 2; - /*flags = IGNORE_FILENUM;*/ - flags = 0; - cnt = 512; - -/* printf("ctrl %x dev %x\n",pbugargs->ctrl_lun, pbugargs->dev_lun);*/ - - ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, - buf, &cnt, blk_num, &flags, verbose); - - if (ret != 0 && status != 0x300) { - printf("unable to load kernel 1 status %x\n", status); - return (1); - } - pexec = (struct exec *) buf; - - mid = N_GETMID(*pexec); - if ( mid != MID_M88K ) { - printf("invalid mid %d on kernel\n", mid); - return (1); - } - - magic = N_GETMAGIC(*pexec); - switch (magic) { - case ZMAGIC: - break; - case NMAGIC: - printf("NMAGIC not yet supported"); - case OMAGIC: - printf("OMAGIC file\n"); - case QMAGIC: - printf("QMAGIC file\n"); - default: - printf("Unknown or unsupported magic type <%x>\n", magic); - return (1); - } - if (magic == ZMAGIC) { - status = 0; - addr = (char *) (pexec->a_entry & ~0x0FFF); - - if ((int) pexec->a_entry != (int) addr + 0x22) { - printf("warning kernel start address not %x, %x\n", - (int) addr + 0x22, pexec->a_entry); - printf("kernel loaded at %x\n", addr); - } - bcopy(&buf, addr, 512); - /* 2nd block of exe */ - addr += 512; - - printf("text 0x%x data 0x%x bss 0x%x\n", - pexec->a_text, pexec->a_data, pexec->a_bss); - - len = (pexec->a_text - 512); /* XXX */ - len += (pexec->a_data); - - printf("loading [ %x + %x ", pexec->a_text, pexec->a_data); - - cnt = len; - flags = IGNORE_FILENUM; - ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, - &status, addr, &cnt, blk_num, &flags, verbose); - if (ret != 0 || cnt != len) { - printf("\nunable to load kernel 2 status %x\n", status); - return 1; - } - addr += len; - - /* Skip over text and data and zero bss. */ - len = pexec->a_bss; - printf("+ %x", len); -#ifdef DEBUG - printf("bss %x - %x\n", addr, addr + pexec->a_bss); -#endif - bzero(addr, pexec->a_bss); - addr += len; - - if (pexec->a_syms != 0 && !(kernel.bflags & RB_NOSYM)) { - printf(" + [ %x", pexec->a_syms); - addr += 4; /* skip over _end symbol */ - symtab = (void *) pexec->a_syms; - len = pexec->a_syms; - cnt = ((len + (512 - 1)) / 512) * 512; - flags = IGNORE_FILENUM; - ret = read_tape_block(pbugargs->ctrl_lun, - pbugargs->dev_lun, &status, addr, - &cnt, blk_num, &flags, verbose); - if (ret != 0 || cnt != ((len + (512 - 1)) / 512) * 512) { - printf("\nunable to load kernel 3\n"); - return 1; - } - /* this value should have already been loaded XXX */ - esym = (void *) ((u_int) addr + pexec->a_syms); - if ((int) addr + cnt <= (int) esym) { - printf("\nmissed loading count of symbols\n"); - return 1; - } - addr += cnt; - len = *esym; -#if 0 - printf("start load %x end load %x %x\n", addr, - len, addr + len); - printf("esym %x *esym %x\n", esym, len); -#endif - /* dont load tail of already loaded */ - len -= (u_int) addr - (u_int) esym; - - if (len > 0) { - printf(" + %x", *esym); - esym = (int*) (addr + len); - cnt = ((len + (512 - 1)) / 512) * 512; - flags = IGNORE_FILENUM; - ret = read_tape_block(pbugargs->ctrl_lun, - pbugargs->dev_lun, &status, addr, - &cnt, blk_num, &flags, verbose); - if (ret != 0 || cnt != ((len + (512-1)) / 512)*512) { - printf("\nunable to load kernel 4\n"); - return (1); - } - addr += len; - printf(" ]"); - } else { - printf("+ %x ]", *esym); - } - esym = (int*)addr; - - kernel.symtab = symtab; - kernel.esym = esym; - } else { - kernel.symtab = 0; - kernel.esym = 0; - } - printf(" removing pad ["); - - kernel.end_loaded = (int) addr; - flags = IGNORE_FILENUM | END_OF_FILE; - cnt = 8192; - ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, - &status, addr, &cnt, blk_num, &flags, verbose); - if (ret != 0) { - printf("\nunable to load kernel 5\n"); - return (1); - } - printf(" %d ]", cnt); - - printf("]\n"); - } - kernel.entry = (void *) pexec->a_entry; - return (0); -} - -int -loadmini(addr, pbugargs) - u_int addr; - struct mvmeprom_args *pbugargs; -{ - int cnt, ret, blk_num = 3; - short status = 0; - u_char flags; - - /* align addr to some boundary */ -#define ALIGN_F 0x4 - addr = (u_int) ((((int) addr + ALIGN_F - 1) / ALIGN_F) * ALIGN_F); -#undef ALIGN_F - flags = END_OF_FILE; - cnt = 6144 * 512; /* some abserdly large value. (3meg) */ - printf("loading miniroot[ "); - ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, - &status, (void *) addr, &cnt, blk_num, &flags, verbose); - if (ret != 0) { - printf("\nunable to load miniroot\n"); - return (1); - } - kernel.smini = (void *)addr; - printf("%d ]\n", cnt); - kernel.emini = (void *) ((u_int) addr + cnt); - kernel.end_loaded = (u_int) kernel.emini; - return (0); -} - -void -parse_bugargs(pargs) - struct mvmeprom_args *pargs; -{ - char *ptr = pargs->arg_start; - char c, *name = "bsd"; - int howto = 0; - - if (pargs->arg_start != pargs->arg_end) { - while (c = *ptr) { - while (c == ' ') - c = *++ptr; - if (!c) - return; - if (c != '-') { - name = ptr; - while ((c = *++ptr) && c != ' '); - if (c) - *ptr++ = 0; - continue; - } - while ((c = *++ptr) && c != ' ') { - if (c == 'a') - howto |= RB_ASKNAME; - else if (c == 'b') - howto |= RB_HALT; - else if (c == 'y') - howto |= RB_NOSYM; - else if (c == 'd') - howto |= RB_KDB; - else if (c == 'm') - howto |= RB_MINIROOT; - else if (c == 'r') - howto |= RB_DFLTROOT; - else if (c == 's') - howto |= RB_SINGLE; - } - } - } - kernel.bflags = howto; - kernel.kname = name; -} diff --git a/sys/arch/mvme88k/stand/bootst/conf.c b/sys/arch/mvme88k/stand/bootst/conf.c new file mode 100644 index 00000000000..3fa22dd788e --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/conf.c @@ -0,0 +1,19 @@ +/* $OpenBSD: conf.c,v 1.1 1998/12/15 06:09:51 smurph Exp $ */ + +#include <stand.h> +#include <rawfs.h> +#include <dev_tape.h> + +struct fs_ops file_system[] = { + { + rawfs_open, rawfs_close, rawfs_read, + rawfs_write, rawfs_seek, rawfs_stat, + }, +}; +int nfsys = sizeof(file_system) / sizeof(file_system[0]); + +struct devsw devsw[] = { + { "tape", tape_strategy, tape_open, tape_close, tape_ioctl }, +}; +int ndevs = sizeof(devsw) / sizeof(devsw[0]); + diff --git a/sys/arch/mvme88k/stand/bootst/dev_tape.c b/sys/arch/mvme88k/stand/bootst/dev_tape.c new file mode 100644 index 00000000000..1362a3b1796 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/dev_tape.c @@ -0,0 +1,165 @@ +/* $OpenBSD: dev_tape.c,v 1.1 1998/12/15 06:09:51 smurph Exp $ */ + +/* + * Copyright (c) 1993 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. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library UFS file-system code, and + * possibly for direct access (i.e. boot from tape). + */ + +#include <sys/types.h> +#include <machine/prom.h> + +#include "stand.h" +#include "libsa.h" + + + +struct mvmeprom_dskio tape_ioreq; + +/* + * This is a special version of devopen() for tape boot. + * In this version, the file name is a numeric string of + * one digit, which is passed to the device open so it + * can open the appropriate tape segment. + */ +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; /* normally "1" */ + char **file; +{ + struct devsw *dp; + int errorno; + + *file = (char*)fname; + dp = &devsw[0]; + f->f_dev = dp; + + /* The following will call tape_open() */ + errorno = dp->dv_open(f, fname); + return (errorno); +} + +int +tape_open(f, fname) + struct open_file *f; + char *fname; /* partition number, i.e. "1" */ +{ + int error = 0; + int part; + struct mvmeprom_dskio *ti; + + /* + * Set the tape segment number to the one indicated + * by the single digit fname passed in above. + */ + if ((fname[0] < '0') && (fname[0] > '9')) { + return ENOENT; + } + part = fname[0] - '0'; + fname = NULL; + + /* + * Setup our part of the saioreq. + * (determines what gets opened) + */ + ti = &tape_ioreq; + bzero((caddr_t)ti, sizeof(*ti)); + + ti->ctrl_lun = bugargs.ctrl_lun; + ti->dev_lun = bugargs.dev_lun; + ti->status = 0; + ti->pbuffer = NULL; + ti->blk_num = part; + ti->blk_cnt = 0; + ti->flag = 0; + ti->addr_mod = 0; + + f->f_devdata = ti; + + return (0); +} + +int +tape_close(f) + struct open_file *f; +{ + struct mvmeprom_dskio *ti; + + + ti = f->f_devdata; + f->f_devdata = NULL; + return 0; +} + +#define MVMEPROM_SCALE (512/MVMEPROM_BLOCK_SIZE) + +int +tape_strategy(devdata, flag, dblk, size, buf, rsize) + void *devdata; + int flag; + daddr_t dblk; + u_int size; + char *buf; + u_int *rsize; +{ + struct mvmeprom_dskio *ti; + int ret; + + ti = devdata; + + if (flag != F_READ) + return(EROFS); + + ti->status = 0; + ti->pbuffer = buf; + /* don't change block #, set in open */ + ti->blk_cnt = size / (512 / MVMEPROM_SCALE); + + ret = mvmeprom_diskrd(ti); + + if (ret != 0) + return (EIO); + + *rsize = (ti->blk_cnt / MVMEPROM_SCALE) * 512; + ti->flag |= IGNORE_FILENUM; /* ignore next time */ + + return (0); +} + +int +tape_ioctl() +{ + return EIO; +} + diff --git a/sys/arch/mvme88k/stand/bootst/dev_tape.h b/sys/arch/mvme88k/stand/bootst/dev_tape.h new file mode 100644 index 00000000000..b706b16fd57 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/dev_tape.h @@ -0,0 +1,7 @@ +/* $OpenBSD: dev_tape.h,v 1.1 1998/12/15 06:09:51 smurph Exp $ */ + +int tape_open __P((struct open_file *, ...)); +int tape_close __P((struct open_file *)); +int tape_strategy __P((void *, int, daddr_t, size_t, void *, size_t *)); +int tape_ioctl(); + diff --git a/sys/arch/mvme88k/stand/bootst/rawfs.c b/sys/arch/mvme88k/stand/bootst/rawfs.c new file mode 100644 index 00000000000..33587f46ba8 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/rawfs.c @@ -0,0 +1,178 @@ +/* $OpenBSD: rawfs.c,v 1.1 1998/12/15 06:09:51 smurph Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon W. Ross + * + * 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. + */ + +/* + * Raw file system - for stream devices like tapes. + * No random access, only sequential read allowed. + * This exists only to allow upper level code to be + * shielded from the fact that the device must be + * read only with whole block position and size. + */ + +#include <sys/param.h> +#include <stand.h> +#include <rawfs.h> + +#define RAWFS_BSIZE 512 + +/* + * In-core open file. + */ +struct cfile { + daddr_t fs_nextblk; /* block number to read next */ + int fs_len; /* amount left in f_buf */ + char * fs_ptr; /* read pointer into f_buf */ + char fs_buf[RAWFS_BSIZE]; +}; + +static int +rawfs_get_block __P((struct open_file *)); + +int rawfs_open(path, f) + char *path; + struct open_file *f; +{ + struct cfile *fs; + + /* + * The actual PROM driver has already been opened. + * Just allocate the I/O buffer, etc. + */ + fs = alloc(sizeof(struct cfile)); + fs->fs_nextblk = 0; + fs->fs_len = 0; + fs->fs_ptr = fs->fs_buf; + + f->f_fsdata = fs; + return (0); +} + +int rawfs_close(f) + struct open_file *f; +{ + struct cfile *fs; + + fs = (struct cfile *) f->f_fsdata; + f->f_fsdata = (void *)0; + + if (fs != (struct cfile *)0) + free(fs, sizeof(*fs)); + + return (0); +} + +int rawfs_read(f, start, size, resid) + struct open_file *f; + void *start; + u_int size; + u_int *resid; +{ + struct cfile *fs = (struct cfile *)f->f_fsdata; + char *addr = start; + int error = 0; + size_t csize; + + while (size != 0) { + + if (fs->fs_len == 0) + if ((error = rawfs_get_block(f)) != 0) + break; + + if (fs->fs_len <= 0) + break; /* EOF */ + + csize = size; + if (csize > fs->fs_len) + csize = fs->fs_len; + + bcopy(fs->fs_ptr, addr, csize); + fs->fs_ptr += csize; + fs->fs_len -= csize; + addr += csize; + size -= csize; + } + if (resid) + *resid = size; + return (error); +} + +int rawfs_write(f, start, size, resid) + struct open_file *f; + void *start; + size_t size; + size_t *resid; /* out */ +{ + return (EROFS); +} + +off_t rawfs_seek(f, offset, where) + struct open_file *f; + off_t offset; + int where; +{ + return (EFTYPE); +} + +int rawfs_stat(f, sb) + struct open_file *f; + struct stat *sb; +{ + return (EFTYPE); +} + + +/* + * Read a block from the underlying stream device + * (In our case, a tape drive.) + */ +static int +rawfs_get_block(f) + struct open_file *f; +{ + struct cfile *fs; + int error, len; + + fs = (struct cfile *)f->f_fsdata; + fs->fs_ptr = fs->fs_buf; + + twiddle(); + error = f->f_dev->dv_strategy(f->f_devdata, F_READ, + fs->fs_nextblk, RAWFS_BSIZE, fs->fs_buf, &len); + + if (!error) { + fs->fs_len = len; + fs->fs_nextblk += (RAWFS_BSIZE / DEV_BSIZE); + } + + return (error); +} + diff --git a/sys/arch/mvme88k/stand/bootst/rawfs.h b/sys/arch/mvme88k/stand/bootst/rawfs.h new file mode 100644 index 00000000000..31c4ea0604d --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/rawfs.h @@ -0,0 +1,15 @@ +/* $OpenBSD: rawfs.h,v 1.1 1998/12/15 06:09:51 smurph Exp $ */ + +/* + * Raw file system - for stream devices like tapes. + * No random access, only sequential read allowed. + */ + +int rawfs_open __P((char *path, struct open_file *f)); +int rawfs_close __P((struct open_file *f)); +int rawfs_read __P((struct open_file *f, void *buf, + u_int size, u_int *resid)); +int rawfs_write __P((struct open_file *f, void *buf, + u_int size, u_int *resid)); +off_t rawfs_seek __P((struct open_file *f, off_t offset, int where)); +int rawfs_stat __P((struct open_file *f, struct stat *sb)); diff --git a/sys/arch/mvme88k/stand/bootst/version.c b/sys/arch/mvme88k/stand/bootst/version.c index 835b4d8702a..c0e43c3a4d3 100644 --- a/sys/arch/mvme88k/stand/bootst/version.c +++ b/sys/arch/mvme88k/stand/bootst/version.c @@ -1,8 +1,8 @@ -/* $OpenBSD: version.c,v 1.1 1998/08/18 04:21:27 smurph Exp $ */ +/* $OpenBSD: version.c,v 1.2 1998/12/15 06:09:51 smurph Exp $ */ /* * make a random change to this file when you want the bootblock - * revision to increase. like change this q to an x, or something. + * revision to increase. like change this x to an q, or something. */ -char *version = "$Revision: 1.1 $"; +char *version = "$Revision: 1.2 $"; |