aboutsummaryrefslogtreecommitdiff
path: root/sys/boot
diff options
context:
space:
mode:
authorNathan Whitehorn <nwhitehorn@FreeBSD.org>2014-04-26 16:34:22 +0000
committerNathan Whitehorn <nwhitehorn@FreeBSD.org>2014-04-26 16:34:22 +0000
commite9bee2c689b78173a301e31349573ecf809afeec (patch)
tree9cbad524111adf7e182fdb9e9762520c31b8b640 /sys/boot
parent4b29ef64b216bb0a81a8567f87e1be4cfd34a9ea (diff)
Notes
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/amd64/boot1.efi/Makefile16
-rw-r--r--sys/boot/amd64/boot1.efi/Makefile.fat3
-rw-r--r--sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu22
-rwxr-xr-xsys/boot/amd64/boot1.efi/generate-fat.sh54
4 files changed, 94 insertions, 1 deletions
diff --git a/sys/boot/amd64/boot1.efi/Makefile b/sys/boot/amd64/boot1.efi/Makefile
index 55752a23ea9f..641861ed00a6 100644
--- a/sys/boot/amd64/boot1.efi/Makefile
+++ b/sys/boot/amd64/boot1.efi/Makefile
@@ -26,7 +26,7 @@ CFLAGS+= -I${.CURDIR}/../../..
.PATH: ${.CURDIR}/../efi ${.CURDIR}/../../common
CFLAGS+= -I${.CURDIR}/../../common
-FILES= boot1.efi
+FILES= boot1.efi boot1.efifat
FILESMODE_boot1.efi= ${BINMODE}
LDSCRIPT= ${.CURDIR}/../efi/ldscript.${MACHINE_CPUARCH}
@@ -57,6 +57,20 @@ CFLAGS+= -I${.CURDIR}/../../common
boot1.o: ${.CURDIR}/../../common/ufsread.c
+# The following inserts out objects into a template FAT file system
+# created by generate-fat.sh
+
+.include "${.CURDIR}/Makefile.fat"
+
+boot1.efifat: boot1.efi
+ echo ${.OBJDIR}
+ uudecode ${.CURDIR}/fat.tmpl.bz2.uu
+ mv fat.tmpl.bz2 ${.TARGET}.bz2
+ bzip2 -f -d ${.TARGET}.bz2
+ dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
+
+CLEANFILES= boot1.efifat
+
.endif # ${COMPILER_TYPE} != "gcc"
.include <bsd.prog.mk>
diff --git a/sys/boot/amd64/boot1.efi/Makefile.fat b/sys/boot/amd64/boot1.efi/Makefile.fat
new file mode 100644
index 000000000000..324481e1a315
--- /dev/null
+++ b/sys/boot/amd64/boot1.efi/Makefile.fat
@@ -0,0 +1,3 @@
+# This file autogenerated by generate-fat.sh - DO NOT EDIT
+# $FreeBSD$
+BOOT1_OFFSET=0x2d
diff --git a/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu b/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu
new file mode 100644
index 000000000000..2af42444810f
--- /dev/null
+++ b/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu
@@ -0,0 +1,22 @@
+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/amd64/boot1.efi/generate-fat.sh b/sys/boot/amd64/boot1.efi/generate-fat.sh
new file mode 100755
index 000000000000..eafd3e00dfe2
--- /dev/null
+++ b/sys/boot/amd64/boot1.efi/generate-fat.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# This script generates the dummy FAT filesystem used for the EFI boot
+# blocks. It uses newfs_msdos to generate a template filesystem with the
+# relevant interesting files. These are then found by grep, and the offsets
+# written to a Makefile snippet.
+#
+# Because it requires root, and because it is overkill, we do not
+# do this as part of the normal build. If makefs(8) grows workable FAT
+# support, this should be revisited.
+
+# $FreeBSD$
+
+FAT_SIZE=1600 #Size in 512-byte blocks of the produced image
+
+BOOT1_SIZE=64k
+
+# 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
+mkdir stub
+mount -t msdosfs /dev/$DEVICE stub
+
+# Create and bless a directory for the boot loader
+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
+
+umount stub
+mdconfig -d -u $DEVICE
+rmdir stub
+
+# Locate the offsets of the two fake files
+BOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'Boot1 START' | cut -f 1 -d ' ')
+
+# Convert to numbers 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
+echo '# $FreeBSD$' >> Makefile.fat
+echo "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.fat
+
+bzip2 $OUTPUT_FILE
+echo 'FAT template boot filesystem created by generate-fat.sh' > $OUTPUT_FILE.bz2.uu
+echo 'DO NOT EDIT' >> $OUTPUT_FILE.bz2.uu
+echo '$FreeBSD$' >> $OUTPUT_FILE.bz2.uu
+
+uuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu
+rm $OUTPUT_FILE.bz2
+