2015-01-08 21:08:48 +00:00
|
|
|
##
|
2012-05-30 18:13:09 +00:00
|
|
|
# Ensure that the next Genode build includes no target specific boot modules
|
|
|
|
#
|
2013-02-04 15:27:54 +00:00
|
|
|
proc clean_boot_modules { } {
|
|
|
|
exec rm -rf boot_modules.s var/libcache/boot_modules/boot_modules.o }
|
2012-05-30 18:13:09 +00:00
|
|
|
|
|
|
|
|
2015-01-08 21:08:48 +00:00
|
|
|
proc run_boot_dir_hook { } {
|
2013-02-04 15:27:54 +00:00
|
|
|
clean_boot_modules
|
2012-05-30 18:13:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-06 17:02:55 +00:00
|
|
|
proc run_boot_string { } {
|
2016-07-13 12:19:57 +00:00
|
|
|
return "\nkernel initialized"
|
2015-02-06 17:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-08 21:08:48 +00:00
|
|
|
##
|
|
|
|
# Populate boot directory with binaries on hw
|
|
|
|
#
|
2015-03-20 11:30:18 +00:00
|
|
|
proc run_boot_dir {binaries} {
|
|
|
|
|
2016-01-29 16:15:35 +00:00
|
|
|
# generate static ACPI report for platform driver on Muen
|
|
|
|
if {[have_spec "hw_x86_64_muen"]} {
|
|
|
|
set fh [open "bin/acpi" "WRONLY CREAT TRUNC"]
|
|
|
|
puts $fh "<acpi><bdf start=\"0\" count=\"16384\" base=\"0xf8000000\"/></acpi>"
|
|
|
|
close $fh
|
|
|
|
}
|
|
|
|
|
2013-02-04 15:27:54 +00:00
|
|
|
# strip binaries
|
2012-05-30 18:13:09 +00:00
|
|
|
copy_and_strip_genode_binaries_to_run_dir $binaries
|
|
|
|
|
2013-02-04 15:27:54 +00:00
|
|
|
# append init config
|
2012-12-10 09:53:50 +00:00
|
|
|
if {[file exists "[run_dir]/genode/config"] == 1} {
|
2012-05-30 18:13:09 +00:00
|
|
|
append binaries " config"
|
|
|
|
}
|
|
|
|
|
2013-02-04 15:27:54 +00:00
|
|
|
#
|
|
|
|
# Compose a platform specific assembly file 'boot_modules.s', that
|
|
|
|
# enables the creation of a single boot image. The file rawly includes
|
|
|
|
# all binaries given in 'binaries', minus 'core', if given, plus 'config',
|
|
|
|
# if available. It also provides a simple file system, that enables Genode
|
|
|
|
# to access these BLOBs. To build a single image this file is simply
|
|
|
|
# linked against core. To build core stand-alone this file is substituted
|
|
|
|
# by a dummy version. 'boot_modules.s' must be composed on demand, because
|
|
|
|
# it depends on the individual run scenario.
|
|
|
|
#
|
2012-05-30 18:13:09 +00:00
|
|
|
set boot_modules "[run_dir]/boot_modules.s"
|
|
|
|
|
2015-03-12 09:27:40 +00:00
|
|
|
if {[have_spec "64bit"]} {
|
|
|
|
set address_type ".quad"
|
|
|
|
} else {
|
|
|
|
set address_type ".long"
|
|
|
|
}
|
|
|
|
|
2014-05-05 10:15:31 +00:00
|
|
|
# introduce boot module headers
|
|
|
|
exec echo -e \
|
2015-05-11 17:07:13 +00:00
|
|
|
"/*" \
|
2014-05-05 10:15:31 +00:00
|
|
|
"\n * This file was automatically generated by the procedure" \
|
2015-05-11 17:07:13 +00:00
|
|
|
"\n * 'run_boot_dir' in 'tool/run/boot_dir/hw'." \
|
2014-05-05 10:15:31 +00:00
|
|
|
"\n */" \
|
|
|
|
"\n" \
|
|
|
|
"\n /* core includes */" \
|
|
|
|
"\n.include \"macros.s\"" \
|
|
|
|
"\n" \
|
|
|
|
"\n.section .data" \
|
|
|
|
"\n" \
|
2014-06-12 15:33:50 +00:00
|
|
|
"\n.p2align DATA_ACCESS_ALIGNM_LOG2" \
|
2014-05-05 10:15:31 +00:00
|
|
|
"\n.global _boot_modules_headers_begin" \
|
|
|
|
"\n_boot_modules_headers_begin:" > $boot_modules
|
|
|
|
|
|
|
|
# generate header for each boot module except core
|
|
|
|
set i 1
|
|
|
|
foreach binary $binaries {
|
2016-09-13 09:01:15 +00:00
|
|
|
if {$binary == "core"} { continue }
|
2013-02-04 15:27:54 +00:00
|
|
|
exec echo -e \
|
2015-03-12 09:27:40 +00:00
|
|
|
"\n${address_type} _boot_module_${i}_name" \
|
|
|
|
"\n${address_type} _boot_module_${i}_begin" \
|
|
|
|
"\n${address_type} _boot_module_${i}_end -" \
|
|
|
|
" _boot_module_${i}_begin" >> $boot_modules
|
2014-05-05 10:15:31 +00:00
|
|
|
incr i
|
|
|
|
}
|
|
|
|
|
|
|
|
# end boot module headers
|
|
|
|
exec echo -e \
|
|
|
|
"\n.global _boot_modules_headers_end" \
|
|
|
|
"\n_boot_modules_headers_end:" >> $boot_modules
|
|
|
|
|
|
|
|
# generate name string for each module except core
|
|
|
|
set i 1
|
|
|
|
foreach binary $binaries {
|
2016-09-13 09:01:15 +00:00
|
|
|
if {$binary == "core"} { continue }
|
2013-02-04 15:27:54 +00:00
|
|
|
exec echo -e \
|
2014-06-12 15:33:50 +00:00
|
|
|
"\n.p2align DATA_ACCESS_ALIGNM_LOG2" \
|
2014-05-05 10:15:31 +00:00
|
|
|
"\n_boot_module_${i}_name:" \
|
|
|
|
"\n.string \"${binary}\"" \
|
|
|
|
"\n.byte 0" >> $boot_modules
|
|
|
|
incr i
|
|
|
|
}
|
2012-05-30 18:13:09 +00:00
|
|
|
|
2014-05-05 10:15:31 +00:00
|
|
|
exec echo -e \
|
|
|
|
"\n.section .data.boot_modules_binaries" \
|
|
|
|
"\n" \
|
|
|
|
"\n.global _boot_modules_binaries_begin" \
|
|
|
|
"\n_boot_modules_binaries_begin:" >> $boot_modules
|
|
|
|
|
|
|
|
# include raw data of modules consecutively but page aligned
|
|
|
|
set i 1
|
|
|
|
foreach binary $binaries {
|
2016-09-13 09:01:15 +00:00
|
|
|
if {$binary == "core"} { continue }
|
2014-05-05 10:15:31 +00:00
|
|
|
exec echo -e \
|
2014-06-12 15:33:50 +00:00
|
|
|
"\n.p2align MIN_PAGE_SIZE_LOG2" \
|
2014-05-05 10:15:31 +00:00
|
|
|
"\n_boot_module_${i}_begin:" \
|
|
|
|
"\n.incbin \"[run_dir]/genode/${binary}\"" \
|
|
|
|
"\n_boot_module_${i}_end:" >> $boot_modules
|
|
|
|
incr i
|
2013-02-04 15:27:54 +00:00
|
|
|
}
|
2014-05-05 10:15:31 +00:00
|
|
|
|
|
|
|
# finish boot modules file
|
|
|
|
exec echo -e \
|
|
|
|
"\n.global _boot_modules_binaries_end" \
|
|
|
|
"\n_boot_modules_binaries_end:" >> $boot_modules
|
|
|
|
|
2013-02-04 15:27:54 +00:00
|
|
|
clean_boot_modules
|
|
|
|
exec ln -s $boot_modules boot_modules.s
|
2012-05-30 18:13:09 +00:00
|
|
|
|
2013-02-04 15:27:54 +00:00
|
|
|
# recompile core with boot modules
|
2016-09-13 09:01:15 +00:00
|
|
|
exec cp -L bin/core core/core.standalone
|
|
|
|
exec find . -type f -name core -delete
|
2013-02-04 15:27:54 +00:00
|
|
|
set timeout 10000
|
2016-09-13 09:01:15 +00:00
|
|
|
set pid [eval "spawn make core"]
|
2013-02-04 15:27:54 +00:00
|
|
|
expect { eof { } }
|
|
|
|
if {[lindex [wait $pid] end] != 0} {
|
|
|
|
clean_boot_modules
|
|
|
|
puts stderr "Error: Genode build failed"
|
|
|
|
exit -1
|
|
|
|
}
|
|
|
|
clean_boot_modules
|
2015-06-15 08:38:28 +00:00
|
|
|
exec mv [run_dir]/genode/config [run_dir]/config
|
2013-02-04 15:27:54 +00:00
|
|
|
exec rm -rf "[run_dir]/genode"
|
|
|
|
|
|
|
|
# offer ELF image
|
|
|
|
set elf_img "[run_dir]/image.elf"
|
2015-04-14 15:01:12 +00:00
|
|
|
|
2015-08-21 16:12:42 +00:00
|
|
|
if {[have_spec "x86_64"]} {
|
2015-02-06 16:29:30 +00:00
|
|
|
# as startup is done in 32 bit mode, GRUB expects a 32 bit image
|
2016-09-13 09:01:15 +00:00
|
|
|
exec [cross_dev_prefix]objcopy -O elf32-i386 bin/core $elf_img
|
2015-02-06 16:29:30 +00:00
|
|
|
}
|
2016-02-11 10:42:00 +00:00
|
|
|
if {[expr [have_spec "arm"] || [have_spec "x86_32"] || [have_spec "riscv"]]} {
|
2016-09-13 09:01:15 +00:00
|
|
|
exec cp -L bin/core $elf_img
|
2015-02-06 16:29:30 +00:00
|
|
|
}
|
2015-08-21 16:12:42 +00:00
|
|
|
|
2015-02-06 16:29:30 +00:00
|
|
|
exec [cross_dev_prefix]strip $elf_img
|
2015-02-06 16:27:44 +00:00
|
|
|
|
|
|
|
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"
|
2015-08-21 16:12:42 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
2015-02-06 16:27:44 +00:00
|
|
|
close $fh
|
|
|
|
}
|
2013-02-04 15:27:54 +00:00
|
|
|
|
2015-01-08 21:08:48 +00:00
|
|
|
run_image $elf_img
|
2013-05-07 10:18:56 +00:00
|
|
|
|
|
|
|
# set symbolic link to image.elf file in TFTP directory for PXE boot
|
2015-06-01 13:17:54 +00:00
|
|
|
if {[have_spec arm] && [have_include "load/tftp"]} {
|
2015-01-08 21:08:48 +00:00
|
|
|
exec ln -sf [pwd]/$elf_img [load_tftp_base_dir][load_tftp_offset_dir]
|
2013-05-07 10:18:56 +00:00
|
|
|
|
2015-01-08 21:08:48 +00:00
|
|
|
if {[have_include "image/uboot"]} {
|
|
|
|
exec ln -sf [pwd]/[run_dir]/uImage [load_tftp_base_dir][load_tftp_offset_dir]
|
2013-05-07 10:18:56 +00:00
|
|
|
}
|
2013-02-04 15:27:54 +00:00
|
|
|
}
|
2013-05-07 10:18:56 +00:00
|
|
|
|
2015-08-21 16:12:42 +00:00
|
|
|
if {[have_spec x86] && ![have_spec muen] && [have_include "load/tftp"]} {
|
2015-06-01 13:17:54 +00:00
|
|
|
#
|
|
|
|
# Install PXE bootloader pulsar
|
|
|
|
#
|
|
|
|
install_pxe_bootloader_to_run_dir
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generate pulsar config file
|
|
|
|
#
|
|
|
|
set fh [open "[run_dir]/config-52-54-00-12-34-56" "WRONLY CREAT TRUNC"]
|
|
|
|
puts $fh " exec /boot/bender"
|
|
|
|
puts $fh " load /image.elf"
|
|
|
|
close $fh
|
|
|
|
|
|
|
|
generate_tftp_config
|
|
|
|
}
|
|
|
|
|
2015-12-18 12:09:39 +00:00
|
|
|
if {[have_spec x86] && [have_include "load/ipxe"]} {
|
|
|
|
#
|
|
|
|
# Generate iPXE config file
|
|
|
|
#
|
|
|
|
set fh [open "[run_dir]/boot.cfg" "WRONLY CREAT TRUNC"]
|
|
|
|
puts $fh "#!ipxe"
|
|
|
|
|
|
|
|
if {[have_spec "muen"]} {
|
|
|
|
puts $fh "kernel image.bin"
|
|
|
|
} else {
|
|
|
|
puts $fh "kernel boot/bender"
|
|
|
|
puts $fh "module image.elf"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Install bender
|
|
|
|
#
|
|
|
|
install_bender_to_run_dir
|
|
|
|
}
|
|
|
|
puts $fh "boot"
|
|
|
|
close $fh
|
|
|
|
|
|
|
|
update_ipxe_boot_dir
|
|
|
|
}
|
|
|
|
|
2013-02-04 15:27:54 +00:00
|
|
|
# retrieve stand-alone core
|
2016-09-13 09:01:15 +00:00
|
|
|
exec cp core/core.standalone bin/core
|
|
|
|
exec rm core/core.standalone
|
2012-05-30 18:13:09 +00:00
|
|
|
}
|