tool: support image/uefi for grub2/uefi boot

- add x86_32/64 GRUB2 UEFI boot loader
- enable support for nova

Issue #2242
This commit is contained in:
Alexander Boettcher 2017-06-12 22:12:11 +02:00 committed by Norman Feske
parent 1205607e78
commit 3aca3256c6
5 changed files with 86 additions and 13 deletions

View File

@ -37,3 +37,11 @@ code respectively the download source of binaries are described below.
The changes are available on the genode_bender branch of
https://github.com/skalk/morbo.git.
:'grub2_32.efi', 'grub2_64.efi'
GRUB 2 UEFI bootloader for x86
Source code was obtained from git://git.savannah.gnu.org/grub.git, git
commit 972765fe8245cdf44d465329f33b5aa9ac6c2f47.
The following modules were included: part_msdos iso9660 part_gpt ext2 multiboot multiboot2 fat normal configfile setpci serial efi_uga efi_gop

BIN
tool/boot/grub2_32.efi Normal file

Binary file not shown.

BIN
tool/boot/grub2_64.efi Normal file

Binary file not shown.

View File

@ -55,22 +55,44 @@ proc run_boot_dir {binaries} {
exec rm -rf [run_dir]/genode
if {[have_include "image/iso"] || [have_include "image/disk"]} {
#
# Install isolinux/GRUB files and bender
#
install_iso_bootloader_to_run_dir
if {[have_include "image/iso"] || [have_include "image/disk"] || [have_include image/uefi]} {
if {[have_include "image/iso"] || [have_include "image/disk"]} {
#
# Install isolinux/GRUB files and bender
#
install_iso_bootloader_to_run_dir
#
# Generate GRUB config file
#
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
puts $fh "timeout 0"
puts $fh "default 0"
puts $fh "\ntitle Genode on NOVA"
puts $fh " kernel /boot/bender"
puts $fh " module /hypervisor iommu serial novpid novga"
puts $fh " module /image.elf"
close $fh
}
if {[have_include image/uefi]} {
exec mkdir -p [run_dir]/efi/boot
exec cp [genode_dir]/tool/boot/grub2_32.efi [run_dir]/efi/boot/bootia32.efi
exec cp [genode_dir]/tool/boot/grub2_64.efi [run_dir]/efi/boot/bootx64.efi
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
}
#
# Generate GRUB config file
# Generate GRUB2 config file
#
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
puts $fh "timeout 0"
puts $fh "default 0"
puts $fh "\ntitle Genode on NOVA"
puts $fh " kernel /boot/bender"
puts $fh " module /hypervisor iommu serial novpid novga"
puts $fh " module /image.elf"
set fh [open "[run_dir]/boot/grub/grub.cfg" "WRONLY CREAT TRUNC"]
puts $fh "set timeout=0"
puts $fh "menuentry 'Genode on NOVA' {"
puts $fh " multiboot2 /boot/bender serial_fallback"
puts $fh " module2 /hypervisor hypervisor iommu serial novpid novga"
puts $fh " module2 /image.elf image.elf"
puts $fh "}"
close $fh
}

43
tool/run/image/uefi Normal file
View File

@ -0,0 +1,43 @@
##
# Create GPT disk image with UEFI boot loaders and content of the run directory
#
# \param --image-uefi-size disk size in MiB
#
proc image_uefi_size { } { return [get_cmd_arg --image-uefi_size 0] }
##
# Create uefi image
#
proc run_image { {unused ""} } {
requires_installation_of parted
requires_installation_of mkfs.vfat
requires_installation_of mcopy
set run_size [expr [regsub {\s.*} [exec du -sm [run_dir]] {}]]
if {[image_uefi_size] > 0} {
set disk_size [image_uefi_size]
} else {
set disk_size [expr $run_size + 1]
}
# generate head space designated for the partition table
exec dd if=/dev/zero of=[run_dir].header count=34 bs=512 2>/dev/null
exec dd if=/dev/zero of=[run_dir].partition bs=1M count=$disk_size 2>/dev/null
exec mkfs.vfat -n GENODE [run_dir].partition
# copy content to disk image
foreach file [exec ls [run_dir]] {
exec mcopy -i [run_dir].partition -s [run_dir]/$file ::
}
exec cat [run_dir].header [run_dir].partition > [run_dir].img
exec parted -a none -s [run_dir].img -- mklabel gpt mkpart ESP fat32 34s [expr $disk_size * 1024 * 1024 / 512]s set 1 boot on
exec rm -f [run_dir].header [run_dir].partition
}