Create a loader for each interpreter for x86 BIOS and all EFI

Create loader_{4th,lua,simp}{,.efi}. All of these are installed by
default. Create LOADER_DEFAULT_INTERP to specify the default
interpreter when no other is specified. LOADER_INTERP is the current
interpreter language building. Turn building of lua on by default to
match 4th. simploader is a simplified loader build w/o any interpreter
language (but with a simple loader).  This is the historic behavir you
got with WITHOUT_FORTH. Make a hard link to the default loader. This
has to be a hard link rather than the more desirable soft link because
older zfsboot blocks don't support symlinks.

RelNotes: Yes
Differential Revision: https://reviews.freebsd.org/D16705
This commit is contained in:
Warner Losh 2018-08-14 18:44:41 +00:00
parent 4c5d19fda4
commit 9d45c24cc4
14 changed files with 83 additions and 22 deletions

View File

@ -130,6 +130,7 @@ __DEFAULT_YES_OPTIONS = \
LIBTHR \ LIBTHR \
LLVM_COV \ LLVM_COV \
LOADER_GELI \ LOADER_GELI \
LOADER_LUA \
LOADER_OFW \ LOADER_OFW \
LOADER_UBOOT \ LOADER_UBOOT \
LOCALES \ LOCALES \
@ -197,7 +198,6 @@ __DEFAULT_NO_OPTIONS = \
LIBSOFT \ LIBSOFT \
LOADER_FIREWIRE \ LOADER_FIREWIRE \
LOADER_FORCE_LE \ LOADER_FORCE_LE \
LOADER_LUA \
NAND \ NAND \
OFED_EXTRA \ OFED_EXTRA \
OPENLDAP \ OPENLDAP \

View File

@ -146,6 +146,18 @@ CFLAGS+= -mlittle-endian
.endif .endif
.endif .endif
#
# Have a sensible default
#
.if ${MK_FORTH} == "yes"
LOADER_DEFAULT_INTERP?=4th
.elif ${MK_LOADER_LUA} == "yes"
LOADER_DEFAULT_INTERP?=lua
.else
LOADER_DEFAULT_INTERP?=simp
.endif
LOADER_INTERP?=${LOADER_DEFAULT_INTERP}
# Make sure we use the machine link we're about to create # Make sure we use the machine link we're about to create
CFLAGS+=-I. CFLAGS+=-I.

View File

@ -9,7 +9,10 @@ NO_OBJ=t
.if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500 .if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500
SUBDIR.${MK_FDT}+= fdt SUBDIR.${MK_FDT}+= fdt
SUBDIR.yes+= libefi loader boot1 SUBDIR.yes+= libefi boot1
SUBDIR.${MK_FORTH}+= loader_4th
SUBDIR.${MK_LOADER_LUA}+= loader_lua
SUBDIR.yes+= loader_simp
.endif # ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500 .endif # ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500

View File

@ -8,7 +8,8 @@ LOADER_EXT2FS_SUPPORT?= no
.include <bsd.init.mk> .include <bsd.init.mk>
PROG= loader.sym LOADER?= loader_${LOADER_INTERP}
PROG= ${LOADER}.sym
INTERNALPROG= INTERNALPROG=
WARNS?= 3 WARNS?= 3
@ -24,6 +25,7 @@ SRCS= autoload.c \
smbios.c \ smbios.c \
vers.c vers.c
CFLAGS+= -I${.CURDIR}/../loader
.if ${MK_ZFS} != "no" .if ${MK_ZFS} != "no"
CFLAGS+= -I${ZFSSRC} CFLAGS+= -I${ZFSSRC}
CFLAGS+= -DEFI_ZFS_BOOT CFLAGS+= -DEFI_ZFS_BOOT
@ -41,10 +43,11 @@ CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized
# warnings for now. # warnings for now.
CWARNFLAGS.main.c+= -Wno-format CWARNFLAGS.main.c+= -Wno-format
.PATH: ${.CURDIR}/arch/${MACHINE} .PATH: ${.CURDIR}/../loader
# For smbios.c .PATH: ${.CURDIR}/../loader/arch/${MACHINE}
# For smbios.c XXX need to abstract properly
.PATH: ${BOOTSRC}/i386/libi386 .PATH: ${BOOTSRC}/i386/libi386
.include "${.CURDIR}/arch/${MACHINE}/Makefile.inc" .include "${.CURDIR}/../loader/arch/${MACHINE}/Makefile.inc"
CFLAGS+= -I${.CURDIR} CFLAGS+= -I${.CURDIR}
CFLAGS+= -I${.CURDIR}/arch/${MACHINE} CFLAGS+= -I${.CURDIR}/arch/${MACHINE}
@ -78,20 +81,21 @@ HAVE_BCACHE= yes
CFLAGS+= -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE} CFLAGS+= -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
.endif .endif
NEWVERSWHAT= "EFI loader" ${MACHINE}
VERSION_FILE= ${.CURDIR}/../loader/version
# Always add MI sources # Always add MI sources
.include "${BOOTSRC}/loader.mk" .include "${BOOTSRC}/loader.mk"
FILES+= loader.efi FILES+= ${LOADER}.efi
FILESMODE_loader.efi= ${BINMODE} FILESMODE_${LOADER}.efi= ${BINMODE}
LDSCRIPT= ${.CURDIR}/arch/${MACHINE}/ldscript.${MACHINE} LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared
CLEANFILES+= loader.efi CLEANFILES+= loader.efi
NEWVERSWHAT= "EFI loader" ${MACHINE} ${LOADER}.efi: ${PROG}
loader.efi: ${PROG}
if ${NM} ${.ALLSRC} | grep ' U '; then \ if ${NM} ${.ALLSRC} | grep ' U '; then \
echo "Undefined symbols in ${.ALLSRC}"; \ echo "Undefined symbols in ${.ALLSRC}"; \
exit 1; \ exit 1; \

