diff options
author | msmith <msmith@FreeBSD.org> | 2000-09-05 22:32:31 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 2000-09-05 22:32:31 +0000 |
commit | 9bf5401188bcf0e6e8572d38f8aa3cc3c341d07c (patch) | |
tree | 1cae3371d06414de768e7faecef1717f25b6d972 /sys/boot | |
parent | 7de3089b6a7f9d9fbffbace0dd339801cae61e73 (diff) | |
download | FreeBSD-src-9bf5401188bcf0e6e8572d38f8aa3cc3c341d07c.zip FreeBSD-src-9bf5401188bcf0e6e8572d38f8aa3cc3c341d07c.tar.gz |
Export the salient configuration items in a non-pxe-specific namespace
to allow commonality between varying platforms. This is a step
towards parsing the diskless configuration information with MI code
inside the kernel.
Export the interface hardware address to the kernel, so that it is possible
to determine the boot interface with certainty.
Export the NFS filehandle for the root mount to the kernel, so that the
kernel does not need to perform a mount RPC call.
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/i386/libi386/pxe.c | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/sys/boot/i386/libi386/pxe.c b/sys/boot/i386/libi386/pxe.c index 0357cbe..8391bb8 100644 --- a/sys/boot/i386/libi386/pxe.c +++ b/sys/boot/i386/libi386/pxe.c @@ -40,6 +40,8 @@ #include <net.h> #include <netif.h> +#include <nfsv2.h> +#include <iodesc.h> #include <bootp.h> #include <bootstrap.h> @@ -76,6 +78,7 @@ static int pxe_open(struct open_file *f, ...); static int pxe_close(struct open_file *f); static void pxe_print(int verbose); static void pxe_cleanup(void); +static void pxe_setnfshandle(char *rootpath); static void pxe_perror(int error); static int pxe_netif_match(struct netif *nif, void *machdep_hint); @@ -295,11 +298,15 @@ pxe_open(struct open_file *f, ...) printf("pxe_open: server path: %s\n", rootpath); printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip)); - setenv("boot.pxe.server_addr", inet_ntoa(rootip), 1); - setenv("boot.pxe.rootpath", rootpath, 1); - setenv("boot.pxe.gateway", inet_ntoa(gateip), 1); - setenv("boot.pxe.myip", inet_ntoa(myip), 1); - setenv("boot.pxe.netmask", intoa(netmask), 1); + setenv("boot.netif.ip", inet_ntoa(myip), 1); + setenv("boot.netif.netmask", intoa(netmask), 1); + setenv("boot.netif.gateway", inet_ntoa(gateip), 1); + if (bootplayer.Hardware == ETHER_TYPE) { + sprintf(temp, "%6D", bootplayer.CAddr, ":"); + setenv("boot.netif.hwaddr", temp, 1); + } + setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); + setenv("boot.nfsroot.path", rootpath, 1); } } pxe_opens++; @@ -326,7 +333,11 @@ pxe_close(struct open_file *f) if (pxe_opens > 0) return(0); + /* get an NFS filehandle for our root filesystem */ + pxe_setnfshandle(rootpath); + if (pxe_sock >= 0) { + #ifdef PXE_DEBUG if (pxe_debug) printf("pxe_close: calling netif_close()\n"); @@ -390,6 +401,34 @@ pxe_perror(int err) return; } +/* + * Reach inside the libstand NFS code and dig out an NFS handle + * for the root filesystem. + */ +struct nfs_iodesc { + struct iodesc *iodesc; + off_t off; + u_char fh[NFS_FHSIZE]; + /* structure truncated here */ +}; +extern struct nfs_iodesc nfs_root_node; + +static void +pxe_setnfshandle(char *rootpath) +{ + int i; + u_char *fh; + char buf[2 * NFS_FHSIZE + 3], *cp; + + fh = &nfs_root_node.fh[0]; + buf[0] = 'X'; + cp = &buf[1]; + for (i = 0; i < NFS_FHSIZE; i++, cp += 2) + sprintf(cp, "%02x", fh[i]); + sprintf(cp, "X"); + setenv("boot.nfsroot.nfshandle", buf, 1); +} + void pxenv_call(int func) { |