Explorar el Código

[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 hace 9 años
padre
commit
7f65a08f3e
Se han modificado 4 ficheros con 72 adiciones y 0 borrados
  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 Ver fichero

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

+ 4
- 0
src/arch/x86/Makefile.efi Ver fichero

@@ -40,3 +40,7 @@ $(BIN)/%.efirom : $(BIN)/%.efidrv $(EFIROM)
40 40
 $(BIN)/efidrv.cab : $(BIN)/alldrv.efis # $(ALL_drv.efi) is not yet defined
41 41
 	$(QM)$(ECHO) "  [CAB] $@"
42 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 Ver fichero

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

+ 60
- 0
src/util/genefidsk Ver fichero

@@ -0,0 +1,60 @@
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…
Cancelar
Guardar