From owner-svn-src-all@FreeBSD.ORG Sat Apr 26 16:34:23 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E2D757BF; Sat, 26 Apr 2014 16:34:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C275B1B92; Sat, 26 Apr 2014 16:34:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3QGYNAS028170; Sat, 26 Apr 2014 16:34:23 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3QGYNv4028165; Sat, 26 Apr 2014 16:34:23 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201404261634.s3QGYNv4028165@svn.freebsd.org> From: Nathan Whitehorn Date: Sat, 26 Apr 2014 16:34:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264975 - head/sys/boot/amd64/boot1.efi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Apr 2014 16:34:24 -0000 Author: nwhitehorn Date: Sat Apr 26 16:34:22 2014 New Revision: 264975 URL: http://svnweb.freebsd.org/changeset/base/264975 Log: Add generation of an EFI filesystem to hold boot1.efi. This is a near-exact copy of the code from boot1.chrp again. The resulting image is installed to /boot/boot1.efifat. If dd'ed to an 800K "efi" partition, it should result in a bootable system. Added: head/sys/boot/amd64/boot1.efi/Makefile.fat (contents, props changed) head/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu (contents, props changed) head/sys/boot/amd64/boot1.efi/generate-fat.sh (contents, props changed) Modified: head/sys/boot/amd64/boot1.efi/Makefile Modified: head/sys/boot/amd64/boot1.efi/Makefile ============================================================================== --- head/sys/boot/amd64/boot1.efi/Makefile Sat Apr 26 16:12:39 2014 (r264974) +++ head/sys/boot/amd64/boot1.efi/Makefile Sat Apr 26 16:34:22 2014 (r264975) @@ -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 Added: head/sys/boot/amd64/boot1.efi/Makefile.fat ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/amd64/boot1.efi/Makefile.fat Sat Apr 26 16:34:22 2014 (r264975) @@ -0,0 +1,3 @@ +# This file autogenerated by generate-fat.sh - DO NOT EDIT +# $FreeBSD$ +BOOT1_OFFSET=0x2d Added: head/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu Sat Apr 26 16:34:22 2014 (r264975) @@ -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&(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*%$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 Added: head/sys/boot/amd64/boot1.efi/generate-fat.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/amd64/boot1.efi/generate-fat.sh Sat Apr 26 16:34:22 2014 (r264975) @@ -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 +