Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/ia64/stand PR port-ia64/49717



details:   https://anonhg.NetBSD.org/src/rev/520e05412d6a
branches:  trunk
changeset: 346831:520e05412d6a
user:      scole <scole%NetBSD.org@localhost>
date:      Thu Aug 04 16:22:40 2016 +0000

description:
PR port-ia64/49717

Minimal changes needed to add nfs netboot support

diffstat:

 sys/arch/ia64/stand/common/Makefile.inc   |    9 +-
 sys/arch/ia64/stand/common/dev_net.c      |  113 ++++++++++++++++-------------
 sys/arch/ia64/stand/common/dev_net.h      |    8 +-
 sys/arch/ia64/stand/efi/libefi/Makefile   |   10 +--
 sys/arch/ia64/stand/efi/libefi/efiboot.h  |    4 +-
 sys/arch/ia64/stand/efi/libefi/efinet.c   |   49 +++++++-----
 sys/arch/ia64/stand/ia64/Makefile.booters |    4 +-
 sys/arch/ia64/stand/ia64/efi/conf.c       |   27 +++++-
 sys/arch/ia64/stand/ia64/efi/main.c       |    8 +-
 sys/arch/ia64/stand/ia64/ski/conf.c       |    8 +-
 sys/arch/ia64/stand/ia64/ski/time.c       |    8 +-
 11 files changed, 148 insertions(+), 100 deletions(-)

diffs (truncated from 541 to 300 lines):

diff -r 790d54210742 -r 520e05412d6a sys/arch/ia64/stand/common/Makefile.inc
--- a/sys/arch/ia64/stand/common/Makefile.inc   Thu Aug 04 14:08:23 2016 +0000
+++ b/sys/arch/ia64/stand/common/Makefile.inc   Thu Aug 04 16:22:40 2016 +0000
@@ -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+= 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
 
diff -r 790d54210742 -r 520e05412d6a sys/arch/ia64/stand/common/dev_net.c
--- a/sys/arch/ia64/stand/common/dev_net.c      Thu Aug 04 14:08:23 2016 +0000
+++ b/sys/arch/ia64/stand/common/dev_net.c      Thu Aug 04 16:22:40 2016 +0000
@@ -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 @@
 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 @@
                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 @@
 }
 
 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 @@
 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 @@
      * 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 @@
     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 @@
            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 @@
 
     return (0);
 }
-
-static void
-net_print(int verbose)
-{
-    return;
-}
diff -r 790d54210742 -r 520e05412d6a sys/arch/ia64/stand/common/dev_net.h
--- a/sys/arch/ia64/stand/common/dev_net.h      Thu Aug 04 14:08:23 2016 +0000
+++ b/sys/arch/ia64/stand/common/dev_net.h      Thu Aug 04 16:22:40 2016 +0000
@@ -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 <dfr%freebsd.org@localhost>
@@ -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 *);
diff -r 790d54210742 -r 520e05412d6a sys/arch/ia64/stand/efi/libefi/Makefile
--- a/sys/arch/ia64/stand/efi/libefi/Makefile   Thu Aug 04 14:08:23 2016 +0000
+++ b/sys/arch/ia64/stand/efi/libefi/Makefile   Thu Aug 04 16:22:40 2016 +0000
@@ -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 @@
 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}/../../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>
diff -r 790d54210742 -r 520e05412d6a sys/arch/ia64/stand/efi/libefi/efiboot.h
--- a/sys/arch/ia64/stand/efi/libefi/efiboot.h  Thu Aug 04 14:08:23 2016 +0000
+++ b/sys/arch/ia64/stand/efi/libefi/efiboot.h  Thu Aug 04 16:22:40 2016 +0000
@@ -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 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);
diff -r 790d54210742 -r 520e05412d6a sys/arch/ia64/stand/efi/libefi/efinet.c
--- a/sys/arch/ia64/stand/efi/libefi/efinet.c   Thu Aug 04 14:08:23 2016 +0000
+++ b/sys/arch/ia64/stand/efi/libefi/efinet.c   Thu Aug 04 16:22:40 2016 +0000
@@ -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 $ */
 
 /*-



Home | Main Index | Thread Index | Old Index