Module Name: src Committed By: scole Date: Thu Aug 4 16:22:40 UTC 2016
Modified Files: src/sys/arch/ia64/stand/common: Makefile.inc dev_net.c dev_net.h src/sys/arch/ia64/stand/efi/libefi: Makefile efiboot.h efinet.c src/sys/arch/ia64/stand/ia64: Makefile.booters src/sys/arch/ia64/stand/ia64/efi: conf.c main.c src/sys/arch/ia64/stand/ia64/ski: conf.c time.c Log Message: PR port-ia64/49717 Minimal changes needed to add nfs netboot support To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/ia64/stand/common/Makefile.inc \ src/sys/arch/ia64/stand/common/dev_net.h cvs rdiff -u -r1.10 -r1.11 src/sys/arch/ia64/stand/common/dev_net.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/ia64/stand/efi/libefi/Makefile cvs rdiff -u -r1.2 -r1.3 src/sys/arch/ia64/stand/efi/libefi/efiboot.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/ia64/stand/efi/libefi/efinet.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/ia64/stand/ia64/Makefile.booters cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ia64/stand/ia64/efi/conf.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/ia64/stand/ia64/efi/main.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/ia64/stand/ia64/ski/conf.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ia64/stand/ia64/ski/time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/ia64/stand/common/Makefile.inc diff -u src/sys/arch/ia64/stand/common/Makefile.inc:1.2 src/sys/arch/ia64/stand/common/Makefile.inc:1.3 --- src/sys/arch/ia64/stand/common/Makefile.inc:1.2 Sun Jul 2 17:28:11 2006 +++ src/sys/arch/ia64/stand/common/Makefile.inc Thu Aug 4 16:22:40 2016 @@ -1,6 +1,6 @@ -# $FreeBSD$ +# $NetBSD: Makefile.inc,v 1.3 2016/08/04 16:22:40 scole Exp $ -SRCS+= commands.c console.c devopen.c interp.c boot.c #XXX: Remove bcache.c +SRCS+= commands.c console.c devopen.c interp.c boot.c dev_net.c SRCS+= interp_backslash.c interp_parse.c ls.c misc.c SRCS+= panic.c calloc.c readdir.c pager.c environment.c fileload.c SRCS+= getopt.c gets.c strdup.c strtol.c strspn.c @@ -9,7 +9,8 @@ SRCS+= getopt.c gets.c strdup.c strtol. SRCS+= load_elf64.c .endif -.if defined(LOADER_NET_SUPPORT) +# XXX might need this for different loaders later +#.if defined(LOADER_NET_SUPPORT) #SRCS+= dev_net.c -.endif +#.endif Index: src/sys/arch/ia64/stand/common/dev_net.h diff -u src/sys/arch/ia64/stand/common/dev_net.h:1.2 src/sys/arch/ia64/stand/common/dev_net.h:1.3 --- src/sys/arch/ia64/stand/common/dev_net.h:1.2 Sat Apr 22 07:58:53 2006 +++ src/sys/arch/ia64/stand/common/dev_net.h Thu Aug 4 16:22:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: dev_net.h,v 1.2 2006/04/22 07:58:53 cherry Exp $ */ +/* $NetBSD: dev_net.h,v 1.3 2016/08/04 16:22:40 scole Exp $ */ /*- * Copyright (c) 1998 Doug Rabson <d...@freebsd.org> @@ -28,5 +28,7 @@ * $FreeBSD: src/sys/boot/common/dev_net.h,v 1.2 1999/08/28 00:39:46 peter Exp $ */ -extern struct devsw netdev; - +int net_open(struct open_file *, ...); +int net_close(struct open_file *); +int net_ioctl(struct open_file *, u_long, void *); +int net_strategy(void *, int , daddr_t , size_t, void *, size_t *); Index: src/sys/arch/ia64/stand/common/dev_net.c diff -u src/sys/arch/ia64/stand/common/dev_net.c:1.10 src/sys/arch/ia64/stand/common/dev_net.c:1.11 --- src/sys/arch/ia64/stand/common/dev_net.c:1.10 Mon Feb 1 17:38:31 2016 +++ src/sys/arch/ia64/stand/common/dev_net.c Thu Aug 4 16:22:40 2016 @@ -1,5 +1,5 @@ /* - * $NetBSD: dev_net.c,v 1.10 2016/02/01 17:38:31 christos Exp $ + * $NetBSD: dev_net.c,v 1.11 2016/08/04 16:22:40 scole Exp $ */ /*- @@ -53,17 +53,15 @@ */ #include <sys/param.h> -#include <sys/socket.h> -#include <net/if.h> -#include <netinet/in.h> -#include <netinet/in_systm.h> - -#include <stand.h> -#include <string.h> -#include <net.h> -#include <netif.h> -#include <bootp.h> -#include <bootparam.h> + +#include <lib/libsa/stand.h> +#include <lib/libsa/net.h> +#include <lib/libsa/bootparam.h> +#include <lib/libsa/loadfile.h> +#include <lib/libsa/netif.h> +#include <lib/libsa/nfs.h> +#include <lib/libsa/bootp.h> +#include <lib/libkern/libkern.h> #include "dev_net.h" #include "bootstrap.h" @@ -73,31 +71,8 @@ int debug = 0; static int netdev_sock = -1; static int netdev_opens; -static int net_init(void); -static int net_open(struct open_file *, ...); -static int net_close(struct open_file *); -static int net_strategy(); -static void net_print(int); - static int net_getparams(int sock); -struct devsw netdev = { - "net", - DEVT_NET, - net_init, - net_strategy, - net_open, - net_close, - noioctl, - net_print -}; - -int -net_init(void) -{ - return 0; -} - /* * Called by devopen after it sets f->f_dev to our devsw entry. * This opens the low-level device and sets f->f_devdata. @@ -136,6 +111,23 @@ net_open(struct open_file *f, ...) return (error); } } + if (debug) + printf("net_open: got rootip %s\n", inet_ntoa(rootip)); + + /* + * Get the NFS file handle (mount). + */ + error = nfs_mount(netdev_sock, rootip, rootpath); + if (error) { + netif_close(netdev_sock); + netdev_sock = -1; + printf("net_open: error with nfs mount 0x%x\n", error); + return error; + } + + if (debug) + printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath); + netdev_opens++; } netdev_opens++; @@ -172,7 +164,13 @@ net_close(struct open_file *f) } int -net_strategy(void) +net_strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize) +{ + return EIO; +} + +int +net_ioctl(struct open_file *f, u_long cmd, void *data) { return EIO; } @@ -194,13 +192,13 @@ net_strategy(void) int try_bootp = 1; #endif -extern n_long ip_convertaddr(char *p); - static int net_getparams(int sock) { char buf[MAXHOSTNAMELEN]; char temp[FNAME_SIZE]; + char num[8]; + struct iodesc *d; int i; n_long smask; @@ -213,7 +211,7 @@ net_getparams(int sock) * use RARP and RPC/bootparam (the Sun way) to get them. */ if (try_bootp) - bootp(sock, BOOTP_NONE); + bootp(sock); if (myip.s_addr != 0) goto exit; if (debug) @@ -245,14 +243,16 @@ net_getparams(int sock) gateip.s_addr = 0; if (bp_getfile(sock, "gateway", &gateip, buf) == 0) { /* Got it! Parse the netmask. */ - smask = ip_convertaddr(buf); + smask = inet_addr(buf); } if (smask) { netmask = smask; - printf("net_open: subnet mask: %s\n", intoa(netmask)); + if (debug) + printf("net_open: subnet mask: %s\n", intoa(netmask)); } if (gateip.s_addr) - printf("net_open: net gateway: %s\n", inet_ntoa(gateip)); + if (debug) + printf("net_open: net gateway: %s\n", inet_ntoa(gateip)); /* Get the root server and pathname. */ if (bp_getfile(sock, "root", &rootip, rootpath)) { @@ -275,11 +275,30 @@ net_getparams(int sock) memcpy(&temp[0], &rootpath[i], strlen(&rootpath[i])+1); memcpy(&rootpath[0], &temp[0], strlen(&rootpath[i])+1); } - printf("net_open: server addr: %s\n", inet_ntoa(rootip)); - printf("net_open: server path: %s\n", rootpath); + if (debug) { + printf("net_open: server addr: %s\n", inet_ntoa(rootip)); + printf("net_open: server path: %s\n", rootpath); + } + + /* do equivalent of + * snprintf(temp, sizeof(temp), "%6D", d->myea, ":"); + * in lame way since snprintf seems to understand "%x", but not "%x:%x" + */ d = socktodesc(sock); - snprintf(temp, sizeof(temp), "%6D", d->myea, ":"); + memset(temp, '\0', sizeof(temp)); + + for (i = 0; i < ETHER_ADDR_LEN; i++) { + if (d->myea[i] < 0x10) + strncat(temp, "0", 1); + + snprintf(num, sizeof(num), "%x", d->myea[i]); + strncat(temp, num, 2); + + if (i < ETHER_ADDR_LEN-1) + strncat(temp, ":", 1); + } + setenv("boot.netif.ip", inet_ntoa(myip), 1); setenv("boot.netif.netmask", intoa(netmask), 1); setenv("boot.netif.gateway", inet_ntoa(gateip), 1); @@ -289,9 +308,3 @@ net_getparams(int sock) return (0); } - -static void -net_print(int verbose) -{ - return; -} Index: src/sys/arch/ia64/stand/efi/libefi/Makefile diff -u src/sys/arch/ia64/stand/efi/libefi/Makefile:1.5 src/sys/arch/ia64/stand/efi/libefi/Makefile:1.6 --- src/sys/arch/ia64/stand/efi/libefi/Makefile:1.5 Tue Mar 22 08:25:22 2016 +++ src/sys/arch/ia64/stand/efi/libefi/Makefile Thu Aug 4 16:22:40 2016 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.5 2016/03/22 08:25:22 mrg Exp $ +# $NetBSD: Makefile,v 1.6 2016/08/04 16:22:40 scole Exp $ S?= ${.CURDIR}/../../../../../ @@ -8,8 +8,6 @@ LIB= efi NOPROFILE=# defined INTERNALLIB=# defined -EFI_INCLUDE_NET?= no - CPPFLAGS= -I${EFICPPFLAGS} ${EFIMISCCPPFLAGS} CPPFLAGS+= -I${.CURDIR}/../include CPPFLAGS+= -I${.CURDIR}/../include/${MACHINE_ARCH} @@ -18,16 +16,12 @@ CPPFLAGS+= -I${.CURDIR}/../include/${MAC CPPFLAGS+= -I${.CURDIR}/../../common SRCS= copy.c delay.c efi.c efi_console.c devicename.c bootinfo.c -SRCS+= time.c efifs.c efi_console.c module.c exec.c #efinet.c +SRCS+= time.c efifs.c efi_console.c module.c exec.c efinet.c .if ${MACHINE_ARCH} == "ia64" SRCS+= efifpswa.c pal.S .endif -.if (${EFI_INCLUDE_NET} == "yes") -SRCS+= efinet.c #etc. -.endif - .include <bsd.own.mk> .undef DESTDIR .include <bsd.lib.mk> Index: src/sys/arch/ia64/stand/efi/libefi/efiboot.h diff -u src/sys/arch/ia64/stand/efi/libefi/efiboot.h:1.2 src/sys/arch/ia64/stand/efi/libefi/efiboot.h:1.3 --- src/sys/arch/ia64/stand/efi/libefi/efiboot.h:1.2 Sat Apr 22 07:58:53 2006 +++ src/sys/arch/ia64/stand/efi/libefi/efiboot.h Thu Aug 4 16:22:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.h,v 1.2 2006/04/22 07:58:53 cherry Exp $ */ +/* $NetBSD: efiboot.h,v 1.3 2016/08/04 16:22:40 scole Exp $ */ /*- * Copyright (c) 1996 @@ -68,7 +68,7 @@ extern struct devsw devsw[]; extern struct netif_driver efi_net; /* Find EFI network resources */ -/*extern void efinet_init_driver(void); XXX should get this running once we're off the mark */ +extern void efinet_init_driver(void); /* Map handles to units */ int efifs_get_unit(EFI_HANDLE); Index: src/sys/arch/ia64/stand/efi/libefi/efinet.c diff -u src/sys/arch/ia64/stand/efi/libefi/efinet.c:1.6 src/sys/arch/ia64/stand/efi/libefi/efinet.c:1.7 --- src/sys/arch/ia64/stand/efi/libefi/efinet.c:1.6 Mon Oct 26 19:16:56 2009 +++ src/sys/arch/ia64/stand/efi/libefi/efinet.c Thu Aug 4 16:22:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: efinet.c,v 1.6 2009/10/26 19:16:56 cegger Exp $ */ +/* $NetBSD: efinet.c,v 1.7 2016/08/04 16:22:40 scole Exp $ */ /*- * Copyright (c) 2001 Doug Rabson @@ -30,18 +30,40 @@ /* __FBSDID("$FreeBSD: src/sys/boot/efi/libefi/efinet.c,v 1.6 2004/01/04 23:28:16 obrien Exp $"); */ #include <sys/param.h> -#include <netinet/in.h> -#include <netinet/in_systm.h> #include <lib/libsa/stand.h> -#include <net.h> -#include <netif.h> +#include <lib/libsa/loadfile.h> +#include <lib/libsa/net.h> +#include <lib/libsa/netif.h> + +#ifdef EFINET_DEBUG +#include <lib/libsa/ether_sprintf.c> +#endif #include <efi.h> #include <efilib.h> extern struct netif_driver efi_net; +int efinet_match(struct netif *, void *); +int efinet_probe(struct netif *, void *); +void efinet_init(struct iodesc *, void *); +int efinet_get(struct iodesc *, void *, size_t, saseconds_t); +int efinet_put(struct iodesc *, void *, size_t); +void efinet_end(struct netif *); + +struct netif_driver efi_net = { + "net", /* netif_bname */ + efinet_match, /* netif_match */ + efinet_probe, /* netif_probe */ + efinet_init, /* netif_init */ + efinet_get, /* netif_get */ + efinet_put, /* netif_put */ + efinet_end, /* netif_end */ + 0, /* netif_ifs */ + 0 /* netif_nifs */ +}; + #ifdef EFINET_DEBUG static void dump_mode(EFI_SIMPLE_NETWORK_MODE *mode) @@ -120,7 +142,7 @@ efinet_put(struct iodesc *desc, void *pk int -efinet_get(struct iodesc *desc, void *pkt, size_t len, time_t timeout) +efinet_get(struct iodesc *desc, void *pkt, size_t len, saseconds_t timeout) { struct netif *nif = desc->io_netif; EFI_SIMPLE_NETWORK *net; @@ -223,7 +245,7 @@ efinet_init_driver(void) handles = (EFI_HANDLE *) alloc(sz); status = BS->LocateHandle(ByProtocol, &netid, 0, &sz, handles); if (EFI_ERROR(status)) { - free(handles, sz); + free(handles); return; } @@ -255,16 +277,3 @@ efinet_end(struct netif *nif) net->Shutdown(net); } - -struct netif_driver efi_net = { - "net", /* netif_bname */ - efinet_match, /* netif_match */ - efinet_probe, /* netif_probe */ - efinet_init, /* netif_init */ - efinet_get, /* netif_get */ - efinet_put, /* netif_put */ - efinet_end, /* netif_end */ - 0, /* netif_ifs */ - 0 /* netif_nifs */ -}; - Index: src/sys/arch/ia64/stand/ia64/Makefile.booters diff -u src/sys/arch/ia64/stand/ia64/Makefile.booters:1.6 src/sys/arch/ia64/stand/ia64/Makefile.booters:1.7 --- src/sys/arch/ia64/stand/ia64/Makefile.booters:1.6 Sun Jan 12 15:26:29 2014 +++ src/sys/arch/ia64/stand/ia64/Makefile.booters Thu Aug 4 16:22:40 2016 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.booters,v 1.6 2014/01/12 15:26:29 tsutsui Exp $ +# $NetBSD: Makefile.booters,v 1.7 2016/08/04 16:22:40 scole Exp $ .include <bsd.own.mk> .include <bsd.klinks.mk> @@ -37,7 +37,7 @@ LIBZ= ${ZLIB} ### find out what to use for libsa SA_AS= library -SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" "SA_INCLUDE_NET=no" +SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" "SA_INCLUDE_NET=yes" .include "${S}/lib/libsa/Makefile.inc" LIBSA= ${SALIB} Index: src/sys/arch/ia64/stand/ia64/efi/conf.c diff -u src/sys/arch/ia64/stand/ia64/efi/conf.c:1.3 src/sys/arch/ia64/stand/ia64/efi/conf.c:1.4 --- src/sys/arch/ia64/stand/ia64/efi/conf.c:1.3 Mon Jul 20 04:59:04 2009 +++ src/sys/arch/ia64/stand/ia64/efi/conf.c Thu Aug 4 16:22:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.3 2009/07/20 04:59:04 kiyohara Exp $ */ +/* $NetBSD: conf.c,v 1.4 2016/08/04 16:22:40 scole Exp $ */ /* * Copyright (c) 2004 @@ -12,6 +12,12 @@ * 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 for the NetBSD Project + * by Matthias Drochner. + * 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 @@ -27,13 +33,14 @@ #include <sys/cdefs.h> +/* __FBSDID("$FreeBSD: releng/10.1/sys/boot/ia64/efi/conf.c 219691 2011-03-16 03:53:18Z marcel $"); */ #include <sys/types.h> #include <lib/libsa/stand.h> +#include <lib/libsa/net.h> #include <lib/libsa/loadfile.h> - -#include <bootstrap.h> +#include <lib/libsa/nfs.h> #include <efi.h> #include <efilib.h> @@ -44,13 +51,23 @@ #include "dev_net.h" struct devsw devsw[] = { - {"disk", efifs_dev_strategy, efifs_dev_open, efifs_dev_close, noioctl}, + {"disk", efifs_dev_strategy, efifs_dev_open, efifs_dev_close, noioctl}, + { "net", net_strategy, net_open, net_close, net_ioctl }, }; int ndevs = sizeof(devsw) / sizeof(struct devsw); +extern struct netif_driver efi_net; + +struct netif_driver *netif_drivers[] = { + &efi_net +}; + +int n_netif_drivers = (sizeof(netif_drivers) / sizeof(netif_drivers[0])); + struct fs_ops file_system[] = { - FS_OPS(efifs), + FS_OPS(efifs), + FS_OPS(nfs), }; int nfsys = sizeof(file_system) / sizeof(struct fs_ops); Index: src/sys/arch/ia64/stand/ia64/efi/main.c diff -u src/sys/arch/ia64/stand/ia64/efi/main.c:1.9 src/sys/arch/ia64/stand/ia64/efi/main.c:1.10 --- src/sys/arch/ia64/stand/ia64/efi/main.c:1.9 Tue Mar 25 18:35:33 2014 +++ src/sys/arch/ia64/stand/ia64/efi/main.c Thu Aug 4 16:22:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.9 2014/03/25 18:35:33 christos Exp $ */ +/* $NetBSD: main.c,v 1.10 2016/08/04 16:22:40 scole Exp $ */ /*- * Copyright (c) 1998 Michael Smith <msm...@freebsd.org> @@ -123,8 +123,8 @@ main(int argc, CHAR16 *argv[]) find_pal_proc(); efifs_dev_init(); - - /* efinet_init_driver(); XXX enable net boot. */ + + efinet_init_driver(); /* Get our loaded image protocol interface structure. */ BS->HandleProtocol(IH, &imgid, (VOID**)&img); @@ -147,6 +147,8 @@ main(int argc, CHAR16 *argv[]) currdev.d_kind.netif.unit = 0; /* XXX */ currdev.d_type = DEVT_NET; + /* XXX overwrite disk ops with nfs ops */ + memcpy(&file_system[0], &file_system[1], sizeof(struct fs_ops)); } Index: src/sys/arch/ia64/stand/ia64/ski/conf.c diff -u src/sys/arch/ia64/stand/ia64/ski/conf.c:1.2 src/sys/arch/ia64/stand/ia64/ski/conf.c:1.3 --- src/sys/arch/ia64/stand/ia64/ski/conf.c:1.2 Mon Jul 20 04:59:04 2009 +++ src/sys/arch/ia64/stand/ia64/ski/conf.c Thu Aug 4 16:22:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.2 2009/07/20 04:59:04 kiyohara Exp $ */ +/* $NetBSD: conf.c,v 1.3 2016/08/04 16:22:40 scole Exp $ */ /*- * Copyright (c) 1997 @@ -30,7 +30,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $NetBSD: conf.c,v 1.2 2009/07/20 04:59:04 kiyohara Exp $ + * $NetBSD: conf.c,v 1.3 2016/08/04 16:22:40 scole Exp $ */ #include <sys/cdefs.h> @@ -76,6 +76,10 @@ struct devsw devsw[] = { int ndevs = sizeof(devsw) / sizeof(struct devsw); +/* XXX fix netif for ski if needed */ +struct netif_drvier *netif_drivers[] = {}; +int n_netif_drivers = 0; + struct fs_ops file_system[] = { FS_OPS(skifs), }; Index: src/sys/arch/ia64/stand/ia64/ski/time.c diff -u src/sys/arch/ia64/stand/ia64/ski/time.c:1.3 src/sys/arch/ia64/stand/ia64/ski/time.c:1.4 --- src/sys/arch/ia64/stand/ia64/ski/time.c:1.3 Mon Jul 20 04:59:04 2009 +++ src/sys/arch/ia64/stand/ia64/ski/time.c Thu Aug 4 16:22:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: time.c,v 1.3 2009/07/20 04:59:04 kiyohara Exp $ */ +/* $NetBSD: time.c,v 1.4 2016/08/04 16:22:40 scole Exp $ */ /*- * Copyright (c) 1999, 2000 @@ -176,3 +176,9 @@ time(time_t *tloc) return *tloc = EfiTimeToUnixTime(&time); } + +time_t +getsecs(void) +{ + return time(0); +}