diff --git a/sys/arch/hp300/stand/Makefile b/sys/arch/hp300/stand/Makefile index 1e037c3dbabb..fb4d532f0aca 100644 --- a/sys/arch/hp300/stand/Makefile +++ b/sys/arch/hp300/stand/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.19 1996/01/15 01:41:37 thorpej Exp $ +# $NetBSD: Makefile,v 1.20 1996/06/26 17:44:21 thorpej Exp $ # @(#)Makefile 8.1 (Berkeley) 6/10/93 @@ -39,7 +39,7 @@ LIBSA= ${SA_LIB} LIBS= ${OBJS} libdrive.a ${LIBSA} ${LIBKERN} -BOOTS= pboot netboot sys_inst dboot dcopy tboot tcopy cat #ls +BOOTS= uboot inst ALL= ${BOOTS} mkboot installboot all: ${ALL} @@ -62,76 +62,21 @@ ite.o ite_subr.o ite_dv.o ite_gb.o ite_hy.o ite_rb.o ite_tc.o: Makefile srt0.o: ${.CURDIR}/srt0.s ${CC} ${INCPATH} ${DEFS} -c ${.CURDIR}/srt0.s -tpsrt0.o: ${.CURDIR}/srt0.s - ${CC} ${INCPATH} ${DEFS} -DTP -c ${.CURDIR}/srt0.s -o $@ - -# new boot -pboot: srt0.o pboot.o tgets.o conf.o ${LIBS} - ${LD} -N -T ${RELOC} -e begin srt0.o pboot.o tgets.o conf.o ${LIBS} -o $@ +# unified boot program (disk, network, tape) +uboot: srt0.o uboot.o tgets.o netio.o clock.o conf.o ${LIBS} + ${LD} -N -T ${RELOC} -e begin srt0.o uboot.o tgets.o netio.o clock.o \ + conf.o ${LIBS} -o $@ @size $@ @echo $@ total size should not exceed 1044480 bytes -ls: srt0.o ls.o conf.o ${LIBS} - ${LD} -N -T ${RELOC} -e begin srt0.o ls.o conf.o ${LIBS} -o $@ +# miniroot installation program +inst: srt0.o inst.o clock.o conf.o netio.o tgets.o ${LIBS} + ${LD} -N -T ${RELOC} -e begin srt0.o inst.o clock.o conf.o netio.o \ + tgets.o ${LIBS} -o $@ @size $@ @echo $@ total size should not exceed 1044480 bytes -cat: srt0.o cat.o conf.o ${LIBS} - ${LD} -N -T ${RELOC} -e begin srt0.o cat.o conf.o ${LIBS} -o $@ - @size $@ - @echo $@ total size should not exceed 1044480 bytes - -# installation -sys_inst: srt0.o sys_inst.o clock.o instconf.o inst_netio.o tgets.o ${LIBS} - ${LD} -N -T ${RELOC} -e begin srt0.o sys_inst.o clock.o instconf.o inst_netio.o tgets.o ${LIBS} -o $@ - @size $@ - @echo $@ total size should not exceed 1044480 bytes - -instconf.o: ${.CURDIR}/conf.c - ${CC} ${CFLAGS} -DSYS_INST -c ${.CURDIR}/conf.c -o $@ - -inst_netio.o: ${.CURDIR}/netio.c - ${CC} ${CFLAGS} -DSYS_INST -c ${.CURDIR}/netio.c -o $@ - -# bootable from network - -netboot: srt0.o netboot.o clock.o netconf.o netio.o tgets.o ${LIBS} - ${LD} -N -T ${RELOC} -e begin srt0.o netboot.o clock.o netconf.o netio.o tgets.o ${LIBS} -o $@ - @size $@ - @echo $@ total size should not exceed 1044480 bytes - -netconf.o: ${.CURDIR}/conf.c - ${CC} ${CFLAGS} -DNETBOOT -c ${.CURDIR}/conf.c -o $@ - -# bootable from tape - -tboot: srt0.o tboot.o conf.o ${LIBS} - ${LD} -N -T ${RELOC} -e begin srt0.o tboot.o conf.o ${LIBS} -o $@ - @size $@ - @echo $@ total size should not exceed 1044480 bytes - -tboot.o: ${.CURDIR}/boot.c - ${CC} ${CFLAGS} -DJUSTASK -c ${.CURDIR}/boot.c -o $@ - -tcopy: tpsrt0.o copy.o conf.o ${LIBS} - ${LD} -N -T ${RELOC} -e begin tpsrt0.o copy.o conf.o ${LIBS} -o $@ - @size $@ - @echo $@ total size should not exceed 1044480 bytes - -# bootable from floppy or real disks - -dboot: srt0.o boot.o tapeconf.o ${LIBS} - ${LD} -N -T ${RELOC} -e begin srt0.o boot.o tapeconf.o ${LIBS} -o $@ - @size $@ - @echo $@ text+data size should not exceed 57344 bytes - @echo $@ total size should not exceed 1044480 bytes - -tapeconf.o: ${.CURDIR}/conf.c - ${CC} ${CFLAGS} -DTAPEBOOT -c ${.CURDIR}/conf.c -o $@ - -dcopy: srt0.o copy.o conf.o ${LIBS} - ${LD} -N -T ${RELOC} -e begin srt0.o copy.o conf.o ${LIBS} -o $@ - +# helper program ... turns OMAGIC into LIF mkboot: ${.CURDIR}/mkboot.c ${CC} ${CFLAGS} ${.CURDIR}/mkboot.c -o $@ @@ -142,35 +87,34 @@ installboot: ${.CURDIR}/installboot.sh # utilities clean:: - rm -f *.o *.exe *.i errs make.out - rm -f a.out pboot cat ls tboot tcopy - rm -f boot[a-z]? boot[a-wyz][a-z].c conf[a-wyz][a-z].c - rm -f core sboot - rm -f libdrive.a mkboot dboot dcopy installboot *.lif + rm -f *.o *.i + rm -f a.out ${BOOTS} + rm -f libdrive.a mkboot installboot *.lif install: mkboot installboot ${ALL} - ./mkboot pboot netbsdboot.lif - ./mkboot netboot netboot.lif - ./mkboot sys_inst sys_inst.lif - ./mkboot dboot diskboot.lif - ./mkboot tboot tcopy tapeboot.lif + ./mkboot uboot uboot.lif + ./mkboot inst inst.lif + install -d -m 755 -o ${BINOWN} -g ${BINGRP} ${DESTDIR}/usr/mdec/rbootd install -c -o ${BINOWN} -g ${BINGRP} -m 555 installboot \ ${DESTDIR}/usr/mdec - install -c -o ${BINOWN} -g ${BINGRP} -m 444 netbsdboot.lif \ - ${DESTDIR}/usr/mdec/rdboot + install -c -o ${BINOWN} -g ${BINGRP} -m 444 uboot.lif \ + ${DESTDIR}/usr/mdec + rm -f ${DESTDIR}/usr/mdec/rdboot + ln ${DESTDIR}/usr/mdec/uboot.lif ${DESTDIR}/usr/mdec/rdboot rm -f ${DESTDIR}/usr/mdec/bootrd - ln ${DESTDIR}/usr/mdec/rdboot ${DESTDIR}/usr/mdec/bootrd + ln ${DESTDIR}/usr/mdec/uboot.lif ${DESTDIR}/usr/mdec/bootrd rm -f ${DESTDIR}/usr/mdec/sdboot - ln ${DESTDIR}/usr/mdec/rdboot ${DESTDIR}/usr/mdec/sdboot + ln ${DESTDIR}/usr/mdec/uboot.lif ${DESTDIR}/usr/mdec/sdboot rm -f ${DESTDIR}/usr/mdec/bootsd - ln ${DESTDIR}/usr/mdec/sdboot ${DESTDIR}/usr/mdec/bootsd - install -d -m 755 -o ${BINOWN} -g ${BINGRP} ${DESTDIR}/usr/mdec/rbootd - install -c -o ${BINOWN} -g ${BINGRP} -m 444 netboot.lif \ - ${DESTDIR}/usr/mdec/rbootd/SYS_NBOOT - install -c -o ${BINOWN} -g ${BINGRP} -m 444 sys_inst.lif \ + ln ${DESTDIR}/usr/mdec/uboot.lif ${DESTDIR}/usr/mdec/bootsd + rm -f ${DESTDIR}/usr/mdec/ctboot + ln ${DESTDIR}/usr/mdec/uboot.lif ${DESTDIR}/usr/mdec/ctboot + rm -f ${DESTDIR}/usr/mdec/bootct + ln ${DESTDIR}/usr/mdec/uboot.lif ${DESTDIR}/usr/mdec/bootct + rm -f ${DESTDIR}/usr/mdec/rbootd/SYS_UBOOT + ln ${DESTDIR}/usr/mdec/uboot.lif ${DESTDIR}/usr/mdec/rbootd/SYS_UBOOT + install -c -o ${BINOWN} -g ${BINGRP} -m 444 inst.lif \ ${DESTDIR}/usr/mdec/rbootd/SYS_INST - install -c -o ${BINOWN} -g ${BINGRP} -m 644 tapeboot.lif \ - ${DESTDIR}/usr/mdec/bootct .include .include diff --git a/sys/arch/hp300/stand/autoconf.c b/sys/arch/hp300/stand/autoconf.c index 17f3c20107c7..da9b26f442a0 100644 --- a/sys/arch/hp300/stand/autoconf.c +++ b/sys/arch/hp300/stand/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.9 1995/08/05 16:47:34 thorpej Exp $ */ +/* $NetBSD: autoconf.c,v 1.10 1996/06/26 17:44:23 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -57,7 +57,9 @@ * WARNING: major numbers must match bdevsw indices in hp300/conf.c. */ char rom2mdev[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0-13: none */ + 0, 0, /* 0-1: none */ + 6, /* 2: network device; special */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 3-13: none */ 4, /* 14: SCSI disk */ 0, /* 15: none */ 2, /* 16: CS/80 device on HPIB */ diff --git a/sys/arch/hp300/stand/boot.c b/sys/arch/hp300/stand/boot.c deleted file mode 100644 index 7ddb6efb8fef..000000000000 --- a/sys/arch/hp300/stand/boot.c +++ /dev/null @@ -1,101 +0,0 @@ -/* $NetBSD: boot.c,v 1.6 1995/02/21 09:06:13 mycroft Exp $ */ - -/*- - * 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 -#include -#include -#include "stand.h" - -/* - * Boot program... bits in `howto' determine whether boot stops to - * ask for system name. Boot device is derived from ROM provided - * information. - */ - -char line[100]; - -extern u_int opendev; -extern char *lowram; -extern int noconsole; -extern int howto, bootdev; - -main() -{ - int retry, type; - - printf("%s CPU\nBoot\n", getmachineid()); -#ifdef JUSTASK - howto = RB_ASKNAME|RB_SINGLE; -#else - if ((howto & RB_ASKNAME) == 0) { - type = (bootdev >> B_TYPESHIFT) & B_TYPEMASK; - if ((unsigned)type < ndevs && devsw[type].dv_name) - strcpy(line, "/netbsd"); - else - howto |= RB_SINGLE|RB_ASKNAME; - } -#endif - for (retry = 0;;) { - if (!noconsole && (howto & RB_ASKNAME)) { - printf(": "); - gets(line); - if (line[0] == 0) { - strcpy(line, "/netbsd"); - printf(": %s\n", line); - } - } else - printf(": %s\n", line); - exec(line, lowram, howto); - printf("boot: %s\n", strerror(errno)); - howto |= RB_SINGLE|RB_ASKNAME; - } -} - -void -machdep_start(entry, howto, loadaddr, ssym, esym) - char *entry; - int howto; - char *loadaddr; - char *ssym, *esym; -{ - - asm("movl %0,d7" : : "m" (howto)); - asm("movl %0,d6" : : "m" (opendev)); - asm("movl %0,a5" : : "a" (loadaddr)); - asm("movl %0,a4" : : "a" (esym)); - (*((int (*)())entry))(); -} diff --git a/sys/arch/hp300/stand/conf.c b/sys/arch/hp300/stand/conf.c index 6e8fb07a7dfc..c96686dde407 100644 --- a/sys/arch/hp300/stand/conf.c +++ b/sys/arch/hp300/stand/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.10 1995/09/23 17:28:11 thorpej Exp $ */ +/* $NetBSD: conf.c,v 1.11 1996/06/26 17:44:26 thorpej Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -39,7 +39,6 @@ #include "stand.h" -#if defined(NETBOOT) || defined(SYS_INST) #include #include #include @@ -47,38 +46,22 @@ #include #include "nfs.h" - -#endif /* NETBOOT || SYS_INST */ - -#ifndef NETBOOT +#include "rawfs.h" #include "ufs.h" -#endif /* ! NETBOOT */ int debug = 0; /* XXX */ /* * Device configuration */ -#if defined(NETBOOT) || defined(SYS_INST) int netstrategy __P((void *, int, daddr_t, size_t, void *, size_t *)); int netopen __P((struct open_file *, ...)); int netclose __P((struct open_file *)); #define netioctl noioctl -#endif /* NETBOOT || SYS_INST */ -#ifndef NETBOOT -/* XXX: no support for tapes in SYS_INST yet. */ -#ifdef TAPEBOOT int ctstrategy __P((void *, int, daddr_t, size_t, void *, size_t *)); int ctopen __P((struct open_file *, ...)); int ctclose __P((struct open_file *)); -#else -#define ctstrategy \ - (int (*) __P((void *, int, daddr_t, size_t, void *, size_t *)))nullsys -#define ctopen (int (*) __P((struct open_file *, ...)))nodev -#define ctclose (int (*) __P((struct open_file *)))nullsys -#endif /* TAPEBOOT */ - #define ctioctl noioctl int rdstrategy __P((void *, int, daddr_t, size_t, void *, size_t *)); @@ -96,46 +79,46 @@ int sdclose __P((struct open_file *)); #define xxopen (int (*) __P((struct open_file *, ...)))nodev #define xxclose (int (*) __P((struct open_file *)))nullsys -#endif /* ! NETBOOT */ - +/* + * Note: "le" isn't a major offset. + */ struct devsw devsw[] = { -#ifdef NETBOOT - { "le", netstrategy, netopen, netclose, netioctl }, /*0*/ -#else { "ct", ctstrategy, ctopen, ctclose, ctioctl }, /*0*/ { "??", xxstrategy, xxopen, xxclose, noioctl }, /*1*/ { "rd", rdstrategy, rdopen, rdclose, rdioctl }, /*2*/ { "??", xxstrategy, xxopen, xxclose, noioctl }, /*3*/ { "sd", sdstrategy, sdopen, sdclose, sdioctl }, /*4*/ -#ifdef SYS_INST - { "le", netstrategy, netopen, netclose, netioctl }, -#endif /* SYS_INST */ -#endif /* NETBOOT */ + { "??", xxstrategy, xxopen, xxclose, noioctl }, /*5*/ + { "le", netstrategy, netopen, netclose, netioctl },/*6*/ }; -int ndevs = (sizeof(devsw)/sizeof(devsw[0])); +int ndevs = (sizeof(devsw) / sizeof(devsw[0])); -/* - * Filesystem configuration - */ -struct fs_ops file_system[] = { -#ifndef NETBOOT - { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }, -#endif /* ! NETBOOT */ -#if defined(NETBOOT) || defined(SYS_INST) - { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat }, -#endif /* NETBOOT || SYS_INST */ -}; - -int nfsys = (sizeof(file_system) / sizeof(file_system[0])); - -#if defined(NETBOOT) || defined(SYS_INST) extern struct netif_driver le_driver; struct netif_driver *netif_drivers[] = { &le_driver, }; -int n_netif_drivers = sizeof(netif_drivers)/sizeof(netif_drivers[0]); -#endif /* NETBOOT */ +int n_netif_drivers = (sizeof(netif_drivers) / sizeof(netif_drivers[0])); + +/* + * Filesystem configuration + */ +struct fs_ops file_system_rawfs[] = { + { rawfs_open, rawfs_close, rawfs_read, rawfs_write, rawfs_seek, + rawfs_stat }, +}; + +struct fs_ops file_system_ufs[] = { + { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }, +}; + +struct fs_ops file_system_nfs[] = { + { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat }, +}; + +struct fs_ops file_system[1]; +int nfsys = 1; /* we always know which one we want */ + /* * Inititalize controllers @@ -144,11 +127,7 @@ int n_netif_drivers = sizeof(netif_drivers)/sizeof(netif_drivers[0]); */ void ctlrinit() { -#if defined(NETBOOT) || defined(SYS_INST) leinit(); -#endif /* NETBOOT || SYS_INST */ -#ifndef NETBOOT hpibinit(); scsiinit(); -#endif /* ! NETBOOT */ } diff --git a/sys/arch/hp300/stand/devopen.c b/sys/arch/hp300/stand/devopen.c index fe22240ed693..9dd1e94f3925 100644 --- a/sys/arch/hp300/stand/devopen.c +++ b/sys/arch/hp300/stand/devopen.c @@ -1,6 +1,7 @@ -/* $NetBSD: devopen.c,v 1.5 1995/08/05 16:47:41 thorpej Exp $ */ +/* $NetBSD: devopen.c,v 1.6 1996/06/26 17:44:28 thorpej Exp $ */ /*- + * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1993 John Brezak * All rights reserved. * @@ -61,10 +62,38 @@ devlookup(d, len) struct devsw *dp = devsw; int i; - for (i = 0; i < ndevs; i++, dp++) - if (dp->dv_name && strncmp(dp->dv_name, d, len) == 0) - return(i); + for (i = 0; i < ndevs; i++, dp++) { + if (dp->dv_name && strncmp(dp->dv_name, d, len) == 0) { + /* + * Set the filesystem and startup up according to the device + * being opened. + */ + switch (i) { + case 0: /* ct */ + bcopy(file_system_rawfs, file_system, sizeof(struct fs_ops)); + __machdep_start = machdep_start_disk_tape; + break; + case 2: /* rd */ + case 4: /* sd */ + bcopy(file_system_ufs, file_system, sizeof(struct fs_ops)); + __machdep_start = machdep_start_disk_tape; + break; + + case 6: /* le */ + bcopy(file_system_nfs, file_system, sizeof(struct fs_ops)); + __machdep_start = machdep_start_net; + break; + + default: + /* Agh! What happened?! */ + goto bad; + } + return(i); + } + } + + bad: printf("No such device - Configured devices are:\n"); for (dp = devsw, i = 0; i < ndevs; i++, dp++) if (dp->dv_name) @@ -187,7 +216,38 @@ devopen(f, fname, file) ctlr = B_CONTROLLER(bootdev); unit = B_UNIT(bootdev); part = B_PARTITION(bootdev); - + + /* + * Set up defaults for filesystem and startup, according to + * type detetect by the BOOT ROM. + */ + switch (dev) { + case 0: /* ct */ + bcopy(file_system_rawfs, file_system, sizeof(struct fs_ops)); + __machdep_start = machdep_start_disk_tape; + break; + + case 2: /* rd */ + case 4: /* sd */ + bcopy(file_system_ufs, file_system, sizeof(struct fs_ops)); + __machdep_start = machdep_start_disk_tape; + break; + + case 6: /* le */ + bcopy(file_system_nfs, file_system, sizeof(struct fs_ops)); + __machdep_start = machdep_start_net; + break; + + default: + /* XXX what else should we do here? */ + printf("WARNING: BOGUS BOOT DEV TYPE 0x%x!\n", dev); + printf("FALLING BACK ON `sd'\n"); + bcopy(file_system_ufs, file_system, sizeof(struct fs_ops)); + __machdep_start = machdep_start_disk_tape; + break; + } + + if (error = devparse(fname, &dev, &adapt, &ctlr, &unit, &part, file)) return(error); @@ -197,9 +257,9 @@ devopen(f, fname, file) return(ENODEV); opendev = MAKEBOOTDEV(dev, adapt, ctlr, unit, part); - + f->f_dev = dp; - + if ((error = (*dp->dv_open)(f, adapt, ctlr, part)) == 0) return(0); @@ -207,4 +267,4 @@ devopen(f, fname, file) adapt, ctlr, unit, part, strerror(error)); return(error); -} +} diff --git a/sys/arch/hp300/stand/sys_inst.c b/sys/arch/hp300/stand/inst.c similarity index 97% rename from sys/arch/hp300/stand/sys_inst.c rename to sys/arch/hp300/stand/inst.c index bd98f8dee672..28afbfe01125 100644 --- a/sys/arch/hp300/stand/sys_inst.c +++ b/sys/arch/hp300/stand/inst.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_inst.c,v 1.3 1995/10/04 07:24:33 thorpej Exp $ */ +/* $NetBSD: inst.c,v 1.1 1996/06/26 17:44:29 thorpej Exp $ */ /* * Copyright (c) 1995 Jason R. Thorpe. @@ -69,6 +69,7 @@ extern u_int opendev; extern char *lowram; extern int noconsole; extern int cons_scode; +extern int netio_ask; char *kernel_name = "/netbsd"; @@ -99,9 +100,15 @@ main() { int i, currname = 0; - printf("\n>> NetBSD INSTALLATION HP9000/%s CPU\n", + /* + * We want netopen() to ask for IP address, etc, rather + * that using bootparams. + */ + netio_ask = 1; + + printf("\n>> NetBSD MINIROOT INSTALLATION HP9000/%s CPU\n", getmachineid()); - printf(">> $NetBSD: sys_inst.c,v 1.3 1995/10/04 07:24:33 thorpej Exp $\n"); + printf(">> $NetBSD: inst.c,v 1.1 1996/06/26 17:44:29 thorpej Exp $\n"); gethelp(); for (;;) { diff --git a/sys/arch/hp300/stand/libsa/Makefile b/sys/arch/hp300/stand/libsa/Makefile index 8ba5d23934c4..0d7bbe4e08b7 100644 --- a/sys/arch/hp300/stand/libsa/Makefile +++ b/sys/arch/hp300/stand/libsa/Makefile @@ -1,13 +1,15 @@ -# $NetBSD: Makefile,v 1.4 1996/01/30 19:47:32 thorpej Exp $ +# $NetBSD: Makefile,v 1.5 1996/06/26 17:44:42 thorpej Exp $ LIB= sa .PATH: ${.CURDIR}/../../../../lib/libsa +.PATH: ${.CURDIR}/.. # Don't need these now... # DEBUGFLAGS=-DNETIF_DEBUG -DRPC_DEBUG -DNFS_DEBUG -DRARP_DEBUG -DNET_DEBUG -CFLAGS+=-DSTANDALONE -DCOMPAT_UFS ${DEBUGFLAGS} +CFLAGS+=-DSTANDALONE -DCOMPAT_UFS -DNO_LSEEK ${DEBUGFLAGS} +CFLAGS+=-I${.CURDIR}/.. CFLAGS+=-I${.CURDIR}/../../../.. -I${.CURDIR}/../../../../lib/libsa # stand routines @@ -25,7 +27,7 @@ SRCS+= arp.c ether.c in_cksum.c net.c netif.c rpc.c SRCS+= bootp.c bootparam.c rarp.c # boot filesystems -SRCS+= ufs.c nfs.c +SRCS+= ufs.c nfs.c rawfs.o NOPROFILE= NOPIC= diff --git a/sys/arch/hp300/stand/netboot.c b/sys/arch/hp300/stand/netboot.c deleted file mode 100644 index 34e9aee755b0..000000000000 --- a/sys/arch/hp300/stand/netboot.c +++ /dev/null @@ -1,162 +0,0 @@ -/* $NetBSD: netboot.c,v 1.10 1995/10/04 07:24:32 thorpej Exp $ */ - -/*- - * 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 -#include -#include -#include "stand.h" -#include "samachdep.h" - -/* - * Boot program... bits in `howto' determine whether boot stops to - * ask for system name. Boot device is derived from ROM provided - * information. - */ - -char line[100]; - -extern u_int opendev; -extern char *lowram; -extern int noconsole; -extern int cons_scode; - -char *name; -char *names[] = { - "netbsd", "onetbsd", "netbsd.old", -}; -#define NUMNAMES (sizeof(names)/sizeof(char *)) - -static int bdev, badapt, bctlr, bunit, bpart; - -main() -{ - int currname = 0; - - /* - * XXX: different versions of the HP boot rom seem to report - * different things, so we have to compensate. - */ - bootdev = MAKEBOOTDEV(0, 0, 0, 0, 0); - - printf("\n>> NetBSD NETWORK BOOT HP9000/%s CPU\n", - getmachineid()); - printf(">> $NetBSD: netboot.c,v 1.10 1995/10/04 07:24:32 thorpej Exp $\n"); - printf(">> Enter \"reset\" to reset system.\n"); - - bdev = B_TYPE(bootdev); - badapt = B_ADAPTOR(bootdev); - bctlr = B_CONTROLLER(bootdev); - bunit = B_UNIT(bootdev); - bpart = B_PARTITION(bootdev); - - for (;;) { - name = names[currname++]; - if (currname == NUMNAMES) - currname = 0; - - if (!noconsole) { - howto = 0; - getbootname(&howto); - } else - printf(": %s\n", name); - - exec(name, lowram, howto); - printf("boot: %s\n", strerror(errno)); - } -} - -getbootname(howto) - int *howto; -{ - char c, *ptr = line; - - printf("Boot: [%s][-s][-a][-d] :- ", name); - - if (tgets(line)) { - if (strcmp(line, "reset") == 0) { - call_req_reboot(); /* reset machine */ - printf("panic: can't reboot, halting\n"); - asm("stop #0x2700"); - } - - while (c = *ptr) { - while (c == ' ') - c = *++ptr; - if (!c) - return; - if (c == '-') - while ((c = *++ptr) && c != ' ') - switch (c) { - case 'a': - *howto |= RB_ASKNAME; - continue; - case 's': - *howto |= RB_SINGLE; - continue; - case 'd': - *howto |= RB_KDB; - continue; - case 'b': - *howto |= RB_HALT; - continue; - } - else { - name = ptr; - while ((c = *++ptr) && c != ' '); - if (c) - *ptr++ = 0; - } - } - } else - printf("\n"); -} - -void -machdep_start(entry, howto, loadaddr, ssym, esym) - char *entry; - int howto; - char *loadaddr; - char *ssym, *esym; -{ - - asm("movl %0,d7" : : "m" (howto)); - asm("movl #0,d6"); /* tell setroot we've netbooted */ - asm("movl %0,d5" : : "m" (cons_scode)); - asm("movl %0,a5" : : "a" (loadaddr)); - asm("movl %0,a4" : : "a" (esym)); - (*((int (*)())entry))(); -} diff --git a/sys/arch/hp300/stand/netio.c b/sys/arch/hp300/stand/netio.c index f655eeeb1b4d..c74e60224871 100644 --- a/sys/arch/hp300/stand/netio.c +++ b/sys/arch/hp300/stand/netio.c @@ -1,7 +1,7 @@ -/* $NetBSD: netio.c,v 1.2 1995/09/23 17:31:10 thorpej Exp $ */ +/* $NetBSD: netio.c,v 1.3 1996/06/26 17:44:32 thorpej Exp $ */ /* - * Copyright (c) 1995 Jason R. Thorpe + * Copyright (c) 1995, 1996 Jason R. Thorpe * Copyright (c) 1995 Gordon W. Ross * All rights reserved. * @@ -71,9 +71,9 @@ char rootpath[FNAME_SIZE]; int netdev_sock = -1; static int open_count; -#ifdef SYS_INST +int netio_ask = 0; /* default to bootparam, can override */ + static char input_line[100]; -#endif /* Why be any different? */ #define SUN_BOOTPARAMS @@ -131,64 +131,68 @@ netmountroot(f, devname) char *devname; /* Device part of file name (or NULL). */ { int error; -#ifdef SYS_INST struct iodesc *d; -#endif #ifdef DEBUG printf("netmountroot: %s\n", devname); #endif -#ifdef SYS_INST + if (netio_ask) { get_my_ip: - printf("My IP address? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((myip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) { - printf("invalid IP address: %s\n", input_line); - goto get_my_ip; - } + printf("My IP address? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((myip.s_addr = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid IP address: %s\n", input_line); + goto get_my_ip; + } get_my_netmask: - printf("My netmask? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((netmask = inet_addr(input_line)) == htonl(INADDR_NONE)) { - printf("invalid netmask: %s\n", input_line); - goto get_my_netmask; - } + printf("My netmask? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((netmask = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid netmask: %s\n", input_line); + goto get_my_netmask; + } get_my_gateway: - printf("My gateway? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((gateip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) { - printf("invalid IP address: %s\n", input_line); - goto get_my_gateway; - } + printf("My gateway? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((gateip.s_addr = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid IP address: %s\n", input_line); + goto get_my_gateway; + } get_server_ip: - printf("Server IP address? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((rootip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) { - printf("invalid IP address: %s\n", input_line); - goto get_server_ip; - } + printf("Server IP address? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((rootip.s_addr = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid IP address: %s\n", input_line); + goto get_server_ip; + } get_server_path: - printf("Server path? "); - bzero(rootpath, sizeof(rootpath)); - gets(rootpath); - if (rootpath[0] == '\0' || rootpath[0] == '\n') - goto get_server_path; + printf("Server path? "); + bzero(rootpath, sizeof(rootpath)); + gets(rootpath); + if (rootpath[0] == '\0' || rootpath[0] == '\n') + goto get_server_path; - if ((d = socktodesc(netdev_sock)) == NULL) - return (EMFILE); + if ((d = socktodesc(netdev_sock)) == NULL) + return (EMFILE); - d->myip = myip; + d->myip = myip; + + goto do_nfs_mount; + } -#else /* SYS_INST */ /* * Get info for NFS boot: our IP address, our hostname, * server IP address, and our root path on the server. @@ -233,8 +237,7 @@ netmountroot(f, devname) printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath); -#endif /* SYS_INST */ - + do_nfs_mount: /* Get the NFS file handle (mount). */ error = nfs_mount(netdev_sock, rootip, rootpath); diff --git a/sys/arch/hp300/stand/rawfs.c b/sys/arch/hp300/stand/rawfs.c new file mode 100644 index 000000000000..c2d9a58b8b41 --- /dev/null +++ b/sys/arch/hp300/stand/rawfs.c @@ -0,0 +1,207 @@ +/* $NetBSD: rawfs.c,v 1.1 1996/06/26 17:44:35 thorpej 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 +#include +#include + +extern int debug; + +/* Our devices are generally willing to do 8K transfers. */ +#define RAWFS_BSIZE 0x2000 + +/* + * In-core open file. + */ +struct file { + 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 file *fs; + + /* + * The actual PROM driver has already been opened. + * Just allocate the I/O buffer, etc. + */ + fs = alloc(sizeof(struct file)); + fs->fs_nextblk = 0; + fs->fs_len = 0; + fs->fs_ptr = fs->fs_buf; + +#ifdef DEBUG_RAWFS + printf("rawfs_open: fs=0x%x\n", fs); +#endif + + f->f_fsdata = fs; + return (0); +} + +int rawfs_close(f) + struct open_file *f; +{ + struct file *fs; + + fs = (struct file *) f->f_fsdata; + f->f_fsdata = (void *)0; + +#ifdef DEBUG_RAWFS + if (debug) { + printf("rawfs_close: breakpoint...", fs->fs_buf); + __asm (" trap #0"); + } +#endif + + if (fs != (struct file *)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 file *fs = (struct file *)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 */ +{ +#ifdef DEBUG_RAWFS + panic("rawfs_write"); +#endif + return (EROFS); +} + +off_t rawfs_seek(f, offset, where) + struct open_file *f; + off_t offset; + int where; +{ +#ifdef DEBUG_RAWFS + panic("rawfs_seek"); +#endif + return (EFTYPE); +} + +int rawfs_stat(f, sb) + struct open_file *f; + struct stat *sb; +{ +#ifdef DEBUG_RAWFS + panic("rawfs_stat"); +#endif + /* + * Clear out the stat buffer so that the uid check + * won't fail. See sys/lib/libsa/exec.c + */ + bzero(sb, sizeof(*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 file *fs; + int error, len; + + fs = (struct file *)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/hp300/stand/rawfs.h b/sys/arch/hp300/stand/rawfs.h new file mode 100644 index 000000000000..1ab4819648b3 --- /dev/null +++ b/sys/arch/hp300/stand/rawfs.h @@ -0,0 +1,15 @@ +/* $NetBSD: rawfs.h,v 1.1 1996/06/26 17:44:36 thorpej 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/hp300/stand/samachdep.h b/sys/arch/hp300/stand/samachdep.h index 192d2b4241af..53213e81fdd7 100644 --- a/sys/arch/hp300/stand/samachdep.h +++ b/sys/arch/hp300/stand/samachdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: samachdep.h,v 1.5 1995/08/05 16:47:50 thorpej Exp $ */ +/* $NetBSD: samachdep.h,v 1.6 1996/06/26 17:44:37 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -35,6 +35,8 @@ * @(#)samachdep.h 8.1 (Berkeley) 6/10/93 */ +#include + #define NHPIB 4 #define NSCSI 2 #define NRD 8 @@ -71,9 +73,23 @@ extern int howto; extern unsigned int bootdev; extern char *getmachineid(); +void machdep_start_net __P((char *, int, char *, char *, char *)); +void machdep_start_disk_tape __P((char *, int, char *, char *, char *)); +void (*__machdep_start) __P((char *, int, char *, char *, char *)); + #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } /* bogon grfinfo structure to keep grf_softc happy */ struct grfinfo { int grf_foo; }; + +extern struct devsw devsw_net[]; +extern int ndevs_net; + +extern struct devsw devsw_general[]; +extern int ndevs_general; + +extern struct fs_ops file_system_rawfs[]; +extern struct fs_ops file_system_ufs[]; +extern struct fs_ops file_system_nfs[]; diff --git a/sys/arch/hp300/stand/pboot.c b/sys/arch/hp300/stand/uboot.c similarity index 82% rename from sys/arch/hp300/stand/pboot.c rename to sys/arch/hp300/stand/uboot.c index 34407c14befc..c1ec3a8f5a4d 100644 --- a/sys/arch/hp300/stand/pboot.c +++ b/sys/arch/hp300/stand/uboot.c @@ -1,4 +1,4 @@ -/* $NetBSD: pboot.c,v 1.10 1995/10/04 07:24:31 thorpej Exp $ */ +/* $NetBSD: uboot.c,v 1.1 1996/06/26 17:44:39 thorpej Exp $ */ /*- * Copyright (c) 1982, 1986, 1990, 1993 @@ -54,11 +54,14 @@ extern char *lowram; extern int noconsole; extern int cons_scode; +/* + * XXX UFS accepts a /, NFS doesn't. + */ char *name; char *names[] = { - "/netbsd", "/onetbsd", "/netbsd.old", + "netbsd", "onetbsd", "netbsd.old", }; -#define NUMNAMES (sizeof(names)/sizeof(char *)) +#define NUMNAMES (sizeof(names) / sizeof(char *)) static int bdev, badapt, bctlr, bunit, bpart; @@ -66,9 +69,9 @@ main() { int currname = 0; - printf("\n>> NetBSD BOOT HP9000/%s CPU\n", + printf("\n>> NetBSD UNIFIED BOOT HP9000/%s CPU\n", getmachineid()); - printf(">> $NetBSD: pboot.c,v 1.10 1995/10/04 07:24:31 thorpej Exp $\n"); + printf(">> $NetBSD: uboot.c,v 1.1 1996/06/26 17:44:39 thorpej Exp $\n"); printf(">> Enter \"reset\" to reset system.\n"); bdev = B_TYPE(bootdev); @@ -88,11 +91,6 @@ main() } else printf(": %s\n", name); -#if 0 - printf("Booting %s%d%c:%s @ 0x%x\n", - devsw[dev].dv_name, ctlr + (8 * adapt), 'a' + part, name, x.a_entry); -#endif - exec(name, lowram, howto); printf("boot: %s\n", strerror(errno)); } @@ -145,7 +143,23 @@ getbootdev(howto) } void -machdep_start(entry, howto, loadaddr, ssym, esym) +machdep_start_net(entry, howto, loadaddr, ssym, esym) + char *entry; + int howto; + char *loadaddr; + char *ssym, *esym; +{ + + asm("movl %0,d7" : : "m" (howto)); + asm("movl #0,d6"); /* tell setroot we've netbooted */ + asm("movl %0,d5" : : "m" (cons_scode)); + asm("movl %0,a5" : : "a" (loadaddr)); + asm("movl %0,a4" : : "a" (esym)); + (*((int (*)())entry))(); +} + +void +machdep_start_disk_tape(entry, howto, loadaddr, ssym, esym) char *entry; int howto; char *loadaddr; @@ -159,3 +173,14 @@ machdep_start(entry, howto, loadaddr, ssym, esym) asm("movl %0,a4" : : "a" (esym)); (*((int (*)())entry))(); } + +void +machdep_start(entry, howto, loadaddr, ssym, esym) + char *entry; + int howto; + char *loadaddr; + char *ssym, *esym; +{ + + (*__machdep_start)(entry, howto, loadaddr, ssym, esym); +}