From bb65fdf6e0db16ea90cd5200d511fa1b9af30286 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Tue, 5 Sep 2000 22:32:31 +0000 Subject: [PATCH] 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. --- sys/boot/i386/libi386/pxe.c | 49 +++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/sys/boot/i386/libi386/pxe.c b/sys/boot/i386/libi386/pxe.c index 0357cbe3130..8391bb825a6 100644 --- a/sys/boot/i386/libi386/pxe.c +++ b/sys/boot/i386/libi386/pxe.c @@ -40,6 +40,8 @@ #include #include +#include +#include #include #include @@ -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) {