summaryrefslogtreecommitdiffstats
path: root/sys/boot/i386
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2014-07-27 16:12:51 +0000
committermarcel <marcel@FreeBSD.org>2014-07-27 16:12:51 +0000
commit42335f4752fa57cf15318a09d3cfc118bf559b08 (patch)
tree3fdb72c26ee68a70ec6f2ed8fd97f6d03fbeb233 /sys/boot/i386
parent32661c5bec8b8ab836158f7f46314c35aa7e5fd5 (diff)
downloadFreeBSD-src-42335f4752fa57cf15318a09d3cfc118bf559b08.zip
FreeBSD-src-42335f4752fa57cf15318a09d3cfc118bf559b08.tar.gz
Give loaders more control over the Forth initialization process. In
particular, allow loaders to define the name of the RC script the interpreter needs to use. Use this new-found control to have the PXE loader (when compiled with TFTP support and not NFS support) read from ${bootfile}.4th, where ${bootfile} is the name of the file fetched by the PXE firmware. The normal startup process involves reading the following files: 1. /boot/boot.4th 2. /boot/loader.rc or alternatively /boot/boot.conf When these come from a FreeBSD-defined file system, this is all good. But when we boot over the network, subdirectories and fixed file names are often painful to administrators and there's really no way for them to change the behaviour of the loader. Obtained from: Juniper Networks, Inc.
Diffstat (limited to 'sys/boot/i386')
-rw-r--r--sys/boot/i386/libi386/libi386.h1
-rw-r--r--sys/boot/i386/libi386/pxe.c23
-rw-r--r--sys/boot/i386/loader/main.c7
3 files changed, 30 insertions, 1 deletions
diff --git a/sys/boot/i386/libi386/libi386.h b/sys/boot/i386/libi386/libi386.h
index f7dc379..24d6f56 100644
--- a/sys/boot/i386/libi386/libi386.h
+++ b/sys/boot/i386/libi386/libi386.h
@@ -121,4 +121,5 @@ int bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip,
vm_offset_t *modulep, vm_offset_t *kernend);
int bi_load64(char *args, vm_offset_t *modulep, vm_offset_t *kernend);
+char *pxe_default_rc(void);
void pxe_enable(void *pxeinfo);
diff --git a/sys/boot/i386/libi386/pxe.c b/sys/boot/i386/libi386/pxe.c
index 49814dd..93969c2 100644
--- a/sys/boot/i386/libi386/pxe.c
+++ b/sys/boot/i386/libi386/pxe.c
@@ -694,3 +694,26 @@ readudp(struct iodesc *h, void *pkt, size_t len, time_t timeout)
uh->uh_sport = udpread_p->s_port;
return udpread_p->buffer_size;
}
+
+char *
+pxe_default_rc(void)
+{
+ char *rc;
+ size_t count, rcsz;
+
+ /* XXX It may not be a good idea to modify the PXE boot file. */
+ rc = (char *)bootplayer.bootfile;
+ rcsz = sizeof(bootplayer.bootfile);
+
+ /* Ignore how we define rc and rcsz above -- it can change. */
+ if (rcsz < 6)
+ return (NULL);
+ if (*rc == '\0') {
+ strncpy(rc, "pxeboot", rcsz);
+ rc[rcsz - 1] = '\0';
+ }
+ count = strlen(rc);
+ strncat(rc, ".4th", rcsz - count - 1);
+ printf("PXE: loading Forth from %s\n", rc);
+ return (rc);
+}
diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c
index 84ae713..13f9335 100644
--- a/sys/boot/i386/loader/main.c
+++ b/sys/boot/i386/loader/main.c
@@ -192,7 +192,12 @@ main(void)
bios_getsmap();
- interact(); /* doesn't return */
+#ifdef LOADER_TFTP_SUPPORT
+ if (kargs->bootflags & KARGS_FLAGS_PXE)
+ interact(pxe_default_rc());
+ else
+#endif
+ interact(NULL);
/* if we ever get here, it is an error */
return (1);
OpenPOWER on IntegriCloud