summaryrefslogtreecommitdiffstats
path: root/sys/boot/i386
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2014-08-19 06:50:54 +0000
committersjg <sjg@FreeBSD.org>2014-08-19 06:50:54 +0000
commitd7cd1d425cc1ea9451fa235e3af9b6625c3e0de2 (patch)
treeb04f4bd7cd887f50e7d98af35f46b9834ff86c80 /sys/boot/i386
parent3c8e37b1d04827f33c0c9a7594bd1b1ef7cdb3d3 (diff)
parent4fbde208c6460d576f64d6dc3cdc6cab085a4283 (diff)
downloadFreeBSD-src-d7cd1d425cc1ea9451fa235e3af9b6625c3e0de2.zip
FreeBSD-src-d7cd1d425cc1ea9451fa235e3af9b6625c3e0de2.tar.gz
Merge head from 7/28
Diffstat (limited to 'sys/boot/i386')
-rw-r--r--sys/boot/i386/boot2/Makefile2
-rw-r--r--sys/boot/i386/boot2/boot2.c33
-rw-r--r--sys/boot/i386/btx/btx/Makefile2
-rw-r--r--sys/boot/i386/btx/btxldr/Makefile2
-rw-r--r--sys/boot/i386/btx/lib/Makefile2
-rw-r--r--sys/boot/i386/gptboot/gptboot.84
-rw-r--r--sys/boot/i386/libi386/Makefile3
-rw-r--r--sys/boot/i386/libi386/amd64_tramp.S2
-rw-r--r--sys/boot/i386/libi386/libi386.h1
-rw-r--r--sys/boot/i386/libi386/pxe.c42
-rw-r--r--sys/boot/i386/loader/Makefile4
-rw-r--r--sys/boot/i386/loader/main.c7
12 files changed, 88 insertions, 16 deletions
diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
index fa8c29d..e52060d 100644
--- a/sys/boot/i386/boot2/Makefile
+++ b/sys/boot/i386/boot2/Makefile
@@ -22,6 +22,8 @@ BOOT2_UFS?= UFS1_AND_UFS2
#BOOT2_UFS?= UFS2_ONLY
#BOOT2_UFS?= UFS1_ONLY
+NO_PIE= yes
+
CFLAGS= -Os \
-fomit-frame-pointer \
-mrtd \
diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c
index 6998026..cd384e5 100644
--- a/sys/boot/i386/boot2/boot2.c
+++ b/sys/boot/i386/boot2/boot2.c
@@ -34,9 +34,22 @@ __FBSDID("$FreeBSD$");
#include "boot2.h"
#include "lib.h"
+/* Define to 0 to omit serial support */
+#ifndef SERIAL
+#define SERIAL 1
+#endif
+
#define IO_KEYBOARD 1
#define IO_SERIAL 2
+#if SERIAL
+#define DO_KBD (ioctrl & IO_KEYBOARD)
+#define DO_SIO (ioctrl & IO_SERIAL)
+#else
+#define DO_KBD (1)
+#define DO_SIO (0)
+#endif
+
#define SECOND 18 /* Circa that many ticks in a second. */
#define RBX_ASKNAME 0x0 /* -a */
@@ -131,9 +144,11 @@ static struct dsk {
static char cmd[512], cmddup[512], knamebuf[1024];
static const char *kname;
static uint32_t opts;
-static int comspeed = SIOSPD;
static struct bootinfo bootinfo;
+#if SERIAL
+static int comspeed = SIOSPD;
static uint8_t ioctrl = IO_KEYBOARD;
+#endif
void exit(int);
static void load(void);
@@ -276,7 +291,7 @@ main(void)
"boot: ",
dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
'a' + dsk.part, kname);
- if (ioctrl & IO_SERIAL)
+ if (DO_SIO)
sio_flush();
if (!autoboot || keyhit(3*SECOND))
getstr();
@@ -398,6 +413,7 @@ parse()
}
printf("Keyboard: %s\n", cp);
continue;
+#if SERIAL
} else if (c == 'S') {
j = 0;
while ((unsigned int)(i = *arg++ - '0') <= 9)
@@ -407,18 +423,21 @@ parse()
break;
}
/* Fall through to error below ('S' not in optstr[]). */
+#endif
}
for (i = 0; c != optstr[i]; i++)
if (i == NOPT - 1)
return -1;
opts ^= OPT_SET(flags[i]);
}
+#if SERIAL
ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) :
OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD;
- if (ioctrl & IO_SERIAL) {
+ if (DO_SIO) {
if (sio_init(115200 / comspeed) != 0)
ioctrl &= ~IO_SERIAL;
}
+#endif
} else {
for (q = arg--; *q && *q != '('; q++);
if (*q) {
@@ -626,9 +645,9 @@ keyhit(unsigned ticks)
static int
xputc(int c)
{
- if (ioctrl & IO_KEYBOARD)
+ if (DO_KBD)
putc(c);
- if (ioctrl & IO_SERIAL)
+ if (DO_SIO)
sio_putc(c);
return c;
}
@@ -648,9 +667,9 @@ xgetc(int fn)
if (OPT_CHECK(RBX_NOINTR))
return 0;
for (;;) {
- if (ioctrl & IO_KEYBOARD && getc(1))
+ if (DO_KBD && getc(1))
return fn ? 1 : getc(0);
- if (ioctrl & IO_SERIAL && sio_ischar())
+ if (DO_SIO && sio_ischar())
return fn ? 1 : sio_getc();
if (fn)
return 0;
diff --git a/sys/boot/i386/btx/btx/Makefile b/sys/boot/i386/btx/btx/Makefile
index 0f5a468..55756e0 100644
--- a/sys/boot/i386/btx/btx/Makefile
+++ b/sys/boot/i386/btx/btx/Makefile
@@ -5,6 +5,8 @@ INTERNALPROG=
MAN=
SRCS= btx.S
+NO_PIE= yes
+
.if defined(BOOT_BTX_NOHANG)
BOOT_BTX_FLAGS=0x1
.else
diff --git a/sys/boot/i386/btx/btxldr/Makefile b/sys/boot/i386/btx/btxldr/Makefile
index 7e57ca3..6808934 100644
--- a/sys/boot/i386/btx/btxldr/Makefile
+++ b/sys/boot/i386/btx/btxldr/Makefile
@@ -5,6 +5,8 @@ INTERNALPROG=
MAN=
SRCS= btxldr.S
+NO_PIE= yes
+
CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS}
CFLAGS+=-I${.CURDIR}/../../common
diff --git a/sys/boot/i386/btx/lib/Makefile b/sys/boot/i386/btx/lib/Makefile
index c66f0fc..caec3eb 100644
--- a/sys/boot/i386/btx/lib/Makefile
+++ b/sys/boot/i386/btx/lib/Makefile
@@ -7,4 +7,6 @@ SRCS= btxcsu.S btxsys.s btxv86.s
CFLAGS+=-I${.CURDIR}/../../common
LDFLAGS=-Wl,-r
+NO_PIE= yes
+
.include <bsd.prog.mk>
diff --git a/sys/boot/i386/gptboot/gptboot.8 b/sys/boot/i386/gptboot/gptboot.8
index 9bc655a..a7afd81 100644
--- a/sys/boot/i386/gptboot/gptboot.8
+++ b/sys/boot/i386/gptboot/gptboot.8
@@ -241,5 +241,5 @@ gpart set -a bootonce -i 2 ada0
.Nm
appeared in FreeBSD 7.1.
.Sh AUTHORS
-.An
-This manual page written by Warren Block <wblock@FreeBSD.org>.
+This manual page written by
+.An Warren Block Aq wblock@FreeBSD.org .
diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile
index e40f8b6..6b7e056 100644
--- a/sys/boot/i386/libi386/Makefile
+++ b/sys/boot/i386/libi386/Makefile
@@ -55,6 +55,9 @@ CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../common \
# the location of libstand
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
+# Suppress warning from clang for FreeBSD %b and %D formats
+CFLAGS+= -fformat-extensions
+
.if ${MACHINE_CPUARCH} == "amd64"
CLEANFILES+= machine
machine:
diff --git a/sys/boot/i386/libi386/amd64_tramp.S b/sys/boot/i386/libi386/amd64_tramp.S
index ff12c66..fe0cf83 100644
--- a/sys/boot/i386/libi386/amd64_tramp.S
+++ b/sys/boot/i386/libi386/amd64_tramp.S
@@ -84,7 +84,7 @@ amd64_tramp:
/* Turn on PAE */
movl %cr4, %eax
- orl $(CR4_PAE | CR4_PSE), %eax
+ orl $CR4_PAE, %eax
movl %eax, %cr4
/* Set %cr3 for PT4 */
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..1b255e9 100644
--- a/sys/boot/i386/libi386/pxe.c
+++ b/sys/boot/i386/libi386/pxe.c
@@ -301,10 +301,6 @@ pxe_open(struct open_file *f, ...)
bcopy(&rootpath[i], &temp[0], strlen(&rootpath[i])+1);
bcopy(&temp[0], &rootpath[0], strlen(&rootpath[i])+1);
}
- printf("pxe_open: server addr: %s\n", inet_ntoa(rootip));
- printf("pxe_open: server path: %s\n", rootpath);
- printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip));
-
setenv("boot.netif.ip", inet_ntoa(myip), 1);
setenv("boot.netif.netmask", intoa(netmask), 1);
setenv("boot.netif.gateway", inet_ntoa(gateip), 1);
@@ -312,9 +308,24 @@ pxe_open(struct open_file *f, ...)
sprintf(temp, "%6D", bootplayer.CAddr, ":");
setenv("boot.netif.hwaddr", temp, 1);
}
+#ifdef LOADER_NFS_SUPPORT
+ printf("pxe_open: server addr: %s\n", inet_ntoa(rootip));
+ printf("pxe_open: server path: %s\n", rootpath);
+ printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip));
+
setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
setenv("boot.nfsroot.path", rootpath, 1);
+#else
+ setenv("boot.netif.server", inet_ntoa(rootip), 1);
+#endif
setenv("dhcp.host-name", hostname, 1);
+
+ sprintf(temp, "%08X", ntohl(myip.s_addr));
+ setenv("pxeboot.ip", temp, 1);
+ if (bootplayer.Hardware == ETHER_TYPE) {
+ sprintf(temp, "%6D", bootplayer.CAddr, "-");
+ setenv("pxeboot.hwaddr", temp, 1);
+ }
}
}
pxe_opens++;
@@ -694,3 +705,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/Makefile b/sys/boot/i386/loader/Makefile
index b331012..f691314 100644
--- a/sys/boot/i386/loader/Makefile
+++ b/sys/boot/i386/loader/Makefile
@@ -8,6 +8,8 @@ PROG= ${LOADER}.sym
INTERNALPROG=
NEWVERSWHAT?= "bootstrap loader" x86
+NO_PIE= yes
+
# architecture-specific loader code
SRCS= main.c conf.c vers.c
@@ -132,6 +134,6 @@ LDADD= ${LIBFICL} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND}
beforedepend ${OBJS}: machine
CLEANFILES+= machine
CFLAGS+= -DLOADER_PREFER_AMD64
-machine:
+machine: .NOPATH
ln -sf ${.CURDIR}/../../../i386/include machine
.endif
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