run/load/ipxe: support ISO and UEFI images

Patch by Roman Iten and Pirmin Duss.
This commit is contained in:
Christian Helmuth 2022-07-08 09:16:06 +02:00
parent 789a60278c
commit 427f3bb634
5 changed files with 32 additions and 22 deletions

View File

@ -99,7 +99,7 @@ proc run_boot_dir {binaries} {
}
if {[have_include "load/ipxe"]} {
create_ipxe_iso_config
create_ipxe_config
update_ipxe_boot_dir
create_symlink_for_iso
}

View File

@ -146,7 +146,7 @@ proc run_boot_dir_x86 {binaries} {
}
if {[have_include "load/ipxe"]} {
create_ipxe_iso_config
create_ipxe_config
update_ipxe_boot_dir
create_symlink_for_iso
}

View File

@ -47,7 +47,7 @@ proc run_boot_dir {binaries} {
if {$ld_arg != ""} { copy_file bin/ld-nova.lib.so [run_dir]/genode/ld.lib.so }
#
# Collect contents of the ISO image
# Collect contents of the boot image
#
build_core_image $binaries
@ -177,7 +177,7 @@ proc run_boot_dir {binaries} {
}
if {[have_include "load/ipxe"]} {
create_ipxe_iso_config
create_ipxe_config
update_ipxe_boot_dir
create_symlink_for_iso
}

View File

@ -147,7 +147,7 @@ proc run_boot_dir {binaries} {
}
if {[have_spec x86] && [have_include "load/ipxe"]} {
create_ipxe_iso_config
create_ipxe_config
update_ipxe_boot_dir
create_symlink_for_iso
}

View File

@ -25,6 +25,18 @@ proc load_ipxe_base_dir { } { return [get_cmd_arg --load-ipxe-base-dir ""] }
proc load_ipxe_boot_dir { } { return [get_cmd_arg --load-ipxe-boot-dir ""] }
proc image_extension { } {
if {[have_include "image/iso"]} {
return "iso"
} elseif {[have_include "image/uefi"]} {
return "img"
} else {
puts "Warning, iPXE requires ISO or UEFI image."
exit -1
}
}
##
# Install files needed to boot via iPXE
#
@ -38,7 +50,7 @@ proc install_bender_to_run_dir { } {
# Create symlink for ISO image in current run directory.
#
proc create_symlink_for_iso { } {
exec ln -sfn [pwd]/[run_dir].iso [pwd]/[run_dir]/[run_name].iso
exec ln -sfn [pwd]/[run_dir].[image_extension] [pwd]/[run_dir]/[run_name].[image_extension]
}
##
@ -49,21 +61,19 @@ proc update_ipxe_boot_dir { } {
}
##
# Create iPXE config file which directly boots an ISO file.
# Create iPXE config file which directly boots an image file.
#
proc create_ipxe_iso_config { } {
if {[have_include "image/iso"]} {
set fh [open "[run_dir]/boot.cfg" "WRONLY CREAT TRUNC"]
puts $fh "#!ipxe"
puts $fh "sanboot [run_name].iso || goto failed"
puts $fh ""
puts $fh ":failed"
puts $fh "echo Booting failed, dropping to shell"
puts $fh "shell"
puts $fh "boot"
close $fh
} else {
puts "Warning, iPXE requires ISO image."
exit -1
}
# Note, the sanboot URI works relative to the script path and honors the former
# protocol too (which must be http:// not tftp://)
#
proc create_ipxe_config { } {
set fh [open "[run_dir]/boot.cfg" "WRONLY CREAT TRUNC"]
puts $fh "#!ipxe"
puts $fh "sanboot [run_name].[image_extension] || goto failed"
puts $fh ""
puts $fh ":failed"
puts $fh "echo Booting failed, dropping to shell"
puts $fh "shell"
puts $fh "boot"
close $fh
}