Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/stand/ofwboot Try both the BOOTPARAM and DH...



details:   https://anonhg.NetBSD.org/src/rev/5f2cd1591715
branches:  trunk
changeset: 494517:5f2cd1591715
user:      pk <pk%NetBSD.org@localhost>
date:      Fri Jul 07 12:59:16 2000 +0000

description:
Try both the BOOTPARAM and DHCP protocol (in that order as is the custom
with Sun machines).

diffstat:

 sys/arch/sparc64/stand/ofwboot/net.c |  99 +++++++++++++++++++++++++----------
 1 files changed, 70 insertions(+), 29 deletions(-)

diffs (127 lines):

diff -r 204628664c9a -r 5f2cd1591715 sys/arch/sparc64/stand/ofwboot/net.c
--- a/sys/arch/sparc64/stand/ofwboot/net.c      Fri Jul 07 12:53:29 2000 +0000
+++ b/sys/arch/sparc64/stand/ofwboot/net.c      Fri Jul 07 12:59:16 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: net.c,v 1.3 1999/05/07 16:19:28 drochner Exp $ */
+/*     $NetBSD: net.c,v 1.4 2000/07/07 12:59:16 pk Exp $       */
 
 /*
  * Copyright (C) 1995 Wolfgang Solfrank.
@@ -63,6 +63,9 @@
 
 #include <lib/libkern/libkern.h>
 
+static int net_mountroot_bootparams __P((void));
+static int net_mountroot_bootp __P((void));
+
 char   rootpath[FNAME_SIZE];
 
 static int netdev_sock = -1;
@@ -114,41 +117,79 @@
 }
 
 int
+net_mountroot_bootparams()
+{
+       /* Get our IP address.  (rarp.c) */
+       if (rarp_getipaddress(netdev_sock) == -1)
+               return (errno);
+
+       printf("Using BOOTPARAMS protocol: ");
+       printf("ip address: %s", inet_ntoa(myip));
+
+       /* Get our hostname, server IP address. */
+       if (bp_whoami(netdev_sock))
+               return (errno);
+
+       printf(", hostname: %s\n", hostname);
+
+       /* Get the root pathname. */
+       if (bp_getfile(netdev_sock, "root", &rootip, rootpath))
+               return (errno);
+
+       return (0);
+}
+
+int
+net_mountroot_bootp()
+{
+       bootp(netdev_sock);
+
+       if (myip.s_addr == 0)
+               return(ENOENT);
+
+       printf("Using BOOTP protocol: ");
+       printf("ip address: %s", inet_ntoa(myip));
+
+       if (hostname[0])
+               printf(", hostname: %s", hostname);
+       if (netmask)
+               printf(", netmask: %s", intoa(netmask));
+       if (gateip.s_addr)
+               printf(", gateway: %s", inet_ntoa(gateip));
+       printf("\n");
+
+       return (0);
+}
+
+int
 net_mountroot()
 {
+       int error;
 
-#ifdef DEBUG
+#ifdef DEBUG
        printf("net_mountroot\n");
 #endif
-       
+
        /*
-        * Get info for NFS boot: our IP address, out hostname,
+        * Get info for NFS boot: our IP address, our hostname,
         * server IP address, and our root path on the server.
-        * We use BOOTP (RFC951, RFC1532) exclusively as mandated
-        * by PowerPC Reference Platform Specification I.4.2
+        * There are two ways to do this:  The old, Sun way,
+        * and the more modern, BOOTP way. (RFC951, RFC1048)
         */
-       
-       bootp(netdev_sock);
-       
-       if (myip.s_addr == 0)
-               return ETIMEDOUT;
-       
-       printf("Using IP address: %s\n", inet_ntoa(myip));
-       
-#ifdef DEBUG
-       printf("myip: %s (%s)", hostname, inet_ntoa(myip));
-       if (gateip.s_addr)
-               printf(", gateip: %s", inet_ntoa(gateip));
-       if (netmask)
-               printf(", netmask: %s", intoa(netmask));
-       printf("\n");
-#endif
+
+       /* Historically, we've used BOOTPARAMS, so try that first */
+       error = net_mountroot_bootparams();
+       if (error != 0)
+               /* Next, try BOOTP */
+               error = net_mountroot_bootp();
+       if (error != 0)
+               return (error);
+
        printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath);
-       
-       /*
-        * Get the NFS file handle (mount).
-        */
-       if (nfs_mount(netdev_sock, rootip, rootpath) < 0)
-               return errno;
-       return 0;
+
+       /* Get the NFS file handle (mount). */
+       if (nfs_mount(netdev_sock, rootip, rootpath) != 0)
+               return (errno);
+
+       return (0);
 }



Home | Main Index | Thread Index | Old Index