Browse Source

[efi] Add %.usb target for building EFI-bootable USB (or other) disk images

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
7f65a08f3e
4 changed files with 72 additions and 0 deletions
  1. 4
    0
      src/arch/i386/Makefile.efi
  2. 4
    0
      src/arch/x86/Makefile.efi
  3. 4
    0
      src/arch/x86_64/Makefile.efi
  4. 60
    0
      src/util/genefidsk

+ 4
- 0
src/arch/i386/Makefile.efi View File

8
 #
8
 #
9
 CFLAGS		+= -malign-double
9
 CFLAGS		+= -malign-double
10
 
10
 
11
+# Specify EFI boot file
12
+#
13
+EFI_BOOT_FILE	= bootia32.efi
14
+
11
 # Include generic EFI Makefile
15
 # Include generic EFI Makefile
12
 #
16
 #
13
 MAKEDEPS	+= arch/x86/Makefile.efi
17
 MAKEDEPS	+= arch/x86/Makefile.efi

+ 4
- 0
src/arch/x86/Makefile.efi View File

40
 $(BIN)/efidrv.cab : $(BIN)/alldrv.efis # $(ALL_drv.efi) is not yet defined
40
 $(BIN)/efidrv.cab : $(BIN)/alldrv.efis # $(ALL_drv.efi) is not yet defined
41
 	$(QM)$(ECHO) "  [CAB] $@"
41
 	$(QM)$(ECHO) "  [CAB] $@"
42
 	$(Q)$(LCAB) -n -q $(ALL_drv.efi) $@
42
 	$(Q)$(LCAB) -n -q $(ALL_drv.efi) $@
43
+
44
+$(BIN)/%.usb : $(BIN)/%.efi
45
+	$(QM)$(ECHO) "  [GENEFIDSK] $@"
46
+	$(Q)bash util/genefidsk -o $@ -b $(EFI_BOOT_FILE) $<

+ 4
- 0
src/arch/x86_64/Makefile.efi View File

8
 #
8
 #
9
 ELF2EFI		= $(ELF2EFI64)
9
 ELF2EFI		= $(ELF2EFI64)
10
 
10
 
11
+# Specify EFI boot file
12
+#
13
+EFI_BOOT_FILE	= bootx64.efi
14
+
11
 # Include generic EFI Makefile
15
 # Include generic EFI Makefile
12
 #
16
 #
13
 MAKEDEPS	+= arch/x86/Makefile.efi
17
 MAKEDEPS	+= arch/x86/Makefile.efi

+ 60
- 0
src/util/genefidsk View File

1
+#!/bin/sh
2
+#
3
+# Generate an EFI bootable disk image
4
+
5
+set -e
6
+
7
+function help() {
8
+	echo "Usage: ${0} [OPTIONS] <ipxe.efi>"
9
+	echo
10
+	echo "where OPTIONS are:"
11
+	echo " -h       Show this help"
12
+	echo " -b       Specify boot file name (e.g. bootx64.efi)"
13
+	echo " -o FILE  Save disk image to file"
14
+}
15
+
16
+BOOT=bootx64.efi
17
+
18
+while getopts "hb:o:" opt; do
19
+	case ${opt} in
20
+		h)
21
+			help
22
+			exit 0
23
+			;;
24
+		b)
25
+			BOOT="${OPTARG}"
26
+			;;
27
+		o)
28
+			OUT="${OPTARG}"
29
+			;;
30
+	esac
31
+done
32
+
33
+shift $((OPTIND - 1))
34
+IN=$1
35
+
36
+if [ -z "${IN}" ]; then
37
+	echo "${0}: no input file given" >&2
38
+	help
39
+	exit 1
40
+fi
41
+
42
+if [ -z "${OUT}" ]; then
43
+	echo "${0}: no output file given" >&2
44
+	help
45
+	exit 1
46
+fi
47
+
48
+# Create sparse output file
49
+rm -f ${OUT}
50
+truncate -s 1440K ${OUT}
51
+
52
+# Format disk
53
+mformat -i ${OUT} -f 1440 ::
54
+
55
+# Create directory structure
56
+mmd -i ${OUT} ::efi
57
+mmd -i ${OUT} ::efi/boot
58
+
59
+# Copy bootable image
60
+mcopy -i ${OUT} ${IN} ::efi/boot/${BOOT}

Loading…
Cancel
Save