summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-01-07 18:08:08 -0200
committerRenato Botelho <renato@netgate.com>2016-01-07 18:08:08 -0200
commit7a579754077b3460c9509c75cdd1b78769c1db3f (patch)
treec15015685ccb82b7db1ac19d663a3c6e41e64587 /sys/boot
parentd8ff3484131f428fcc0727cd504acb5050a36490 (diff)
parentbc6ee646001a22150936ff06bf11cd08195e208d (diff)
downloadFreeBSD-src-7a579754077b3460c9509c75cdd1b78769c1db3f.zip
FreeBSD-src-7a579754077b3460c9509c75cdd1b78769c1db3f.tar.gz
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/amd64/Makefile7
-rw-r--r--sys/boot/amd64/Makefile.inc12
-rw-r--r--sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu22
-rw-r--r--sys/boot/efi/Makefile4
-rw-r--r--sys/boot/efi/Makefile.inc3
-rw-r--r--sys/boot/efi/boot1/Makefile (renamed from sys/boot/amd64/boot1.efi/Makefile)12
-rw-r--r--sys/boot/efi/boot1/Makefile.fat (renamed from sys/boot/amd64/boot1.efi/Makefile.fat)0
-rw-r--r--sys/boot/efi/boot1/boot1.c (renamed from sys/boot/amd64/boot1.efi/boot1.c)9
-rw-r--r--sys/boot/efi/boot1/fat.tmpl.bz2.uu20
-rwxr-xr-xsys/boot/efi/boot1/generate-fat.sh (renamed from sys/boot/amd64/boot1.efi/generate-fat.sh)22
-rw-r--r--sys/boot/efi/loader/Makefile (renamed from sys/boot/amd64/efi/Makefile)35
-rw-r--r--sys/boot/efi/loader/arch/amd64/Makefile.inc11
-rw-r--r--sys/boot/efi/loader/arch/amd64/amd64_tramp.S (renamed from sys/boot/amd64/efi/amd64_tramp.S)0
-rw-r--r--sys/boot/efi/loader/arch/amd64/elf64_freebsd.c (renamed from sys/boot/amd64/efi/elf64_freebsd.c)21
-rw-r--r--sys/boot/efi/loader/arch/amd64/framebuffer.c (renamed from sys/boot/amd64/efi/framebuffer.c)0
-rw-r--r--sys/boot/efi/loader/arch/amd64/framebuffer.h (renamed from sys/boot/amd64/efi/framebuffer.h)0
-rw-r--r--sys/boot/efi/loader/arch/amd64/ldscript.amd64 (renamed from sys/boot/amd64/efi/ldscript.amd64)0
-rw-r--r--sys/boot/efi/loader/arch/amd64/reloc.c (renamed from sys/boot/amd64/efi/reloc.c)0
-rw-r--r--sys/boot/efi/loader/arch/amd64/start.S (renamed from sys/boot/amd64/efi/start.S)0
-rw-r--r--sys/boot/efi/loader/autoload.c (renamed from sys/boot/amd64/efi/autoload.c)2
-rw-r--r--sys/boot/efi/loader/bootinfo.c (renamed from sys/boot/amd64/efi/bootinfo.c)145
-rw-r--r--sys/boot/efi/loader/conf.c (renamed from sys/boot/amd64/efi/conf.c)9
-rw-r--r--sys/boot/efi/loader/copy.c (renamed from sys/boot/amd64/efi/copy.c)10
-rw-r--r--sys/boot/efi/loader/devicename.c (renamed from sys/boot/amd64/efi/devicename.c)16
-rw-r--r--sys/boot/efi/loader/loader_efi.h (renamed from sys/boot/amd64/efi/x86_efi.h)26
-rw-r--r--sys/boot/efi/loader/main.c (renamed from sys/boot/amd64/efi/main.c)21
-rw-r--r--sys/boot/efi/loader/version (renamed from sys/boot/amd64/efi/version)0
-rw-r--r--sys/boot/forth/loader.conf15
-rw-r--r--sys/boot/forth/loader.rc3
-rw-r--r--sys/boot/forth/menu.rc3
-rw-r--r--sys/boot/forth/support.4th19
-rw-r--r--sys/boot/i386/efi/bootinfo.c275
-rw-r--r--sys/boot/i386/efi/efimd.c139
-rw-r--r--sys/boot/i386/efi/elf32_freebsd.c87
-rw-r--r--sys/boot/i386/efi/exec.c49
-rw-r--r--sys/boot/i386/efi/i386_copy.c59
-rw-r--r--sys/boot/i386/efi/ldscript.i38672
-rw-r--r--sys/boot/i386/efi/reloc.c107
-rw-r--r--sys/boot/i386/efi/start.S70
-rw-r--r--sys/boot/i386/loader/Makefile7
-rw-r--r--sys/boot/pc98/loader/Makefile7
-rw-r--r--sys/boot/powerpc/ofw/Makefile8
-rw-r--r--sys/boot/powerpc/ps3/Makefile8
-rw-r--r--sys/boot/sparc64/loader/Makefile8
44 files changed, 245 insertions, 1098 deletions
diff --git a/sys/boot/amd64/Makefile b/sys/boot/amd64/Makefile
deleted file mode 100644
index 59940e9..0000000
--- a/sys/boot/amd64/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# $FreeBSD$
-
-.include <bsd.own.mk>
-
-SUBDIR= efi boot1.efi
-
-.include <bsd.subdir.mk>
diff --git a/sys/boot/amd64/Makefile.inc b/sys/boot/amd64/Makefile.inc
deleted file mode 100644
index 7b10385..0000000
--- a/sys/boot/amd64/Makefile.inc
+++ /dev/null
@@ -1,12 +0,0 @@
-# Common defines for all of /sys/boot/amd64/
-#
-# $FreeBSD$
-
-BINDIR?= /boot
-
-# See conf/kern.mk for the correct set of these
-CFLAGS+= -ffreestanding -mno-red-zone
-CFLAGS+= -mno-mmx -mno-sse -mno-aes -mno-avx -msoft-float
-LDFLAGS+= -nostdlib
-
-.include "../Makefile.inc"
diff --git a/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu b/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu
deleted file mode 100644
index 2af4244..0000000
--- a/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu
+++ /dev/null
@@ -1,22 +0,0 @@
-FAT template boot filesystem created by generate-fat.sh
-DO NOT EDIT
-$FreeBSD$
-begin 644 fat.tmpl.bz2
-M0EIH.3%!62936?1V`!$`&J7____[ZZKJJ_^N_ZO^Z_^[ON_\`4`00!0$#$$"
-M0D)$6&(<P`(Y=SNY1(2DHTC":::-`!H`&@-````#)IH#3(&@:`!IIDT--,@E
-M53TFCWZJGJ`-!D`-`#(::```:```&@:!D`!D``&*B3:C]4T]0#0`:``-`T``
-M``````````&@)131/4T-*>IZC3RGZH\B&$,U&AH#)B:,$8TAF@@]0T>IZF&A
-M&GZID,1IZFAMO%FPGL0"(QIZV"3_!`$@N(@`DD$?C&$["`)`!)$6@#\HOB42
-M0`"2(X0FGX1#L"`'7E,'#-'HM!'QUD0\R,?9U,6ZE8F,Y6*L<9S<6PH)"%_"
-MX'_PL4A),QB"(`B(=14*-"8,(QCG.(2$A(1J'010CB&R$(0B00FPP(0A"$)E
-M#`A"$(1]LB&!"$(0B4&1#`A"$(14W<9J.:&A@8&!@8'`Z$(D(02@^L=UL>:+
-MBG:Q5+4&'[/P4@D2?M<,E!0&YBF8+],4^%$`4<YVD4=K")O.IZ\#)``!CU-1
-M``!L%C7V^RL80`#K(AUU+"D])9/B4@>*%$N9MF:Z29-_VG2G7<$LJ-44RST&
-MB53YE@H%(G5G$.FU;=L[DQVA]"(V4B1+%BP%.A<-10-%#R#NKR='@\'#"_'U
-M'I36ZT:8QIN*3E$:HZIZRJ?$Y1L&<1'C)G(=8,E.L(KU<9X=%/NX.6\=@^IW
-M\-PC$B&I"T\!(VI3"K!X:\%.01Y#X/83[SH.J*H5BH:ILFV1'X/D/V1$W6'\
-MFY>YE:*(I!.X@'D>H_(PY'(W1+B;:,Y?H8Y%(Q')!>DDE;\J1-DRXJJ/O(1@
-M'X/24=!+/V8S1)B(R:UE"0&&1:PUS(1`!$04``++GZ/8(CE5P1P8?^7QB[DB
-(G"A(>CL`"(``
-`
-end
diff --git a/sys/boot/efi/Makefile b/sys/boot/efi/Makefile
index ce52113..5dfb648 100644
--- a/sys/boot/efi/Makefile
+++ b/sys/boot/efi/Makefile
@@ -2,4 +2,8 @@
SUBDIR= libefi
+.if ${MACHINE_CPUARCH} == "amd64"
+SUBDIR+= loader boot1
+.endif
+
.include <bsd.subdir.mk>
diff --git a/sys/boot/efi/Makefile.inc b/sys/boot/efi/Makefile.inc
index 29ebae4..58c4726 100644
--- a/sys/boot/efi/Makefile.inc
+++ b/sys/boot/efi/Makefile.inc
@@ -7,7 +7,10 @@ CFLAGS+= -march=i386
.endif
# Options used when building app-specific efi components
+# See conf/kern.mk for the correct set of these
CFLAGS+= -ffreestanding -fshort-wchar -Wformat
+CFLAGS+= -mno-red-zone
+CFLAGS+= -mno-mmx -mno-sse -mno-aes -mno-avx -msoft-float
LDFLAGS+= -nostdlib
.include "../Makefile.inc"
diff --git a/sys/boot/amd64/boot1.efi/Makefile b/sys/boot/efi/boot1/Makefile
index dd8eaf9..554df39 100644
--- a/sys/boot/amd64/boot1.efi/Makefile
+++ b/sys/boot/efi/boot1/Makefile
@@ -17,19 +17,19 @@ SRCS= boot1.c reloc.c start.S
CFLAGS+= -fPIC
CFLAGS+= -I.
-CFLAGS+= -I${.CURDIR}/../../efi/include
-CFLAGS+= -I${.CURDIR}/../../efi/include/${MACHINE_CPUARCH}
+CFLAGS+= -I${.CURDIR}/../include
+CFLAGS+= -I${.CURDIR}/../include/${MACHINE_CPUARCH}
CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include
CFLAGS+= -I${.CURDIR}/../../..
# Always add MI sources and REGULAR efi loader bits
-.PATH: ${.CURDIR}/../efi ${.CURDIR}/../../common
+.PATH: ${.CURDIR}/../loader/arch/amd64 ${.CURDIR}/../../common
CFLAGS+= -I${.CURDIR}/../../common
FILES= boot1.efi boot1.efifat
FILESMODE_boot1.efi= ${BINMODE}
-LDSCRIPT= ${.CURDIR}/../efi/ldscript.${MACHINE_CPUARCH}
+LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE_CPUARCH}/ldscript.${MACHINE_CPUARCH}
LDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared -Wl,-znocombreloc
${PROG}: ${LDSCRIPT}
@@ -39,7 +39,7 @@ OBJDUMP?= objdump
.if ${MACHINE_CPUARCH} == "amd64"
EFI_TARGET= efi-app-x86_64
-.else
+.elif ${MACHINE_CPUARCH} == "i386"
EFI_TARGET= efi-app-ia32
.endif
@@ -53,8 +53,6 @@ boot1.efi: loader.sym
-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
-CFLAGS+= -I${.CURDIR}/../../common
-
boot1.o: ${.CURDIR}/../../common/ufsread.c
# The following inserts out objects into a template FAT file system
diff --git a/sys/boot/amd64/boot1.efi/Makefile.fat b/sys/boot/efi/boot1/Makefile.fat
index 324481e..324481e 100644
--- a/sys/boot/amd64/boot1.efi/Makefile.fat
+++ b/sys/boot/efi/boot1/Makefile.fat
diff --git a/sys/boot/amd64/boot1.efi/boot1.c b/sys/boot/efi/boot1/boot1.c
index 4a8f951..e0c26da 100644
--- a/sys/boot/amd64/boot1.efi/boot1.c
+++ b/sys/boot/efi/boot1/boot1.c
@@ -308,18 +308,21 @@ load(const char *fname)
status = systab->BootServices->LoadImage(TRUE, image, bootdevpath,
buffer, bufsize, &loaderhandle);
if (EFI_ERROR(status))
- printf("LoadImage failed with error %lx\n", status);
+ printf("LoadImage failed with error %lu\n",
+ status & ~EFI_ERROR_MASK);
status = systab->BootServices->HandleProtocol(loaderhandle,
&LoadedImageGUID, (VOID**)&loaded_image);
if (EFI_ERROR(status))
- printf("HandleProtocol failed with error %lx\n", status);
+ printf("HandleProtocol failed with error %lu\n",
+ status & ~EFI_ERROR_MASK);
loaded_image->DeviceHandle = bootdevhandle;
status = systab->BootServices->StartImage(loaderhandle, NULL, NULL);
if (EFI_ERROR(status))
- printf("StartImage failed with error %lx\n", status);
+ printf("StartImage failed with error %lu\n",
+ status & ~EFI_ERROR_MASK);
}
static void
diff --git a/sys/boot/efi/boot1/fat.tmpl.bz2.uu b/sys/boot/efi/boot1/fat.tmpl.bz2.uu
new file mode 100644
index 0000000..c9044ee
--- /dev/null
+++ b/sys/boot/efi/boot1/fat.tmpl.bz2.uu
@@ -0,0 +1,20 @@
+FAT template boot filesystem created by generate-fat.sh
+DO NOT EDIT
+$FreeBSD$
+begin 644 fat.tmpl.bz2
+M0EIH.3%!629362AK*D(`&I+____[ZZKJZ_^N_ZO^Z_Z_OJ[L`4`!7I0$#&$"
+M0$!$3&(<P`(;J*C:0E0E#30&AH`T````9#0```9````#)ZF0:,-3U/409,`)
+M@`"8`C3",````$R:8F@P`C`````"24U,D>I-DTU,)ZAZ0VA-!M0T'J`>H#"9
+M'I#0-H&HQI&0&3&FH>H>*`JHHU3V]1%/4/2``T#0`!H``#0`````#1H,@``6
+M'1&G'&@?$6[T#A)?X8$A160"20BO#")0J4TB1*4GXF$B4I,&>43+=_?K=#3*
+M6]<E0HE`UBF?(J%8BRF#?8OQ2'D)`)(EL2;F4.'R>R"ZNKJZI,9*68E8*E2Q
+M4J5*E3'(1830A"$(12A-"<(0A#]VD)H0A"$,>I0FA"$(0I\>P^=F5:M6K5JU
+M:DI3:64UN;[7%5B]Y-^\]@_K@B:N\/,5F%&H<\G#IXQXAEFC&D?![6%0'6MR
+MX1@@%FC"FD`M7,/SXFNG:2`'-0<-C$8^+$N.7M1B,^6)9,DV9,0A\OL<:C"L
+ML1V&,<\9YRB>XV#BG")'6NKRK^("UF2XO?_L!#29">MGDF$R3).!PX&%E,4C
+M''=(FL1.`_3?CN@-IB2PI3!FF\<8X.X@D,>CA90I)#M$XRPNDFJELL<3=1?8
+M2B7\5Z64,!7Z;EEBW-MXN-4IJ@W$462]-*\YCR,-B,5[W?=3&L/U>SX,WV#\
+M\B`:I"'0Z)5"$1B.E)(K[5I4RS`%R$>Y\D0NR*,;<9CZ:^V3P(I?D<D#!UC)
+D^M-HEE3SAN-8O0FQ$(`$(DF`?ZQ]'U2F_XNY(IPH2!0UE2$`
+`
+end
diff --git a/sys/boot/amd64/boot1.efi/generate-fat.sh b/sys/boot/efi/boot1/generate-fat.sh
index eafd3e0..2688da3 100755
--- a/sys/boot/amd64/boot1.efi/generate-fat.sh
+++ b/sys/boot/efi/boot1/generate-fat.sh
@@ -13,14 +13,26 @@
FAT_SIZE=1600 #Size in 512-byte blocks of the produced image
-BOOT1_SIZE=64k
+BOOT1_SIZE=128k
+
+#
+# Known filenames
+# amd64: BOOTx64.efi
+# arm64: BOOTaa64.efi
+#
+if [ -z "$1" ]; then
+ echo "Usage: $0 filename"
+ exit 1
+fi
+
+FILENAME=$1
# Generate 800K FAT image
OUTPUT_FILE=fat.tmpl
dd if=/dev/zero of=$OUTPUT_FILE bs=512 count=$FAT_SIZE
DEVICE=`mdconfig -a -f $OUTPUT_FILE`
-newfs_msdos -F 12 $DEVICE
+newfs_msdos -F 12 -L EFI $DEVICE
mkdir stub
mount -t msdosfs /dev/$DEVICE stub
@@ -28,16 +40,16 @@ mount -t msdosfs /dev/$DEVICE stub
mkdir -p stub/efi/boot
# Make a dummy file for boot1
-echo 'Boot1 START' | dd of=stub/efi/boot/BOOTx64.efi cbs=$BOOT1_SIZE count=1 conv=block
+echo 'Boot1 START' | dd of=stub/efi/boot/$FILENAME cbs=$BOOT1_SIZE count=1 conv=block
umount stub
mdconfig -d -u $DEVICE
rmdir stub
-# Locate the offsets of the two fake files
+# Locate the offset of the fake file
BOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'Boot1 START' | cut -f 1 -d ' ')
-# Convert to numbers of blocks
+# Convert to number of blocks
BOOT1_OFFSET=$(echo 0x$BOOT1_OFFSET | awk '{printf("%x\n",$1/512);}')
echo '# This file autogenerated by generate-fat.sh - DO NOT EDIT' > Makefile.fat
diff --git a/sys/boot/amd64/efi/Makefile b/sys/boot/efi/loader/Makefile
index 29e5389..26fd8a0 100644
--- a/sys/boot/amd64/efi/Makefile
+++ b/sys/boot/efi/loader/Makefile
@@ -12,27 +12,27 @@ MK_SSP= no
PROG= loader.sym
INTERNALPROG=
+.PATH: ${.CURDIR}/../../efi/loader
# architecture-specific loader code
SRCS= autoload.c \
bootinfo.c \
conf.c \
copy.c \
devicename.c \
- elf64_freebsd.c \
- framebuffer.c \
main.c \
- reloc.c \
smbios.c \
vers.c
-SRCS+= amd64_tramp.S \
- start.S
-SRCS+= nullconsole.c \
- comconsole.c
+
+.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}
+# For smbios.c
+.PATH: ${.CURDIR}/../../i386/libi386
+.include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc"
CFLAGS+= -fPIC
-CFLAGS+= -I.
-CFLAGS+= -I${.CURDIR}/../../efi/include
-CFLAGS+= -I${.CURDIR}/../../efi/include/${MACHINE_CPUARCH}
+CFLAGS+= -I${.CURDIR}
+CFLAGS+= -I${.CURDIR}/arch/${MACHINE_CPUARCH}
+CFLAGS+= -I${.CURDIR}/../include
+CFLAGS+= -I${.CURDIR}/../include/${MACHINE_CPUARCH}
CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include
CFLAGS+= -I${.CURDIR}/../../..
CFLAGS+= -I${.CURDIR}/../../i386/libi386
@@ -55,24 +55,20 @@ CFLAGS+= -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
# Always add MI sources
.PATH: ${.CURDIR}/../../common
-# For smbios.c, nullconsole.c, comconsole.c
-.PATH: ${.CURDIR}/../../i386/libi386
.include "${.CURDIR}/../../common/Makefile.inc"
CFLAGS+= -I${.CURDIR}/../../common
FILES= loader.efi
FILESMODE_loader.efi= ${BINMODE}
-LDSCRIPT= ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
+LDSCRIPT= ${.CURDIR}/arch/${MACHINE_CPUARCH}/ldscript.${MACHINE_CPUARCH}
LDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared -Wl,-znocombreloc
-${PROG}: ${LDSCRIPT}
-
CLEANFILES= vers.c loader.efi
NEWVERSWHAT= "EFI loader" ${MACHINE_CPUARCH}
-vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
+vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../../efi/loader/version
sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
OBJCOPY?= objcopy
@@ -80,7 +76,7 @@ OBJDUMP?= objdump
.if ${MACHINE_CPUARCH} == "amd64"
EFI_TARGET= efi-app-x86_64
-.else
+.elif ${MACHINE_CPUARCH} == "i386"
EFI_TARGET= efi-app-ia32
.endif
@@ -94,10 +90,9 @@ loader.efi: loader.sym
-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
-LIBEFI= ${.OBJDIR}/../../efi/libefi/libefi.a
-CFLAGS+= -I${.CURDIR}/../../common
+LIBEFI= ${.OBJDIR}/../libefi/libefi.a
-DPADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND}
+DPADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND} ${LDSCRIPT}
LDADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND}
.endif # ${COMPILER_TYPE} != "gcc"
diff --git a/sys/boot/efi/loader/arch/amd64/Makefile.inc b/sys/boot/efi/loader/arch/amd64/Makefile.inc
new file mode 100644
index 0000000..3f2b68e
--- /dev/null
+++ b/sys/boot/efi/loader/arch/amd64/Makefile.inc
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+SRCS+= amd64_tramp.S \
+ start.S \
+ framebuffer.c \
+ elf64_freebsd.c \
+ reloc.c
+
+.PATH: ${.CURDIR}/../../i386/libi386
+SRCS+= nullconsole.c \
+ comconsole.c
diff --git a/sys/boot/amd64/efi/amd64_tramp.S b/sys/boot/efi/loader/arch/amd64/amd64_tramp.S
index c102d92..c102d92 100644
--- a/sys/boot/amd64/efi/amd64_tramp.S
+++ b/sys/boot/efi/loader/arch/amd64/amd64_tramp.S
diff --git a/sys/boot/amd64/efi/elf64_freebsd.c b/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c
index 0fb82b0..c1dbec2 100644
--- a/sys/boot/amd64/efi/elf64_freebsd.c
+++ b/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
#include "actypes.h"
#include "actbl.h"
-#include "x86_efi.h"
+#include "loader_efi.h"
static EFI_GUID acpi_guid = ACPI_TABLE_GUID;
static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID;
@@ -57,8 +57,14 @@ extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp);
static int elf64_exec(struct preloaded_file *amp);
static int elf64_obj_exec(struct preloaded_file *amp);
-struct file_format amd64_elf = { elf64_loadfile, elf64_exec };
-struct file_format amd64_elf_obj = { elf64_obj_loadfile, elf64_obj_exec };
+static struct file_format amd64_elf = { elf64_loadfile, elf64_exec };
+static struct file_format amd64_elf_obj = { elf64_obj_loadfile, elf64_obj_exec };
+
+struct file_format *file_formats[] = {
+ &amd64_elf,
+ &amd64_elf_obj,
+ NULL
+};
#define PG_V 0x001
#define PG_RW 0x002
@@ -168,16 +174,9 @@ elf64_exec(struct preloaded_file *fp)
if (err != 0)
return(err);
- status = BS->ExitBootServices(IH, x86_efi_mapkey);
- if (EFI_ERROR(status)) {
- printf("%s: ExitBootServices() returned 0x%lx\n", __func__,
- (long)status);
- return (EINVAL);
- }
-
dev_cleanup();
- trampoline(trampstack, x86_efi_copy_finish, kernend, modulep, PT4,
+ trampoline(trampstack, efi_copy_finish, kernend, modulep, PT4,
ehdr->e_entry);
panic("exec returned");
diff --git a/sys/boot/amd64/efi/framebuffer.c b/sys/boot/efi/loader/arch/amd64/framebuffer.c
index 90bf992..90bf992 100644
--- a/sys/boot/amd64/efi/framebuffer.c
+++ b/sys/boot/efi/loader/arch/amd64/framebuffer.c
diff --git a/sys/boot/amd64/efi/framebuffer.h b/sys/boot/efi/loader/arch/amd64/framebuffer.h
index 2ec9017..2ec9017 100644
--- a/sys/boot/amd64/efi/framebuffer.h
+++ b/sys/boot/efi/loader/arch/amd64/framebuffer.h
diff --git a/sys/boot/amd64/efi/ldscript.amd64 b/sys/boot/efi/loader/arch/amd64/ldscript.amd64
index 14e1f06..14e1f06 100644
--- a/sys/boot/amd64/efi/ldscript.amd64
+++ b/sys/boot/efi/loader/arch/amd64/ldscript.amd64
diff --git a/sys/boot/amd64/efi/reloc.c b/sys/boot/efi/loader/arch/amd64/reloc.c
index 98bcf8e..98bcf8e 100644
--- a/sys/boot/amd64/efi/reloc.c
+++ b/sys/boot/efi/loader/arch/amd64/reloc.c
diff --git a/sys/boot/amd64/efi/start.S b/sys/boot/efi/loader/arch/amd64/start.S
index beaeeff..beaeeff 100644
--- a/sys/boot/amd64/efi/start.S
+++ b/sys/boot/efi/loader/arch/amd64/start.S
diff --git a/sys/boot/amd64/efi/autoload.c b/sys/boot/efi/loader/autoload.c
index efb32d4..694a6da 100644
--- a/sys/boot/amd64/efi/autoload.c
+++ b/sys/boot/efi/loader/autoload.c
@@ -28,7 +28,7 @@
__FBSDID("$FreeBSD$");
int
-x86_efi_autoload(void)
+efi_autoload(void)
{
return (0);
diff --git a/sys/boot/amd64/efi/bootinfo.c b/sys/boot/efi/loader/bootinfo.c
index 2d45dd0..f3bb9cc 100644
--- a/sys/boot/amd64/efi/bootinfo.c
+++ b/sys/boot/efi/loader/bootinfo.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/linker.h>
#include <sys/boot.h>
#include <machine/cpufunc.h>
+#include <machine/elf.h>
#include <machine/metadata.h>
#include <machine/psl.h>
#include <machine/specialreg.h>
@@ -45,9 +46,7 @@ __FBSDID("$FreeBSD$");
#include "bootstrap.h"
#include "framebuffer.h"
-#include "x86_efi.h"
-
-UINTN x86_efi_mapkey;
+#include "loader_efi.h"
static const char howto_switches[] = "aCdrgDmphsv";
static int howto_masks[] = {
@@ -114,24 +113,24 @@ bi_copyenv(vm_offset_t start)
/* Traverse the environment. */
for (ep = environ; ep != NULL; ep = ep->ev_next) {
len = strlen(ep->ev_name);
- if (x86_efi_copyin(ep->ev_name, addr, len) != len)
+ if (archsw.arch_copyin(ep->ev_name, addr, len) != len)
break;
addr += len;
- if (x86_efi_copyin("=", addr, 1) != 1)
+ if (archsw.arch_copyin("=", addr, 1) != 1)
break;
addr++;
if (ep->ev_value != NULL) {
len = strlen(ep->ev_value);
- if (x86_efi_copyin(ep->ev_value, addr, len) != len)
+ if (archsw.arch_copyin(ep->ev_value, addr, len) != len)
break;
addr += len;
}
- if (x86_efi_copyin("", addr, 1) != 1)
+ if (archsw.arch_copyin("", addr, 1) != 1)
break;
last = ++addr;
}
- if (x86_efi_copyin("", last++, 1) != 1)
+ if (archsw.arch_copyin("", last++, 1) != 1)
last = start;
return(last);
}
@@ -155,7 +154,7 @@ bi_copyenv(vm_offset_t start)
#define COPY32(v, a, c) { \
uint32_t x = (v); \
if (c) \
- x86_efi_copyin(&x, a, sizeof(x)); \
+ archsw.arch_copyin(&x, a, sizeof(x)); \
a += sizeof(x); \
}
@@ -163,8 +162,8 @@ bi_copyenv(vm_offset_t start)
COPY32(t, a, c); \
COPY32(strlen(s) + 1, a, c); \
if (c) \
- x86_efi_copyin(s, a, strlen(s) + 1); \
- a += roundup(strlen(s) + 1, sizeof(uint64_t)); \
+ archsw.arch_copyin(s, a, strlen(s) + 1); \
+ a += roundup(strlen(s) + 1, sizeof(u_long)); \
}
#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
@@ -175,8 +174,8 @@ bi_copyenv(vm_offset_t start)
COPY32(t, a, c); \
COPY32(sizeof(s), a, c); \
if (c) \
- x86_efi_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(uint64_t)); \
+ archsw.arch_copyin(&s, a, sizeof(s)); \
+ a += roundup(sizeof(s), sizeof(u_long)); \
}
#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c)
@@ -186,8 +185,8 @@ bi_copyenv(vm_offset_t start)
COPY32(MODINFO_METADATA | mm->md_type, a, c); \
COPY32(mm->md_size, a, c); \
if (c) \
- x86_efi_copyin(mm->md_data, a, mm->md_size); \
- a += roundup(mm->md_size, sizeof(uint64_t)); \
+ archsw.arch_copyin(mm->md_data, a, mm->md_size); \
+ a += roundup(mm->md_size, sizeof(u_long)); \
}
#define MOD_END(a, c) { \
@@ -229,60 +228,86 @@ bi_load_efi_data(struct preloaded_file *kfp)
EFI_PHYSICAL_ADDRESS addr;
EFI_STATUS status;
size_t efisz;
- UINTN mmsz, pages, sz;
+ UINTN efi_mapkey;
+ UINTN mmsz, pages, retry, sz;
UINT32 mmver;
struct efi_map_header *efihdr;
struct efi_fb efifb;
- if (efi_find_framebuffer(&efifb) == 0)
+ if (efi_find_framebuffer(&efifb) == 0) {
+ printf("EFI framebuffer information:\n");
+ printf("addr, size 0x%lx, 0x%lx\n", efifb.fb_addr,
+ efifb.fb_size);
+ printf("dimensions %d x %d\n", efifb.fb_width,
+ efifb.fb_height);
+ printf("stride %d\n", efifb.fb_stride);
+ printf("masks 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
+ efifb.fb_mask_red, efifb.fb_mask_green, efifb.fb_mask_blue,
+ efifb.fb_mask_reserved);
+
file_addmetadata(kfp, MODINFOMD_EFI_FB, sizeof(efifb), &efifb);
+ }
efisz = (sizeof(struct efi_map_header) + 0xf) & ~0xf;
/*
- * Allocate enough pages to hold the bootinfo block and the memory
- * map EFI will return to us. The memory map has an unknown size,
- * so we have to determine that first. Note that the AllocatePages
- * call can itself modify the memory map, so we have to take that
- * into account as well. The changes to the memory map are caused
- * by splitting a range of free memory into two (AFAICT), so that
- * one is marked as being loader data.
+ * It is possible that the first call to ExitBootServices may change
+ * the map key. Fetch a new map key and retry ExitBootServices in that
+ * case.
*/
- sz = 0;
- BS->GetMemoryMap(&sz, NULL, &x86_efi_mapkey, &mmsz, &mmver);
- sz += mmsz;
- sz = (sz + 0xf) & ~0xf;
- pages = EFI_SIZE_TO_PAGES(sz + efisz);
- status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, pages,
- &addr);
- if (EFI_ERROR(status)) {
- printf("%s: AllocatePages() returned 0x%lx\n", __func__,
- (long)status);
- return (ENOMEM);
- }
+ for (retry = 2; retry > 0; retry--) {
+ /*
+ * Allocate enough pages to hold the bootinfo block and the
+ * memory map EFI will return to us. The memory map has an
+ * unknown size, so we have to determine that first. Note that
+ * the AllocatePages call can itself modify the memory map, so
+ * we have to take that into account as well. The changes to
+ * the memory map are caused by splitting a range of free
+ * memory into two (AFAICT), so that one is marked as being
+ * loader data.
+ */
+ sz = 0;
+ BS->GetMemoryMap(&sz, NULL, &efi_mapkey, &mmsz, &mmver);
+ sz += mmsz;
+ sz = (sz + 0xf) & ~0xf;
+ pages = EFI_SIZE_TO_PAGES(sz + efisz);
+ status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData,
+ pages, &addr);
+ if (EFI_ERROR(status)) {
+ printf("%s: AllocatePages error %lu\n", __func__,
+ (unsigned long)(status & ~EFI_ERROR_MASK));
+ return (ENOMEM);
+ }
- /*
- * Read the memory map and stash it after bootinfo. Align the
- * memory map on a 16-byte boundary (the bootinfo block is page
- * aligned).
- */
- efihdr = (struct efi_map_header *)addr;
- mm = (void *)((uint8_t *)efihdr + efisz);
- sz = (EFI_PAGE_SIZE * pages) - efisz;
- status = BS->GetMemoryMap(&sz, mm, &x86_efi_mapkey, &mmsz, &mmver);
- if (EFI_ERROR(status)) {
- printf("%s: GetMemoryMap() returned 0x%lx\n", __func__,
- (long)status);
- return (EINVAL);
+ /*
+ * Read the memory map and stash it after bootinfo. Align the
+ * memory map on a 16-byte boundary (the bootinfo block is page
+ * aligned).
+ */
+ efihdr = (struct efi_map_header *)addr;
+ mm = (void *)((uint8_t *)efihdr + efisz);
+ sz = (EFI_PAGE_SIZE * pages) - efisz;
+
+ status = BS->GetMemoryMap(&sz, mm, &efi_mapkey, &mmsz, &mmver);
+ if (EFI_ERROR(status)) {
+ printf("%s: GetMemoryMap error %lu\n", __func__,
+ (unsigned long)(status & ~EFI_ERROR_MASK));
+ return (EINVAL);
+ }
+ status = BS->ExitBootServices(IH, efi_mapkey);
+ if (EFI_ERROR(status) == 0) {
+ efihdr->memory_size = sz;
+ efihdr->descriptor_size = mmsz;
+ efihdr->descriptor_version = mmver;
+ file_addmetadata(kfp, MODINFOMD_EFI_MAP, efisz + sz,
+ efihdr);
+ return (0);
+ }
+ BS->FreePages(addr, pages);
}
-
- efihdr->memory_size = sz;
- efihdr->descriptor_size = mmsz;
- efihdr->descriptor_version = mmver;
-
- file_addmetadata(kfp, MODINFOMD_EFI_MAP, efisz + sz, efihdr);
-
- return (0);
+ printf("ExitBootServices error %lu\n",
+ (unsigned long)(status & ~EFI_ERROR_MASK));
+ return (EINVAL);
}
/*
@@ -315,14 +340,14 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp)
* tested/set by MI code before launching the kernel.
*/
rootdevname = getenv("rootdev");
- x86_efi_getdev((void**)(&rootdev), rootdevname, NULL);
+ archsw.arch_getdev((void**)(&rootdev), rootdevname, NULL);
if (rootdev == NULL) {
printf("Can't determine root device.\n");
return(EINVAL);
}
/* Try reading the /etc/fstab file to select the root device */
- getrootmount(x86_efi_fmtdev((void *)rootdev));
+ getrootmount(efi_fmtdev((void *)rootdev));
addr = 0;
for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
@@ -364,6 +389,6 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp)
/* Copy module list and metadata. */
(void)bi_copymodules(addr);
-
+
return (0);
}
diff --git a/sys/boot/amd64/efi/conf.c b/sys/boot/efi/loader/conf.c
index 97dd352..8c063fd 100644
--- a/sys/boot/amd64/efi/conf.c
+++ b/sys/boot/efi/loader/conf.c
@@ -53,15 +53,6 @@ struct netif_driver *netif_drivers[] = {
NULL
};
-extern struct file_format amd64_elf;
-extern struct file_format amd64_elf_obj;
-
-struct file_format *file_formats[] = {
- &amd64_elf,
- &amd64_elf_obj,
- NULL
-};
-
extern struct console efi_console;
extern struct console comconsole;
extern struct console nullconsole;
diff --git a/sys/boot/amd64/efi/copy.c b/sys/boot/efi/loader/copy.c
index cd8b6da..a7d6bf1 100644
--- a/sys/boot/amd64/efi/copy.c
+++ b/sys/boot/efi/loader/copy.c
@@ -48,7 +48,7 @@ int stage_offset_set = 0;
ssize_t stage_offset;
int
-x86_efi_copy_init(void)
+efi_copy_init(void)
{
EFI_STATUS status;
@@ -65,7 +65,7 @@ x86_efi_copy_init(void)
}
ssize_t
-x86_efi_copyin(const void *src, vm_offset_t dest, const size_t len)
+efi_copyin(const void *src, vm_offset_t dest, const size_t len)
{
if (!stage_offset_set) {
@@ -83,7 +83,7 @@ x86_efi_copyin(const void *src, vm_offset_t dest, const size_t len)
}
ssize_t
-x86_efi_copyout(const vm_offset_t src, void *dest, const size_t len)
+efi_copyout(const vm_offset_t src, void *dest, const size_t len)
{
/* XXX: Callers do not check for failure. */
@@ -97,7 +97,7 @@ x86_efi_copyout(const vm_offset_t src, void *dest, const size_t len)
ssize_t
-x86_efi_readin(const int fd, vm_offset_t dest, const size_t len)
+efi_readin(const int fd, vm_offset_t dest, const size_t len)
{
if (dest + stage_offset + len > staging_end) {
@@ -108,7 +108,7 @@ x86_efi_readin(const int fd, vm_offset_t dest, const size_t len)
}
void
-x86_efi_copy_finish(void)
+efi_copy_finish(void)
{
uint64_t *src, *dst, *last;
diff --git a/sys/boot/amd64/efi/devicename.c b/sys/boot/efi/loader/devicename.c
index aa43628..a9327dc 100644
--- a/sys/boot/amd64/efi/devicename.c
+++ b/sys/boot/efi/loader/devicename.c
@@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
#include <efi.h>
#include <efilib.h>
-static int x86_efi_parsedev(struct devdesc **, const char *, const char **);
+static int efi_parsedev(struct devdesc **, const char *, const char **);
/*
* Point (dev) at an allocated device specifier for the device matching the
@@ -44,7 +44,7 @@ static int x86_efi_parsedev(struct devdesc **, const char *, const char **);
* use that. If not, use the default device.
*/
int
-x86_efi_getdev(void **vdev, const char *devspec, const char **path)
+efi_getdev(void **vdev, const char *devspec, const char **path)
{
struct devdesc **dev = (struct devdesc **)vdev;
int rv;
@@ -54,14 +54,14 @@ x86_efi_getdev(void **vdev, const char *devspec, const char **path)
* use the current device instead.
*/
if (devspec == NULL || *devspec == '/' || !strchr(devspec, ':')) {
- rv = x86_efi_parsedev(dev, getenv("currdev"), NULL);
+ rv = efi_parsedev(dev, getenv("currdev"), NULL);
if (rv == 0 && path != NULL)
*path = devspec;
return (rv);
}
/* Parse the device name off the beginning of the devspec. */
- return (x86_efi_parsedev(dev, devspec, path));
+ return (efi_parsedev(dev, devspec, path));
}
/*
@@ -78,7 +78,7 @@ x86_efi_getdev(void **vdev, const char *devspec, const char **path)
* fs<unit>:
*/
static int
-x86_efi_parsedev(struct devdesc **dev, const char *devspec, const char **path)
+efi_parsedev(struct devdesc **dev, const char *devspec, const char **path)
{
struct devdesc *idev;
struct devsw *dv;
@@ -132,7 +132,7 @@ x86_efi_parsedev(struct devdesc **dev, const char *devspec, const char **path)
}
char *
-x86_efi_fmtdev(void *vdev)
+efi_fmtdev(void *vdev)
{
struct devdesc *dev = (struct devdesc *)vdev;
static char buf[32]; /* XXX device length constant? */
@@ -154,12 +154,12 @@ x86_efi_fmtdev(void *vdev)
* Set currdev to suit the value being supplied in (value)
*/
int
-x86_efi_setcurrdev(struct env_var *ev, int flags, const void *value)
+efi_setcurrdev(struct env_var *ev, int flags, const void *value)
{
struct devdesc *ncurr;
int rv;
- rv = x86_efi_parsedev(&ncurr, value, NULL);
+ rv = efi_parsedev(&ncurr, value, NULL);
if (rv != 0)
return(rv);
diff --git a/sys/boot/amd64/efi/x86_efi.h b/sys/boot/efi/loader/loader_efi.h
index 73a61c8..5819d78 100644
--- a/sys/boot/amd64/efi/x86_efi.h
+++ b/sys/boot/efi/loader/loader_efi.h
@@ -28,22 +28,22 @@
* $FreeBSD$
*/
-#ifndef _X86_EFI_COPY_H_
-#define _X86_EFI_COPY_H_
+#ifndef _LOADER_EFI_COPY_H_
+#define _LOADER_EFI_COPY_H_
-int x86_efi_autoload(void);
+int efi_autoload(void);
-int x86_efi_getdev(void **vdev, const char *devspec, const char **path);
-char *x86_efi_fmtdev(void *vdev);
-int x86_efi_setcurrdev(struct env_var *ev, int flags, const void *value);
+int efi_getdev(void **vdev, const char *devspec, const char **path);
+char *efi_fmtdev(void *vdev);
+int efi_setcurrdev(struct env_var *ev, int flags, const void *value);
-int x86_efi_copy_init(void);
-void x86_efi_copy_finish(void);
+int efi_copy_init(void);
-ssize_t x86_efi_copyin(const void *src, vm_offset_t dest, const size_t len);
-ssize_t x86_efi_copyout(const vm_offset_t src, void *dest, const size_t len);
-ssize_t x86_efi_readin(const int fd, vm_offset_t dest, const size_t len);
+ssize_t efi_copyin(const void *src, vm_offset_t dest, const size_t len);
+ssize_t efi_copyout(const vm_offset_t src, void *dest, const size_t len);
+ssize_t efi_readin(const int fd, vm_offset_t dest, const size_t len);
+void * efi_translate(vm_offset_t ptr);
-extern UINTN x86_efi_mapkey;
+void efi_copy_finish(void);
-#endif /* _X86_EFI_COPY_H_ */
+#endif /* _LOADER_EFI_COPY_H_ */
diff --git a/sys/boot/amd64/efi/main.c b/sys/boot/efi/loader/main.c
index ea4c3e7..e6e13f1 100644
--- a/sys/boot/amd64/efi/main.c
+++ b/sys/boot/efi/loader/main.c
@@ -37,7 +37,8 @@ __FBSDID("$FreeBSD$");
#include <bootstrap.h>
#include <smbios.h>
-#include "x86_efi.h"
+
+#include "loader_efi.h"
extern char bootprog_name[];
extern char bootprog_rev[];
@@ -75,7 +76,7 @@ main(int argc, CHAR16 *argv[])
*/
cons_probe();
- if (x86_efi_copy_init()) {
+ if (efi_copy_init()) {
printf("failed to allocate staging area\n");
return (EFI_BUFFER_TOO_SMALL);
}
@@ -117,18 +118,18 @@ main(int argc, CHAR16 *argv[])
*/
BS->SetWatchdogTimer(0, 0, 0, NULL);
- env_setenv("currdev", EV_VOLATILE, x86_efi_fmtdev(&currdev),
- x86_efi_setcurrdev, env_nounset);
- env_setenv("loaddev", EV_VOLATILE, x86_efi_fmtdev(&currdev), env_noset,
+ env_setenv("currdev", EV_VOLATILE, efi_fmtdev(&currdev),
+ efi_setcurrdev, env_nounset);
+ env_setenv("loaddev", EV_VOLATILE, efi_fmtdev(&currdev), env_noset,
env_nounset);
setenv("LINES", "24", 1); /* optional */
- archsw.arch_autoload = x86_efi_autoload;
- archsw.arch_getdev = x86_efi_getdev;
- archsw.arch_copyin = x86_efi_copyin;
- archsw.arch_copyout = x86_efi_copyout;
- archsw.arch_readin = x86_efi_readin;
+ archsw.arch_autoload = efi_autoload;
+ archsw.arch_getdev = efi_getdev;
+ archsw.arch_copyin = efi_copyin;
+ archsw.arch_copyout = efi_copyout;
+ archsw.arch_readin = efi_readin;
for (i = 0; i < ST->NumberOfTableEntries; i++) {
guid = &ST->ConfigurationTable[i].VendorGuid;
diff --git a/sys/boot/amd64/efi/version b/sys/boot/efi/loader/version
index 3a4c47c..3a4c47c 100644
--- a/sys/boot/amd64/efi/version
+++ b/sys/boot/efi/loader/version
diff --git a/sys/boot/forth/loader.conf b/sys/boot/forth/loader.conf
index 020239a..88f5411 100644
--- a/sys/boot/forth/loader.conf
+++ b/sys/boot/forth/loader.conf
@@ -12,7 +12,7 @@
### Basic configuration options ############################
##############################################################
-exec=".( Loading /boot/defaults/loader.conf ) cr"
+exec="echo Loading /boot/defaults/loader.conf"
kernel="kernel" # /boot sub-directory containing kernel and modules
bootfile="kernel" # Kernel name (possibly absolute path)
@@ -39,7 +39,7 @@ bitmap_type="splash_image_data" # and place it on the module_path
##############################################################
-### Random number generator configuration ###################
+### Random number generator configuration ##################
##############################################################
entropy_cache_load="NO" # Set this to YES to load entropy at boot time
@@ -156,7 +156,7 @@ module_path="/boot/modules" # Set the module search path
##############################################################
-### ATA modules ##############################################
+### ATA modules ############################################
##############################################################
ataacard_load="NO" # ACARD
@@ -378,6 +378,7 @@ if_xe_load="NO" # Xircom CreditCard PCMCIA
if_xl_load="NO" # 3Com Etherlink XL (3c900, 3c905, 3c905B)
utopia_load="NO" # ATM PHY driver
+
##############################################################
### Netgraph modules #######################################
##############################################################
@@ -420,6 +421,7 @@ ng_tty_load="NO" # Netgraph node type that is also a line
ng_vjc_load="NO" # Van Jacobsen compression netgraph node type
ng_vlan_load="NO" # IEEE 802.1Q VLAN tagging netgraph node type
+
##############################################################
### Sound modules ##########################################
##############################################################
@@ -456,6 +458,7 @@ snd_via82c686_load="NO" # via82c686
snd_vibes_load="NO" # vibes
snd_driver_load="NO" # All sound drivers
+
##############################################################
### USB modules ############################################
##############################################################
@@ -488,6 +491,7 @@ if_ural_load="NO" # Ralink RT2500USB 802.11 wireless adapter
if_zyd_load="NO" # ZyDAS ZD1211(B) USB 802.11 wireless adapter
snd_uaudio_load="NO" # USB audio
+
##############################################################
### Other modules ##########################################
##############################################################
@@ -512,6 +516,7 @@ amdtemp_load="NO" # AMD K8/K10/K11 temperature monitor
tpm_load="NO" # Trusted Platform Module
wbwd_load="NO" # Winbond watchdog
+
##############################################################
### ACPI settings ##########################################
##############################################################
@@ -522,8 +527,9 @@ acpi_dsdt_name="/boot/acpi_dsdt.aml"
# Override DSDT in BIOS by this file
acpi_video_load="NO" # Load the ACPI video extension driver
+
##############################################################
-### TrustedBSD MAC settings ##################################
+### TrustedBSD MAC settings ################################
##############################################################
mac_biba_load="NO" # Biba MAC policy
@@ -534,6 +540,7 @@ mac_none_load="NO" # Null MAC policy
mac_partition_load="NO" # Partition MAC policy
mac_seeotheruids_load="NO" # UID visbility MAC policy
+
##############################################################
### Module loading syntax example ##########################
##############################################################
diff --git a/sys/boot/forth/loader.rc b/sys/boot/forth/loader.rc
index b4a6d51..0bc6657 100644
--- a/sys/boot/forth/loader.rc
+++ b/sys/boot/forth/loader.rc
@@ -1,6 +1,9 @@
\ Loader.rc
\ $FreeBSD$
\
+\ You should not edit this file! Put any overrides in loader.rc.local
+\ instead as this file can be replaced during system updates.
+\
\ Includes additional commands
include /boot/loader.4th
try-include /boot/loader.rc.local
diff --git a/sys/boot/forth/menu.rc b/sys/boot/forth/menu.rc
index e650848..7ffeef4 100644
--- a/sys/boot/forth/menu.rc
+++ b/sys/boot/forth/menu.rc
@@ -1,6 +1,9 @@
\ Menu.rc
\ $FreeBSD$
\
+\ You should not edit this file! Put any overrides in menu.rc.local
+\ instead as this file can be replaced during system updates.
+\
\ Load required Forth modules
include /boot/version.4th
include /boot/brand.4th
diff --git a/sys/boot/forth/support.4th b/sys/boot/forth/support.4th
index 7da92bc..6db232b 100644
--- a/sys/boot/forth/support.4th
+++ b/sys/boot/forth/support.4th
@@ -684,7 +684,7 @@ only forth also support-functions also file-processing definitions
s" loader_conf_files" getenv conf_files string=
;
-: set_nextboot_conf \ XXX maybe do as set_conf_files ?
+: set_nextboot_conf
value_buffer strget unquote nextboot_conf_file string=
;
@@ -833,7 +833,7 @@ get-current ( -- wid ) previous definitions >search ( wid -- )
repeat
;
-: peek_file
+: peek_file ( addr len -- )
0 to end_of_file?
reset_line_reading
O_RDONLY fopen fd !
@@ -844,6 +844,7 @@ get-current ( -- wid ) previous definitions >search ( wid -- )
['] process_assignment catch
['] free_buffers catch
fd @ fclose
+ swap throw throw
;
only forth also support-functions definitions
@@ -851,7 +852,6 @@ only forth also support-functions definitions
\ Interface to loading conf files
: load_conf ( addr len -- )
- \ ." ----- Trying conf " 2dup type cr \ debugging
0 to end_of_file?
reset_line_reading
O_RDONLY fopen fd !
@@ -943,7 +943,6 @@ string current_file_name_ref \ used to print the file name
\ loader_conf_files processing support functions
: get_conf_files ( -- addr len ) \ put addr/len on stack, reset var
- \ ." -- starting on <" conf_files strtype ." >" cr \ debugging
conf_files strget 0 0 conf_files strset
;
@@ -970,7 +969,6 @@ string current_file_name_ref \ used to print the file name
pos char+ to pos
repeat
addr len pos addr r@ + pos r> -
- \ 2dup ." get_file_name has " type cr \ debugging
;
: get_next_file ( addr len ptr -- addr len ptr' addr' len' | 0 )
@@ -1021,25 +1019,26 @@ string current_file_name_ref \ used to print the file name
;
: get_nextboot_conf_file ( -- addr len )
- nextboot_conf_file strget strdup \ XXX is the strdup a leak ?
+ nextboot_conf_file strget
;
: rewrite_nextboot_file ( -- )
get_nextboot_conf_file
O_WRONLY fopen fd !
fd @ -1 = if EOPEN throw then
- fd @ s' nextboot_enable="NO" ' fwrite
+ fd @ s' nextboot_enable="NO" ' fwrite ( fd buf len -- nwritten ) drop
fd @ fclose
;
-: include_nextboot_file
+: include_nextboot_file ( -- )
get_nextboot_conf_file
- ['] peek_file catch
+ ['] peek_file catch if 2drop then
nextboot? if
get_nextboot_conf_file
+ current_file_name_ref strref
['] load_conf catch
process_conf_errors
- ['] rewrite_nextboot_file catch
+ ['] rewrite_nextboot_file catch if 2drop then
then
;
diff --git a/sys/boot/i386/efi/bootinfo.c b/sys/boot/i386/efi/bootinfo.c
deleted file mode 100644
index 853d044..0000000
--- a/sys/boot/i386/efi/bootinfo.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * Copyright (c) 2006 Marcel Moolenaar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <stand.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/reboot.h>
-#include <sys/linker.h>
-#include <sys/boot.h>
-
-#include <efi.h>
-#include <efilib.h>
-
-#include "bootstrap.h"
-#include "libi386.h"
-#include <machine/bootinfo.h>
-
-static const char howto_switches[] = "aCdrgDmphsv";
-static int howto_masks[] = {
- RB_ASKNAME, RB_CDROM, RB_KDB, RB_DFLTROOT, RB_GDB, RB_MULTIPLE,
- RB_MUTE, RB_PAUSE, RB_SERIAL, RB_SINGLE, RB_VERBOSE
-};
-
-int
-bi_getboothowto(char *kargs)
-{
- const char *sw;
- char *opts;
- int howto, i;
-
- howto = 0;
-
- /* Get the boot options from the environment first. */
- for (i = 0; howto_names[i].ev != NULL; i++) {
- if (getenv(howto_names[i].ev) != NULL)
- howto |= howto_names[i].mask;
- }
-
- /* Parse kargs */
- if (kargs == NULL)
- return (howto);
-
- opts = strchr(kargs, '-');
- while (opts != NULL) {
- while (*(++opts) != '\0') {
- sw = strchr(howto_switches, *opts);
- if (sw == NULL)
- break;
- howto |= howto_masks[sw - howto_switches];
- }
- opts = strchr(opts, '-');
- }
-
- return (howto);
-}
-
-/*
- * Copy the environment into the load area starting at (addr).
- * Each variable is formatted as <name>=<value>, with a single nul
- * separating each variable, and a double nul terminating the environment.
- */
-vm_offset_t
-bi_copyenv(vm_offset_t start)
-{
- struct env_var *ep;
- vm_offset_t addr, last;
- size_t len;
-
- addr = last = start;
-
- /* Traverse the environment. */
- for (ep = environ; ep != NULL; ep = ep->ev_next) {
- len = strlen(ep->ev_name);
- if (i386_copyin(ep->ev_name, addr, len) != len)
- break;
- addr += len;
- if (i386_copyin("=", addr, 1) != 1)
- break;
- addr++;
- if (ep->ev_value != NULL) {
- len = strlen(ep->ev_value);
- if (i386_copyin(ep->ev_value, addr, len) != len)
- break;
- addr += len;
- }
- if (i386_copyin("", addr, 1) != 1)
- break;
- last = ++addr;
- }
-
- if (i386_copyin("", last++, 1) != 1)
- last = start;
- return(last);
-}
-
-/*
- * Copy module-related data into the load area, where it can be
- * used as a directory for loaded modules.
- *
- * Module data is presented in a self-describing format. Each datum
- * is preceded by a 32-bit identifier and a 32-bit size field.
- *
- * Currently, the following data are saved:
- *
- * MOD_NAME (variable) module name (string)
- * MOD_TYPE (variable) module type (string)
- * MOD_ARGS (variable) module parameters (string)
- * MOD_ADDR sizeof(vm_offset_t) module load address
- * MOD_SIZE sizeof(size_t) module size
- * MOD_METADATA (variable) type-specific metadata
- */
-#define COPY32(v, a) { \
- u_int32_t x = (v); \
- i386_copyin(&x, a, sizeof(x)); \
- a += sizeof(x); \
-}
-
-#define MOD_STR(t, a, s) { \
- COPY32(t, a); \
- COPY32(strlen(s) + 1, a); \
- i386_copyin(s, a, strlen(s) + 1); \
- a += roundup(strlen(s) + 1, sizeof(u_int64_t));\
-}
-
-#define MOD_NAME(a, s) MOD_STR(MODINFO_NAME, a, s)
-#define MOD_TYPE(a, s) MOD_STR(MODINFO_TYPE, a, s)
-#define MOD_ARGS(a, s) MOD_STR(MODINFO_ARGS, a, s)
-
-#define MOD_VAR(t, a, s) { \
- COPY32(t, a); \
- COPY32(sizeof(s), a); \
- i386_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(u_int64_t)); \
-}
-
-#define MOD_ADDR(a, s) MOD_VAR(MODINFO_ADDR, a, s)
-#define MOD_SIZE(a, s) MOD_VAR(MODINFO_SIZE, a, s)
-
-#define MOD_METADATA(a, mm) { \
- COPY32(MODINFO_METADATA | mm->md_type, a); \
- COPY32(mm->md_size, a); \
- i386_copyin(mm->md_data, a, mm->md_size); \
- a += roundup(mm->md_size, sizeof(u_int64_t));\
-}
-
-#define MOD_END(a) { \
- COPY32(MODINFO_END, a); \
- COPY32(0, a); \
-}
-
-vm_offset_t
-bi_copymodules(vm_offset_t addr)
-{
- struct preloaded_file *fp;
- struct file_metadata *md;
-
- /* Start with the first module on the list, should be the kernel. */
- for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) {
- /* The name field must come first. */
- MOD_NAME(addr, fp->f_name);
- MOD_TYPE(addr, fp->f_type);
- if (fp->f_args)
- MOD_ARGS(addr, fp->f_args);
- MOD_ADDR(addr, fp->f_addr);
- MOD_SIZE(addr, fp->f_size);
- for (md = fp->f_metadata; md != NULL; md = md->md_next) {
- if (!(md->md_type & MODINFOMD_NOCOPY))
- MOD_METADATA(addr, md);
- }
- }
- MOD_END(addr);
- return(addr);
-}
-
-/*
- * Load the information expected by the kernel.
- *
- * - The kernel environment is copied into kernel space.
- * - Module metadata are formatted and placed in kernel space.
- */
-int
-bi_load(struct preloaded_file *fp, uint64_t *bi_addr)
-{
- struct bootinfo bi;
- struct preloaded_file *xp;
- struct file_metadata *md;
- struct devdesc *rootdev;
- char *rootdevname;
- vm_offset_t addr, ssym, esym;
-
- bzero(&bi, sizeof(struct bootinfo));
- bi.bi_version = 1;
-// bi.bi_boothowto = bi_getboothowto(fp->f_args);
-
- /*
- * Allow the environment variable 'rootdev' to override the supplied
- * device. This should perhaps go to MI code and/or have $rootdev
- * tested/set by MI code before launching the kernel.
- */
- rootdevname = getenv("rootdev");
- i386_getdev((void**)&rootdev, rootdevname, NULL);
- if (rootdev != NULL) {
- /* Try reading /etc/fstab to select the root device. */
- getrootmount(i386_fmtdev(rootdev));
- free(rootdev);
- }
-
- md = file_findmetadata(fp, MODINFOMD_SSYM);
- ssym = (md != NULL) ? *((vm_offset_t *)&(md->md_data)) : 0;
- md = file_findmetadata(fp, MODINFOMD_ESYM);
- esym = (md != NULL) ? *((vm_offset_t *)&(md->md_data)) : 0;
- if (ssym != 0 && esym != 0) {
- bi.bi_symtab = ssym;
- bi.bi_esymtab = esym;
- }
-
- /* Find the last module in the chain. */
- addr = 0;
- for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
- if (addr < (xp->f_addr + xp->f_size))
- addr = xp->f_addr + xp->f_size;
- }
-
- addr = (addr + 15) & ~15;
-
- /* Copy module list and metadata. */
- bi.bi_modulep = addr;
- addr = bi_copymodules(addr);
- if (addr <= bi.bi_modulep) {
- addr = bi.bi_modulep;
- bi.bi_modulep = 0;
- }
-
- addr = (addr + 15) & ~15;
-
- /* Copy our environment. */
- bi.bi_envp = addr;
- addr = bi_copyenv(addr);
- if (addr <= bi.bi_envp) {
- addr = bi.bi_envp;
- bi.bi_envp = 0;
- }
-
- addr = (addr + PAGE_MASK) & ~PAGE_MASK;
- bi.bi_kernend = addr;
-
- return (ldr_bootinfo(&bi, bi_addr));
-}
diff --git a/sys/boot/i386/efi/efimd.c b/sys/boot/i386/efi/efimd.c
deleted file mode 100644
index 01905e6..0000000
--- a/sys/boot/i386/efi/efimd.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*-
- * Copyright (c) 2004, 2006 Marcel Moolenaar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <stand.h>
-
-#include <efi.h>
-#include <efilib.h>
-
-#include <libi386.h>
-#include <machine/bootinfo.h>
-
-#define EFI_INTEL_FPSWA \
- {0xc41b6531,0x97b9,0x11d3,{0x9a,0x29,0x00,0x90,0x27,0x3f,0xc1,0x4d}}
-
-static EFI_GUID fpswa_guid = EFI_INTEL_FPSWA;
-
-/* DIG64 Headless Console & Debug Port Table. */
-#define HCDP_TABLE_GUID \
- {0xf951938d,0x620b,0x42ef,{0x82,0x79,0xa8,0x4b,0x79,0x61,0x78,0x98}}
-
-static EFI_GUID hcdp_guid = HCDP_TABLE_GUID;
-
-static UINTN mapkey;
-
-uint64_t
-ldr_alloc(vm_offset_t va)
-{
-
- return (0);
-}
-
-int
-ldr_bootinfo(struct bootinfo *bi, uint64_t *bi_addr)
-{
- VOID *fpswa;
- EFI_MEMORY_DESCRIPTOR *mm;
- EFI_PHYSICAL_ADDRESS addr;
- EFI_HANDLE handle;
- EFI_STATUS status;
- size_t bisz;
- UINTN mmsz, pages, sz;
- UINT32 mmver;
-
- bi->bi_systab = (uint64_t)ST;
- bi->bi_hcdp = (uint64_t)efi_get_table(&hcdp_guid);
-
- sz = sizeof(EFI_HANDLE);
- status = BS->LocateHandle(ByProtocol, &fpswa_guid, 0, &sz, &handle);
- if (status == 0)
- status = BS->HandleProtocol(handle, &fpswa_guid, &fpswa);
- bi->bi_fpswa = (status == 0) ? (uint64_t)fpswa : 0;
-
- bisz = (sizeof(struct bootinfo) + 0x0f) & ~0x0f;
-
- /*
- * Allocate enough pages to hold the bootinfo block and the memory
- * map EFI will return to us. The memory map has an unknown size,
- * so we have to determine that first. Note that the AllocatePages
- * call can itself modify the memory map, so we have to take that
- * into account as well. The changes to the memory map are caused
- * by splitting a range of free memory into two (AFAICT), so that
- * one is marked as being loader data.
- */
- sz = 0;
- BS->GetMemoryMap(&sz, NULL, &mapkey, &mmsz, &mmver);
- sz += mmsz;
- sz = (sz + 15) & ~15;
- pages = EFI_SIZE_TO_PAGES(sz + bisz);
- status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, pages,
- &addr);
- if (EFI_ERROR(status)) {
- printf("%s: AllocatePages() returned 0x%lx\n", __func__,
- (long)status);
- return (ENOMEM);
- }
-
- /*
- * Read the memory map and stash it after bootinfo. Align the
- * memory map on a 16-byte boundary (the bootinfo block is page
- * aligned).
- */
- *bi_addr = addr;
- mm = (void *)(addr + bisz);
- sz = (EFI_PAGE_SIZE * pages) - bisz;
- status = BS->GetMemoryMap(&sz, mm, &mapkey, &mmsz, &mmver);
- if (EFI_ERROR(status)) {
- printf("%s: GetMemoryMap() returned 0x%lx\n", __func__,
- (long)status);
- return (EINVAL);
- }
- bi->bi_memmap = (uint64_t)mm;
- bi->bi_memmap_size = sz;
- bi->bi_memdesc_size = mmsz;
- bi->bi_memdesc_version = mmver;
-
- bcopy(bi, (void *)(*bi_addr), sizeof(*bi));
- return (0);
-}
-
-int
-ldr_enter(const char *kernel)
-{
- EFI_STATUS status;
-
- status = BS->ExitBootServices(IH, mapkey);
- if (EFI_ERROR(status)) {
- printf("%s: ExitBootServices() returned 0x%lx\n", __func__,
- (long)status);
- return (EINVAL);
- }
-
- return (0);
-}
diff --git a/sys/boot/i386/efi/elf32_freebsd.c b/sys/boot/i386/efi/elf32_freebsd.c
deleted file mode 100644
index f193735..0000000
--- a/sys/boot/i386/efi/elf32_freebsd.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/exec.h>
-#include <sys/linker.h>
-#include <string.h>
-#include <machine/bootinfo.h>
-#include <machine/elf.h>
-#include <stand.h>
-
-#include "bootstrap.h"
-#include "../libi386/libi386.h"
-#include "../btx/lib/btxv86.h"
-
-extern void __exec(caddr_t addr, ...);
-
-
-static int elf32_exec(struct preloaded_file *amp);
-static int elf32_obj_exec(struct preloaded_file *amp);
-
-struct file_format i386_elf = { elf32_loadfile, elf32_exec };
-struct file_format i386_elf_obj = { elf32_obj_loadfile, elf32_obj_exec };
-
-/*
- * There is an ELF kernel and one or more ELF modules loaded.
- * We wish to start executing the kernel image, so make such
- * preparations as are required, and do so.
- */
-static int
-elf32_exec(struct preloaded_file *fp)
-{
- struct file_metadata *md;
- Elf_Ehdr *ehdr;
- vm_offset_t entry, bootinfop, modulep, kernend;
- int boothowto, err, bootdev;
-
- if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
- return(EFTYPE);
- ehdr = (Elf_Ehdr *)&(md->md_data);
-
- err = bi_load(fp->f_args, &boothowto, &bootdev, &bootinfop, &modulep, &kernend);
- if (err != 0)
- return(err);
- entry = ehdr->e_entry & 0xffffff;
-
- printf("Start @ 0x%lx ...\n", entry);
-
- ldr_enter(fp->f_name);
-
- dev_cleanup();
- __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop, modulep, kernend);
-
- panic("exec returned");
-}
-
-static int
-elf32_obj_exec(struct preloaded_file *fp)
-{
- return (EFTYPE);
-}
diff --git a/sys/boot/i386/efi/exec.c b/sys/boot/i386/efi/exec.c
deleted file mode 100644
index 579f559..0000000
--- a/sys/boot/i386/efi/exec.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * Copyright (c) 2010 Rui Paulo <rpaulo@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <stand.h>
-#include <machine/elf.h>
-#include "../btx/lib/btxv86.h"
-
-#include "../../common/bootstrap.h"
-
-uint32_t __base;
-struct __v86 __v86;
-
-void
-__v86int()
-{
- printf("%s\n", __func__);
- exit(1);
-}
-
-void
-__exec(caddr_t addr, ...)
-{
-}
diff --git a/sys/boot/i386/efi/i386_copy.c b/sys/boot/i386/efi/i386_copy.c
deleted file mode 100644
index 43c26ce..0000000
--- a/sys/boot/i386/efi/i386_copy.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * MD primitives supporting placement of module data
- *
- * XXX should check load address/size against memory top.
- */
-#include <stand.h>
-
-#include "libi386.h"
-#include "btxv86.h"
-
-ssize_t
-i386_copyin(const void *src, vm_offset_t dest, const size_t len)
-{
- bcopy(src, PTOV(dest), len);
- return(len);
-}
-
-ssize_t
-i386_copyout(const vm_offset_t src, void *dest, const size_t len)
-{
- bcopy(PTOV(src), dest, len);
- return(len);
-}
-
-
-ssize_t
-i386_readin(const int fd, vm_offset_t dest, const size_t len)
-{
- return (read(fd, PTOV(dest), len));
-}
diff --git a/sys/boot/i386/efi/ldscript.i386 b/sys/boot/i386/efi/ldscript.i386
deleted file mode 100644
index fdfda0a..0000000
--- a/sys/boot/i386/efi/ldscript.i386
+++ /dev/null
@@ -1,72 +0,0 @@
-/* $FreeBSD$ */
-OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd", "elf32-i386-freebsd")
-OUTPUT_ARCH(i386)
-ENTRY(_start)
-SECTIONS
-{
- /* Read-only sections, merged into text segment: */
- . = 0;
- ImageBase = .;
- . = SIZEOF_HEADERS;
- . = ALIGN(4096);
- .text : {
- *(.text .stub .text.* .gnu.linkonce.t.*)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- *(.plt)
- } =0x00300000010070000002000001000400
- . = ALIGN(4096);
- .data : {
- *(.rodata .rodata.* .gnu.linkonce.r.*)
- *(.rodata1)
- *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
- *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
- *(.opd)
- *(.data .data.* .gnu.linkonce.d.*)
- *(.data1)
- *(.plabel)
- *(.dynbss)
- *(.bss .bss.* .gnu.linkonce.b.*)
- *(COMMON)
- }
- . = ALIGN(4096);
- set_Xcommand_set : {
- __start_set_Xcommand_set = .;
- *(set_Xcommand_set)
- __stop_set_Xcommand_set = .;
- }
- . = ALIGN(4096);
- __gp = .;
- .sdata : {
- *(.got.plt .got)
- *(.sdata .sdata.* .gnu.linkonce.s.*)
- *(dynsbss)
- *(.sbss .sbss.* .gnu.linkonce.sb.*)
- *(.scommon)
- }
- . = ALIGN(4096);
- .dynamic : { *(.dynamic) }
- . = ALIGN(4096);
- .rel.dyn : {
- *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
- *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
- *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
- *(.rel.got)
- *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
- *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
- *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
- *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
- *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
- *(.rel.plt)
- *(.relset_*)
- *(.rel.dyn .rel.dyn.*)
- }
- . = ALIGN(4096);
- .reloc : { *(.reloc) }
- . = ALIGN(4096);
- .hash : { *(.hash) }
- . = ALIGN(4096);
- .dynsym : { *(.dynsym) }
- . = ALIGN(4096);
- .dynstr : { *(.dynstr) }
-}
diff --git a/sys/boot/i386/efi/reloc.c b/sys/boot/i386/efi/reloc.c
deleted file mode 100644
index 22c6642..0000000
--- a/sys/boot/i386/efi/reloc.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * Copyright (c) 2008-2010 Rui Paulo <rpaulo@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <elf.h>
-#include <efi.h>
-#include <bootstrap.h>
-
-#ifdef __i386__
-#define ElfW_Rel Elf32_Rel
-#define ElfW_Dyn Elf32_Dyn
-#define ELFW_R_TYPE ELF32_R_TYPE
-#elif __amd64__
-#define ElfW_Rel Elf64_Rel
-#define ElfW_Dyn Elf64_Dyn
-#define ELFW_R_TYPE ELF64_R_TYPE
-#endif
-
-/*
- * A simple relocator for IA32/AMD64 EFI binaries.
- */
-EFI_STATUS
-_reloc(unsigned long ImageBase, ElfW_Dyn *dynamic, EFI_HANDLE image_handle,
- EFI_SYSTEM_TABLE *system_table)
-{
- unsigned long relsz, relent;
- unsigned long *newaddr;
- ElfW_Rel *rel;
- ElfW_Dyn *dynp;
-
- /*
- * Find the relocation address, its size and the relocation entry.
- */
- relsz = 0;
- relent = 0;
- for (dynp = dynamic; dynp->d_tag != DT_NULL; dynp++) {
- switch (dynp->d_tag) {
- case DT_RELA:
- case DT_REL:
- rel = (ElfW_Rel *) ((unsigned long) dynp->d_un.d_ptr +
- ImageBase);
- break;
- case DT_RELSZ:
- case DT_RELASZ:
- relsz = dynp->d_un.d_val;
- break;
- case DT_RELENT:
- case DT_RELAENT:
- relent = dynp->d_un.d_val;
- break;
- default:
- break;
- }
- }
-
- /*
- * Perform the actual relocation.
- * XXX: We are reusing code for the amd64 version of this, but
- * we must make sure the relocation types are the same.
- */
- CTASSERT(R_386_NONE == R_X86_64_NONE);
- CTASSERT(R_386_RELATIVE == R_X86_64_RELATIVE);
- for (; relsz > 0; relsz -= relent) {
- switch (ELFW_R_TYPE(rel->r_info)) {
- case R_386_NONE:
- /* No relocation needs be performed. */
- break;
- case R_386_RELATIVE:
- /* Address relative to the base address. */
- newaddr = (unsigned long *)(ImageBase + rel->r_offset);
- *newaddr += ImageBase;
- break;
- default:
- /* XXX: do we need other relocations ? */
- break;
- }
- rel = (ElfW_Rel *) ((caddr_t) rel + relent);
- }
-
- return (EFI_SUCCESS);
-}
diff --git a/sys/boot/i386/efi/start.S b/sys/boot/i386/efi/start.S
deleted file mode 100644
index ea4597f..0000000
--- a/sys/boot/i386/efi/start.S
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * Copyright (c) 2008-2010 Rui Paulo <rpaulo@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
- .text
-
-#include <machine/asm.h>
-
-#define EFI_SUCCESS 0
-
-/*
- * EFI entry point.
- * _start(EFI_IMAGE image_handle, EFI_SYSTEM_TABLE *system_table);
- *
- * We calculate the base address along with _DYNAMIC, relocate us and finally
- * pass control to efi_main.
- */
-
-ENTRY(_start)
- pushl %ebp
- movl %esp, %ebp
-
- pushl 12(%ebp) /* image_handle */
- pushl 8(%ebp) /* system_table */
- call 0f
-0: popl %eax
- movl %eax, %ebx
- addl $ImageBase-0b, %eax
- addl $_DYNAMIC-0b, %ebx
- pushl %ebx /* dynamic */
- pushl %eax /* ImageBase */
- call _reloc
- cmpl $EFI_SUCCESS, %eax
- jne 1f
- popl %ebx /* remove ImageBase from the stack */
- popl %ebx /* remove dynamic from the stack */
- call efi_main
-1: leave
- ret
-END(_start)
-
- .data
- .section .reloc, "a"
- .long 0
- .long 10
- .word 0
diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile
index 9f2f1b2..1ab909d3 100644
--- a/sys/boot/i386/loader/Makefile
+++ b/sys/boot/i386/loader/Makefile
@@ -108,12 +108,7 @@ FILESMODE_${LOADER}= ${BINMODE} -b
.PATH: ${.CURDIR}/../../forth
.include "${.CURDIR}/../../forth/Makefile.inc"
-.if !exists(${DESTDIR}/boot/loader.rc)
-FILES+= loader.rc
-.endif
-.if !exists(${DESTDIR}/boot/menu.rc)
-FILES+= menu.rc
-.endif
+FILES+= loader.rc menu.rc
.endif
# XXX crt0.o needs to be first for pxeboot(8) to work
diff --git a/sys/boot/pc98/loader/Makefile b/sys/boot/pc98/loader/Makefile
index 3eafed4..13b9520 100644
--- a/sys/boot/pc98/loader/Makefile
+++ b/sys/boot/pc98/loader/Makefile
@@ -89,12 +89,7 @@ FILESMODE_${LOADER}= ${BINMODE} -b
.PATH: ${.CURDIR}/../../forth
.include "${.CURDIR}/../../forth/Makefile.inc"
-.if !exists(${DESTDIR}/boot/loader.rc)
-FILES+= ${.CURDIR}/../../i386/loader/loader.rc
-.endif
-.if !exists(${DESTDIR}/boot/menu.rc)
-FILES+= menu.rc
-.endif
+FILES+= ${.CURDIR}/../../i386/loader/loader.rc menu.rc
# XXX crt0.o needs to be first for pxeboot(8) to work
OBJS= ${BTXCRT}
diff --git a/sys/boot/powerpc/ofw/Makefile b/sys/boot/powerpc/ofw/Makefile
index fbde1e7..83112d1 100644
--- a/sys/boot/powerpc/ofw/Makefile
+++ b/sys/boot/powerpc/ofw/Makefile
@@ -105,12 +105,6 @@ loader.help: help.common help.ofw
.PATH: ${.CURDIR}/../../forth
.include "${.CURDIR}/../../forth/Makefile.inc"
-.if !exists(${DESTDIR}/boot/loader.rc)
-FILES+= loader.rc
-.endif
-
-.if !exists(${DESTDIR}/boot/menu.rc)
-FILES+= menu.rc
-.endif
+FILES+= loader.rc menu.rc
.include <bsd.prog.mk>
diff --git a/sys/boot/powerpc/ps3/Makefile b/sys/boot/powerpc/ps3/Makefile
index a90a92c..4c67c15 100644
--- a/sys/boot/powerpc/ps3/Makefile
+++ b/sys/boot/powerpc/ps3/Makefile
@@ -116,12 +116,6 @@ loader.help: help.common help.ps3 ${.CURDIR}/../../fdt/help.fdt
.PATH: ${.CURDIR}/../../forth
.include "${.CURDIR}/../../forth/Makefile.inc"
-.if !exists(${DESTDIR}/boot/loader.rc)
-FILES+= loader.rc
-.endif
-
-.if !exists(${DESTDIR}/boot/menu.rc)
-FILES+= menu.rc
-.endif
+FILES+= loader.rc menu.rc
.include <bsd.prog.mk>
diff --git a/sys/boot/sparc64/loader/Makefile b/sys/boot/sparc64/loader/Makefile
index 06c9838..92e5a95 100644
--- a/sys/boot/sparc64/loader/Makefile
+++ b/sys/boot/sparc64/loader/Makefile
@@ -98,12 +98,6 @@ loader.help: help.common help.sparc64
.PATH: ${.CURDIR}/../../forth
.include "${.CURDIR}/../../forth/Makefile.inc"
-.if !exists(${DESTDIR}/boot/loader.rc)
-FILES+= loader.rc
-.endif
-
-.if !exists(${DESTDIR}/boot/menu.rc)
-FILES+= menu.rc
-.endif
+FILES+= loader.rc menu.rc
.include <bsd.prog.mk>
OpenPOWER on IntegriCloud