diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-05-05 06:02:04 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-05-05 06:02:04 +0000 |
commit | 3d10bc794d2e03421fd174136259f42a03004bca (patch) | |
tree | d1b03f69e85167322eb9804fa9e85237ce45b7f1 /sys/arch/alpha/stand/netboot | |
parent | 53e6b51c98a2cae3f0e7c41c03a85f76fcd17341 (diff) |
Updates from NetBSD (cgd):
- seriously clean up makefiles. use libsa/libkern/libz as appropriate,
and don't build the various sources into objs locally by specifying
them directly in the Makefiles.
- move the secondary bootstrap down (to 0x20004000), and add a HEAP_LIMIT
so that we don't exhaust our bootstrap address space (when using the new,
not yet checked in, memory allocator).
- clean up installboot, deal with secondary bootstrap programs not on
'a' partition or 'a' partition not starting at 0.
- add padding to structures in bbinfo.h for future expansion. Add a
netbbinfo structure to allow netboot information to be hard-coded in
network boot blocks, so that they can be made to work even on systems
with firmware which doesn't support the new "ethernet address in boot
device" convention.
- move the sync() calls to the correct place in installboot.c
- remove a kludge in disk.c which was breaking multiple opens/closes
of the disk
- allow netboot ethernet address to be hard-coded into binary so that
machines with old firmware which doesn't pass it in the boot device
can work. Assume that if the ethernet address isn't passed in, it
uses the old (dain-bramaged) 'read' interface works on my 3000/300LX.
- Add setnetbootinfo, a program to hard code an ethernet address into
a network boot.
- move an 'int debug;' into boot.c (it was the only diff between boot.c and
netboot.c), and nuke netboot.c (using boot.c instead for net boot blocks).
- add cd9660 file system ops to the file system ops table in filesystem.c
- if a file name is given (i.e. BOOTED_FILE) is set, boot only that file,
but if not then try to boot "bsd", "bsd.bak", "bsd.old", and
"obsd" (in that order) until one is found or until the list of names
is exhausted.
- add support for reading gzipped kernels.
- use strerror() to print errors, rather than just printing error numbers
- if no disk label exists, fake one up
- slightly relax the block size checks in bootxx.c; they were a bit to paranoid
And local changes:
- don't build a copy of libsa/libkern/libz for each boot prog,
just build a single copy and use it for everything.
Diffstat (limited to 'sys/arch/alpha/stand/netboot')
-rw-r--r-- | sys/arch/alpha/stand/netboot/Makefile | 98 | ||||
-rw-r--r-- | sys/arch/alpha/stand/netboot/conf.c | 8 | ||||
-rw-r--r-- | sys/arch/alpha/stand/netboot/dev_net.c | 12 | ||||
-rw-r--r-- | sys/arch/alpha/stand/netboot/devopen.c | 6 | ||||
-rw-r--r-- | sys/arch/alpha/stand/netboot/if_prom.c | 92 | ||||
-rw-r--r-- | sys/arch/alpha/stand/netboot/version | 12 |
6 files changed, 147 insertions, 81 deletions
diff --git a/sys/arch/alpha/stand/netboot/Makefile b/sys/arch/alpha/stand/netboot/Makefile index d05d684b225..359b6be7d00 100644 --- a/sys/arch/alpha/stand/netboot/Makefile +++ b/sys/arch/alpha/stand/netboot/Makefile @@ -1,61 +1,67 @@ -# $OpenBSD: Makefile,v 1.2 1996/11/27 19:54:54 niklas Exp $ -# $NetBSD: Makefile,v 1.3 1996/10/18 06:02:24 thorpej Exp $ +# $OpenBSD: Makefile,v 1.3 1997/05/05 06:01:59 millert Exp $ +# $NetBSD: Makefile,v 1.11 1997/04/17 07:27:50 thorpej Exp $ -.PATH: ${.CURDIR}/.. ${.CURDIR}/../../../../lib/libsa +S= ${.CURDIR}/../../../.. + +.PATH: ${.CURDIR}/.. ${.CURDIR}/../boot + +PROG = netboot + +SRCS = start.S boot.c prom.c prom_disp.S OSFpal.c prom_swpal.S +SRCS+= rpcc.S +SRCS+= dev_net.c conf.c devopen.c +SRCS+= if_prom.c loadfile.c getsecs.c +NOMAN= +INSTALL_STRIP= +BINMODE= 444 -BOOT_PROG = netboot BOOT_RELOC = ${PRIMARY_LOAD_ADDRESS} +HEADERSIZE_PROG = headersize -BOOT_SRCS = start.S netboot.c prom.c prom_disp.S OSFpal.c prom_swpal.S -BOOT_SRCS+= printf.c bzero.c rpcc.S +CLEANFILES+= vers.c vers.o ${PROG}.sym ${PROG}.nosym ${HEADERSIZE_PROG} -BOOT_SRCS+= dev_net.c conf.c devopen.c -BOOT_SRCS+= nfs.c rpc.c alloc.c ntohl.c htonl.c ntohs.c htons.c net.c bootp.c -BOOT_SRCS+= strlen.c dev.c bcmp.c strerror.c rarp.c read.c lseek.c -BOOT_SRCS+= in_cksum.c exit.c closeall.c arp.c strncpy.c globals.c open.c -BOOT_SRCS+= close.c ether.c netif.c +DEFNS= -DPRIMARY_BOOTBLOCK -DALPHA_BOOT_ECOFF # -DALPHA_BOOT_ELF -BOOT_SRCS+= if_prom.c loadfile.c getsecs.c +AFLAGS += -DASSEMBLER ${DEFNS} +CPPFLAGS += -I${.CURDIR}/../.. -I${S} ${DEFNS} +CFLAGS = -Werror -mno-fp-regs -BOOT_OBJS = ${BOOT_SRCS:N*.h:R:S/$/.o/g} +${PROG}.nosym: ${PROG}.sym + cp ${PROG}.sym ${PROG}.nosym + strip ${PROG}.nosym -HEADERSIZE_PROG = headersize +${PROG}: ${PROG}.nosym ${HEADERSIZE_PROG} + dd if=${PROG}.nosym of=${PROG} \ + bs=`./${HEADERSIZE_PROG} ${BOOT_RELOC} ${PROG}.nosym` skip=1 + +# no lint here (yet?) +lint: -AFLAGS += -DASSEMBLER -CPPFLAGS += -I${.CURDIR}/../../../../ \ - -I${.CURDIR}/../../../../lib/libsa \ - -I${.CURDIR}/../.. -DPRIMARY_BOOTBLOCK \ - -DALPHA_BOOT_ECOFF # -DALPHA_BOOT_ELF -CFLAGS = -Werror -mno-fp-regs -g +.include <bsd.prog.mk> -CLEANFILES+= vers.c vers.o +### find out what to use for libkern +KERN_AS= library +KERNDST= ${.CURDIR}/../libkern/${__objdir} +.include "${.CURDIR}/../libkern/Makefile.inc" +LIBKERN= ${KERNLIB} -.PATH: ${.CURDIR} ${.CURDIR}/../../../../lib/libkern ${.CURDIR}/../boot +### find out what to use for libz +Z_AS= library +ZDST= ${.CURDIR}/../libz/${__objdir} +.include "${.CURDIR}/../libz/Makefile.inc" +LIBZ= ${ZLIB} -all: ${BOOT_PROG} +### find out what to use for libsa +SA_AS= library +SADST= ${.CURDIR}/../libsa/${__objdir} +SAREL= +SA_ZLIB= yes +.include "${.CURDIR}/../libsa/Makefile.inc" +LIBSA= ${SALIB} -${BOOT_PROG}: ${BOOT_OBJS} ${HEADERSIZE_PROG} +${PROG}.sym: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} sh ${.CURDIR}/newvers.sh ${.CURDIR}/version ${COMPILE.c} vers.c - ${LD} -Ttext ${BOOT_RELOC} -N -e start -o ${BOOT_PROG}.hdr \ - ${BOOT_OBJS} vers.o -lc # XXX - size ${BOOT_PROG}.hdr - strip ${BOOT_PROG}.hdr - dd if=${BOOT_PROG}.hdr of=${BOOT_PROG} \ - bs=`./${HEADERSIZE_PROG} ${BOOT_RELOC} ${BOOT_PROG}.hdr` skip=1 - -install: - ${INSTALL} -c -o bin -g bin -m 444 ${BOOT_PROG} \ - ${DESTDIR}${BINDIR}/${BOOT_PROG} - -clean: _SUBDIRUSE - rm -f a.out [Ee]rrs mklog core *.core \ - ${BOOT_PROG} ${BOOT_OBJS} ${CLEANFILES} \ - ${BOOT_PROG}.hdr ${BOOT_PROG}.nohdr ${HEADERSIZE_PROG} - -cleandir: _SUBDIRUSE clean - -.include "${.CURDIR}/../Makefile.inc" -.include <bsd.obj.mk> -.include <bsd.dep.mk> -.include <bsd.subdir.mk> + ${LD} -Ttext ${BOOT_RELOC} -N -e start -o ${PROG}.sym \ + ${OBJS} vers.o ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} + size ${PROG}.sym diff --git a/sys/arch/alpha/stand/netboot/conf.c b/sys/arch/alpha/stand/netboot/conf.c index b40ffacf7be..119928698cc 100644 --- a/sys/arch/alpha/stand/netboot/conf.c +++ b/sys/arch/alpha/stand/netboot/conf.c @@ -1,11 +1,11 @@ -/* $OpenBSD: conf.c,v 1.1 1996/10/30 22:40:52 niklas Exp $ */ -/* $NetBSD: conf.c,v 1.2 1996/10/02 21:18:45 cgd Exp $ */ +/* $OpenBSD: conf.c,v 1.2 1997/05/05 06:01:59 millert Exp $ */ +/* $NetBSD: conf.c,v 1.4 1997/04/06 08:41:23 cgd Exp $ */ #include <sys/types.h> #include <netinet/in.h> -#include "stand.h" -#include "nfs.h" +#include <lib/libsa/stand.h> +#include <lib/libsa/nfs.h> #include "dev_net.h" struct fs_ops file_system[] = { diff --git a/sys/arch/alpha/stand/netboot/dev_net.c b/sys/arch/alpha/stand/netboot/dev_net.c index ddb84da844c..b3c533766d9 100644 --- a/sys/arch/alpha/stand/netboot/dev_net.c +++ b/sys/arch/alpha/stand/netboot/dev_net.c @@ -1,5 +1,5 @@ -/* $OpenBSD: dev_net.c,v 1.1 1996/10/30 22:40:53 niklas Exp $ */ -/* $NetBSD: dev_net.c,v 1.1 1996/09/18 20:03:07 cgd Exp $ */ +/* $OpenBSD: dev_net.c,v 1.2 1997/05/05 06:02:00 millert Exp $ */ +/* $NetBSD: dev_net.c,v 1.4 1997/04/06 08:41:24 cgd Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -57,10 +57,10 @@ #include <netinet/if_ether.h> #include <netinet/in_systm.h> -#include "stand.h" -#include "net.h" -#include "netif.h" -#include "bootparam.h" +#include <lib/libsa/stand.h> +#include <lib/libsa/net.h> +#include <lib/libsa/netif.h> +#include <lib/libsa/bootparam.h> #include "dev_net.h" extern int debug; diff --git a/sys/arch/alpha/stand/netboot/devopen.c b/sys/arch/alpha/stand/netboot/devopen.c index 601960fcef4..fd148aaa404 100644 --- a/sys/arch/alpha/stand/netboot/devopen.c +++ b/sys/arch/alpha/stand/netboot/devopen.c @@ -1,5 +1,5 @@ -/* $OpenBSD: devopen.c,v 1.1 1996/10/30 22:40:54 niklas Exp $ */ -/* $NetBSD: devopen.c,v 1.1 1996/09/18 20:03:09 cgd Exp $ */ +/* $OpenBSD: devopen.c,v 1.2 1997/05/05 06:02:00 millert Exp $ */ +/* $NetBSD: devopen.c,v 1.3 1997/04/06 08:41:25 cgd Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ * @(#)devopen.c 8.1 (Berkeley) 6/10/93 */ -#include <stand.h> +#include <lib/libsa/stand.h> /* * Decode the string 'fname', open the device and return the remaining diff --git a/sys/arch/alpha/stand/netboot/if_prom.c b/sys/arch/alpha/stand/netboot/if_prom.c index b091d49ffff..74524589f36 100644 --- a/sys/arch/alpha/stand/netboot/if_prom.c +++ b/sys/arch/alpha/stand/netboot/if_prom.c @@ -1,9 +1,9 @@ -/* $OpenBSD: if_prom.c,v 1.2 1996/11/27 19:54:55 niklas Exp $ */ -/* $NetBSD: if_prom.c,v 1.4 1996/10/02 21:18:49 cgd Exp $ */ +/* $OpenBSD: if_prom.c,v 1.3 1997/05/05 06:02:01 millert Exp $ */ +/* $NetBSD: if_prom.c,v 1.9 1997/04/06 08:41:26 cgd Exp $ */ /* - * Copyright (c) 1993 Adam Glass - * All rights reserved. + * Copyright (c) 1997 Christopher G. Demetriou. All rights reserved. + * Copyright (c) 1993 Adam Glass. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -38,11 +38,14 @@ #include <netinet/in.h> #include <netinet/in_systm.h> -#include "netif.h" -#include "include/rpb.h" -#include "include/prom.h" -#include "lib/libkern/libkern.h" -#include "lib/libsa/stand.h" +#include <include/rpb.h> +#include <include/prom.h> + +#include <lib/libkern/libkern.h> +#include <lib/libsa/netif.h> +#include <lib/libsa/stand.h> + +#include "stand/bbinfo.h" int prom_probe(); int prom_match(); @@ -60,6 +63,16 @@ struct netif_dif prom_ifs[] = { struct netif_stats prom_stats[NENTS(prom_ifs)]; +struct netbbinfo netbbinfo = { + 0xfeedbabedeadbeef, /* magic number */ + 0, /* set */ + 0, 0, 0, 0, 0, 0, /* ether address */ + 0, /* force */ + { 0, }, /* pad2 */ + 0, /* cksum */ + 0xfeedbeefdeadbabe, /* magic number */ +}; + struct netif_driver prom_netif_driver = { "prom", /* netif_bname */ prom_match, /* netif_match */ @@ -72,7 +85,7 @@ struct netif_driver prom_netif_driver = { NENTS(prom_ifs) /* netif_nifs */ }; -int netfd; +int netfd, broken_firmware; int prom_match(nif, machdep_hint) @@ -120,11 +133,17 @@ prom_get(desc, pkt, len, timeout) t = getsecs(); cc = 0; while (((getsecs() - t) < timeout) && !cc) { - ret.bits = prom_read(netfd, sizeof hate, hate, 0); + if (broken_firmware) + ret.bits = prom_read(netfd, 0, hate, 0); + else + ret.bits = prom_read(netfd, sizeof hate, hate, 0); if (ret.u.status == 0) - cc += ret.u.retval; + cc = ret.u.retval; } - cc = len; + if (broken_firmware) + cc = min(cc, len); + else + cc = len; bcopy(hate, pkt, cc); return cc; @@ -139,8 +158,28 @@ prom_init(desc, machdep_hint) { prom_return_t ret; char devname[64]; - int devlen, i; + int devlen, i, netbbinfovalid; char *enet_addr; + u_int64_t *qp, csum; + + broken_firmware = 0; + + csum = 0; + for (i = 0, qp = (u_int64_t *)&netbbinfo; + i < (sizeof netbbinfo / sizeof (u_int64_t)); i++, qp++) + csum += *qp; + netbbinfovalid = (csum == 0); + if (netbbinfovalid) + netbbinfovalid = netbbinfo.set; + +#if 0 + printf("netbbinfo "); + if (!netbbinfovalid) + printf("invalid\n"); + else + printf("valid: force = %d, ea = %s\n", netbbinfo.force, + ether_sprintf(netbbinfo.ether_addr)); +#endif ret.bits = prom_getenv(PROM_E_BOOTED_DEV, devname, sizeof(devname)); devlen = ret.u.retval; @@ -150,7 +189,7 @@ prom_init(desc, machdep_hint) for (i = 0; i < 8; i++) { enet_addr = strchr(enet_addr, ' '); if (enet_addr == NULL) { - printf("Boot device name does not contain ethernet address.\n"); + printf("boot: boot device name does not contain ethernet address.\n"); goto punt; } enet_addr++; @@ -168,7 +207,7 @@ prom_init(desc, machdep_hint) enet_addr++; if (hv == -1 || lv == -1) { - printf("Bogus ethernet address.\n"); + printf("boot: boot device name contains bogus ethernet address.\n"); goto punt; } @@ -177,20 +216,37 @@ prom_init(desc, machdep_hint) #undef dval } + if (netbbinfovalid && netbbinfo.force) { + printf("boot: using hard-coded ethernet address (forced).\n"); + bcopy(netbbinfo.ether_addr, desc->myea, sizeof desc->myea); + } + +gotit: printf("boot: ethernet address: %s\n", ether_sprintf(desc->myea)); ret.bits = prom_open(devname, devlen + 1); if (ret.u.status) { printf("prom_init: open failed: %d\n", ret.u.status); - goto punt; + goto reallypunt; } netfd = ret.u.retval; return; punt: + broken_firmware = 1; + if (netbbinfovalid) { + printf("boot: using hard-coded ethernet address.\n"); + bcopy(netbbinfo.ether_addr, desc->myea, sizeof desc->myea); + goto gotit; + } + +reallypunt: + printf("\n"); printf("Boot device name was: \"%s\"\n", devname); printf("\n"); - printf("Your firmware may be too old to network-boot OpenBSD/Alpha.\n"); + printf("Your firmware may be too old to network-boot OpenBSD/Alpha,\n"); + printf("or you might have to hard-code an ethernet address into\n"); + printf("your network boot block with setnetbootinfo(8).\n"); halt(); } diff --git a/sys/arch/alpha/stand/netboot/version b/sys/arch/alpha/stand/netboot/version index 16253a53f4d..78dd6c7767a 100644 --- a/sys/arch/alpha/stand/netboot/version +++ b/sys/arch/alpha/stand/netboot/version @@ -1,5 +1,9 @@ -$OpenBSD: version,v 1.1 1996/10/30 22:41:00 niklas Exp $ -$NetBSD: version,v 1.2 1996/10/02 21:26:17 cgd Exp $ +$OpenBSD: version,v 1.2 1997/05/05 06:02:02 millert Exp $ +$NetBSD: version,v 1.6 1997/01/23 23:10:41 cgd Exp $ -1.1 Initial version -1.2 Cleaned and polished a bit +1.1: Initial version +1.2: Cleaned and polished a bit +1.3: Use libsa and libkern rather than building the objects locally. +1.4: Allow ethernet address to be hardcoded with setnetbootinfo(8). +1.5: Search for a kernel, if none specified. +1.6: Add support for gzipped kernels. |