Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
run: support for creating uefi boot image
  • Loading branch information
alex-ab committed Feb 2, 2017
1 parent 89d65fe commit 097422d
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 46 deletions.
47 changes: 28 additions & 19 deletions tool/run/boot_dir/hw
Expand Up @@ -40,28 +40,37 @@ proc run_boot_dir {binaries} {

build_core_image $binaries

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"
#
# Generate GRUB config file
#
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
puts $fh "timeout 0"
puts $fh "default 0"

if {[have_spec "muen"]} {
puts $fh "\ntitle Genode on base-hw/Muen SK"
puts $fh " kernel /image.bin"
} else {
puts $fh "\ntitle Genode on base-hw"
puts $fh " kernel /boot/bender"
puts $fh " module /image.elf"
}
close $fh
}

if {[have_spec "muen"]} {
puts $fh "\ntitle Genode on base-hw/Muen SK"
puts $fh " kernel /image.bin"
} else {
puts $fh "\ntitle Genode on base-hw"
puts $fh " kernel /boot/bender"
puts $fh " module /image.elf"
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
}
close $fh

#
# Generate GRUB2 config file
Expand Down
42 changes: 26 additions & 16 deletions tool/run/boot_dir/nova
Expand Up @@ -63,23 +63,32 @@ proc run_boot_dir {binaries} {
exec [cross_dev_prefix]objcopy -O elf32-i386 [nova_kernel] [run_dir]/hypervisor
exec [cross_dev_prefix]strip [run_dir]/hypervisor

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
}

#
# 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
}

#
# Generate GRUB2 config file
Expand All @@ -91,6 +100,7 @@ proc run_boot_dir {binaries} {
puts $fh " module2 /image.elf"
puts $fh "}"
close $fh

}

#
Expand Down
43 changes: 43 additions & 0 deletions tool/run/image/uefi
@@ -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
}
23 changes: 12 additions & 11 deletions tool/run/power_on/qemu
Expand Up @@ -60,17 +60,18 @@ proc run_power_on { } {
if {[have_include "load/tftp"]} {
append qemu_args " -boot n -tftp [run_dir] -bootp boot/pulsar -no-reboot -no-shutdown "
} else {
if {[have_include "image/iso"]} {
append qemu_args " -cdrom [run_dir].iso "
} else {
if {[have_include "image/disk"]} {
append qemu_args " -hda [run_dir].img "
} else {
puts "Aborting, cannot execute Qemu without a ISO or disk image"
exit -4
}
}
}
if {[have_include "image/iso"]} {
append qemu_args " -cdrom [run_dir].iso "
} else {
if {[have_include "image/disk"]} {
append qemu_args " -hda [run_dir].img "
} else {
if {[have_include "image/uefi"]} {
append qemu_args " --bios [genode_dir]/tool/boot/tianocore.bin -net none -drive format=raw,file=[run_dir].img "
} else {
puts "Aborting, cannot execute Qemu without a ISO or disk image"
exit -4
} } } }
}

# on ARM, we supply the boot image as kernel
Expand Down

0 comments on commit 097422d

Please sign in to comment.