View File

@ -0,0 +1,6 @@
# $FreeBSD$
LOADER_INTERP=4th
.include "../loader/Makefile"

View File

@ -0,0 +1,6 @@
# $FreeBSD$
LOADER_INTERP=lua
.include "../loader/Makefile"

View File

@ -0,0 +1,6 @@
# $FreeBSD$
LOADER_INTERP=simp
.include "../loader/Makefile"

View File

@ -9,7 +9,9 @@ SUBDIR.yes= mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot \
SUBDIR.${MK_LOADER_FIREWIRE}+= libfirewire SUBDIR.${MK_LOADER_FIREWIRE}+= libfirewire
SUBDIR.yes+= loader SUBDIR.${MK_FORTH}+= loader_4th
SUBDIR.${MK_LOADER_LUA}+= loader_lua
SUBDIR.yes+= loader_simp
# special boot programs, 'self-extracting boot2+loader' # special boot programs, 'self-extracting boot2+loader'
SUBDIR.yes+= pxeldr SUBDIR.yes+= pxeldr

View File

@ -14,7 +14,7 @@ LOADER_BZIP2_SUPPORT?= yes
.include <bsd.init.mk> .include <bsd.init.mk>
LOADER?= loader LOADER?= loader_${LOADER_INTERP}
PROG= ${LOADER}.sym PROG= ${LOADER}.sym
INTERNALPROG= INTERNALPROG=
NEWVERSWHAT?= "bootstrap loader" x86 NEWVERSWHAT?= "bootstrap loader" x86
@ -64,11 +64,13 @@ ${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN}
${LOADER}.bin: ${LOADER}.sym ${LOADER}.bin: ${LOADER}.sym
strip -R .comment -R .note -o ${.TARGET} ${.ALLSRC} strip -R .comment -R .note -o ${.TARGET} ${.ALLSRC}
.if ${MK_ZFS} == "yes" .if ${MK_ZFS} == "yes" && ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
LINKS= ${BINDIR}/${LOADER} ${BINDIR}/zfs${LOADER} LINKS+= ${BINDIR}/${LOADER} ${BINDIR}/zfsloader
.endif
.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
LINKS+= ${BINDIR}/${LOADER} ${BINDIR}/loader
.endif .endif
FILES+= ${LOADER} FILES+= ${LOADER}
# XXX INSTALLFLAGS_loader= -b
FILESMODE_${LOADER}= ${BINMODE} -b FILESMODE_${LOADER}= ${BINMODE} -b
# XXX crt0.o needs to be first for pxeboot(8) to work # XXX crt0.o needs to be first for pxeboot(8) to work

View File

@ -0,0 +1,6 @@
# $FreeBSD$
LOADER_INTERP=4th
.include "../loader/Makefile"

View File

@ -0,0 +1,6 @@
# $FreeBSD$
LOADER_INTERP=lua
.include "../loader/Makefile"

View File

@ -0,0 +1,6 @@
# $FreeBSD$
LOADER_INTERP=simp
.include "../loader/Makefile"

View File

@ -24,7 +24,8 @@ CFLAGS+=-DALWAYS_SERIAL
CFLAGS+=-I${BOOTSRC}/i386/common CFLAGS+=-I${BOOTSRC}/i386/common
LOADERBIN= ${BOOTOBJ}/i386/loader/loader.bin L=${LOADER_DEFAULT_INTERP}
LOADERBIN= ${BOOTOBJ}/i386/loader_${L}/loader_${L}.bin
CLEANFILES+= ${BOOT}.tmp CLEANFILES+= ${BOOT}.tmp

View File

@ -57,19 +57,20 @@ SRCS+= isapnp.c
SRCS+= pnp.c SRCS+= pnp.c
.endif .endif
# Forth interpreter .if ${LOADER_INTERP} == "lua"
.if ${MK_LOADER_LUA} != "no"
SRCS+= interp_lua.c SRCS+= interp_lua.c
.include "${BOOTSRC}/lua.mk" .include "${BOOTSRC}/lua.mk"
LDR_INTERP= ${LIBLUA} LDR_INTERP= ${LIBLUA}
LDR_INTERP32= ${LIBLUA32} LDR_INTERP32= ${LIBLUA32}
.elif ${MK_FORTH} != "no" .elif ${LOADER_INTERP} == "4th"
SRCS+= interp_forth.c SRCS+= interp_forth.c
.include "${BOOTSRC}/ficl.mk" .include "${BOOTSRC}/ficl.mk"
LDR_INTERP= ${LIBFICL} LDR_INTERP= ${LIBFICL}
LDR_INTERP32= ${LIBFICL32} LDR_INTERP32= ${LIBFICL32}
.else .elif ${LOADER_INTERP} == "simp"
SRCS+= interp_simple.c SRCS+= interp_simple.c
.else
.error Unknown interpreter ${LOADER_INTERP}
.endif .endif
.if defined(BOOT_PROMPT_123) .if defined(BOOT_PROMPT_123)