genode/tool/run/boot_dir/sel4
Stefan Kalkowski 4bd5634bd5 hw: remove kernel unit test framework (fix #2096)
* Remove 'test' routine from kernel/core
* Move 'cpu_scheduler' and 'double_list' test to user-land
* Remove 'hw_info' target at all (can be recycled in a topic branch)
2016-09-30 14:15:22 +02:00

203 lines
5.0 KiB
Plaintext

#
# Based on boot_dir/hw
#
##
# Ensure that the next Genode build includes no target specific boot modules
#
proc clean_boot_modules { } {
exec rm -rf boot_modules.s var/libcache/boot_modules/boot_modules.o }
proc run_boot_dir_hook { } {
clean_boot_modules
}
proc run_boot_string { } {
return "\n\rStarting node #0"
}
##
# Populate boot directory with binaries on hw
#
proc run_boot_dir {binaries} {
# strip binaries
copy_and_strip_genode_binaries_to_run_dir $binaries
build { kernel }
exec cp bin/sel4 [run_dir]/sel4
# append init config
if {[file exists "[run_dir]/genode/config"] == 1} {
append binaries " config"
}
#
# 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.
#
set boot_modules "[run_dir]/boot_modules.s"
if {[have_spec "64bit"]} {
set address_type ".quad"
} else {
set address_type ".long"
}
# introduce boot module headers
exec echo -e \
"/*" \
"\n * This file was automatically generated by the procedure" \
"\n * 'run_boot_dir' in 'tool/run/boot_dir/sel4'." \
"\n */" \
"\n" \
"\n /* alignment constraints */" \
"\n .set MIN_PAGE_SIZE_LOG2, 12" \
"\n .set DATA_ACCESS_ALIGNM_LOG2, 2" \
"\n" \
"\n.section .data" \
"\n" \
"\n.p2align DATA_ACCESS_ALIGNM_LOG2" \
"\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 {
if {$binary == "core"} { continue }
exec echo -e \
"\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
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 {
if {$binary == "core"} { continue }
exec echo -e \
"\n.p2align DATA_ACCESS_ALIGNM_LOG2" \
"\n_boot_module_${i}_name:" \
"\n.string \"${binary}\"" \
"\n.byte 0" >> $boot_modules
incr i
}
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 {
if {$binary == "core"} { continue }
exec echo -e \
"\n.p2align MIN_PAGE_SIZE_LOG2" \
"\n_boot_module_${i}_begin:" \
"\n.incbin \"[run_dir]/genode/${binary}\"" \
"\n_boot_module_${i}_end:" >> $boot_modules
incr i
}
# finish boot modules file
exec echo -e \
"\n.global _boot_modules_binaries_end" \
"\n_boot_modules_binaries_end:" >> $boot_modules
clean_boot_modules
exec ln -s $boot_modules boot_modules.s
# recompile core with boot modules
exec cp -L bin/core core/core.standalone
exec find . -type f -name core -delete
set timeout 10000
set pid [eval "spawn make core"]
expect { eof { } }
if {[lindex [wait $pid] end] != 0} {
clean_boot_modules
puts stderr "Error: Genode build failed"
exit -1
}
clean_boot_modules
exec rm -rf "[run_dir]/genode"
# offer ELF image
set elf_img "[run_dir]/image.elf"
if {[have_spec "x86_64"]} {
# as startup is done in 32 bit mode, GRUB expects a 32 bit image
exec [cross_dev_prefix]objcopy -O elf32-i386 bin/core $elf_img
}
if {[expr [have_spec "arm"] || [have_spec "x86_32"]]} {
exec cp -L bin/core $elf_img
}
exec [cross_dev_prefix]strip $elf_img
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 seL4"
puts $fh " kernel /boot/bender norelocate"
puts $fh " module /sel4 disable_iommu"
puts $fh " module /image.elf"
close $fh
}
run_image $elf_img
if {[have_include "load/tftp"]} {
#
# 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 norelocate"
puts $fh " load /sel4 disable_iommu"
puts $fh " load /image.elf"
close $fh
generate_tftp_config
}
if {[have_include "load/ipxe"]} {
create_ipxe_iso_config
update_ipxe_boot_dir
create_symlink_for_iso
}
# retrieve stand-alone core
exec cp core/core.standalone bin/core
exec rm core/core.standalone
}