core: unify handling of boot modules

Instead of solving the problem to deliver ROM modules to core while booting
differently for the several kernels (multi-boot, elfweaver, core re-linking),
this commit unifies the approaches. It always builds core as a library, and
after all binaries are built from a run-script, the run-tool will link an
ELF image out of the core-library and all boot modules. Thereby, core can
access its ROM modules directly.

This approach now works for all kernels except Linux.

With this solution, there is no [build_dir]/bin/core binary available anymore.
For debugging purposes you will find a core binary without boot modules, but
with debug symbols under [run_dir].core.

Fix #2095
This commit is contained in:
Stefan Kalkowski
2016-09-15 16:08:33 +02:00
committed by Christian Helmuth
parent 340a18007c
commit 7e1692d997
80 changed files with 450 additions and 1395 deletions

View File

@@ -63,21 +63,20 @@ proc run_boot_string { } {
return "\nL4 Bootstrapper"
}
proc core_link_address { } { return "0x01000000" }
##
# Populate boot directory with binaries on fiasco
#
proc run_boot_dir {binaries} {
build_core_image $binaries
global fiasco_serial_esc_arg
exec mkdir -p [run_dir]/fiasco
#
# Collect contents of the ISO image
#
copy_and_strip_genode_binaries_to_run_dir $binaries
if {![fiasco_external]} { build { kernel } }
if {![l4_dir_external]} { build { bootstrap sigma0 } }
@@ -107,14 +106,10 @@ proc run_boot_dir {binaries} {
puts $fh "default 0"
puts $fh "\ntitle Genode on L4/Fiasco"
puts $fh " kernel /boot/bender"
puts $fh " module /fiasco/bootstrap -serial -modaddr=0x02000000"
puts $fh " module /fiasco/bootstrap -serial"
puts $fh " module /fiasco/fiasco -serial -jdb_cmd=JH $fiasco_serial_esc_arg"
puts $fh " module /fiasco/sigma0"
puts $fh " module /genode/core"
puts $fh " module /genode/config"
foreach binary $binaries {
if {$binary != "core"} {
puts $fh " module /genode/$binary" } }
puts $fh " module /image.elf"
puts $fh " vbeset 0x117 506070"
close $fh
}
@@ -132,14 +127,10 @@ proc run_boot_dir {binaries} {
#
set fh [open "[run_dir]/config-52-54-00-12-34-56" "WRONLY CREAT TRUNC"]
puts $fh " exec /boot/bender"
puts $fh " load /fiasco/bootstrap -serial -modaddr=0x02000000"
puts $fh " load /fiasco/bootstrap -serial"
puts $fh " load /fiasco/fiasco -serial -serial_esc -jdb_cmd=JH"
puts $fh " load /fiasco/sigma0"
puts $fh " load /genode/core"
puts $fh " load /genode/config"
foreach binary $binaries {
if {$binary != "core"} {
puts $fh " load /genode/$binary" } }
puts $fh " load /image.elf"
close $fh
generate_tftp_config

View File

@@ -76,19 +76,6 @@ proc reset_target { {spawn_id_arg -1} } {
}
proc copy_and_strip_binaries {binaries} {
#
# Collect contents of the boot image
#
foreach binary $binaries {
exec cp bin/$binary [run_dir]/genode
catch {
exec [cross_dev_prefix]strip [run_dir]/genode/$binary }
}
}
proc bin_dir { } {
if {[have_spec x86_32]} { return "[l4_dir]/bin/x86_586" }
if {[have_spec x86_64]} { return "[l4_dir]/bin/amd64_K8" }
@@ -101,14 +88,24 @@ proc bin_dir { } {
set fiasco_serial_esc_arg "-serial_esc "
proc run_boot_dir_x86 {binaries} {
proc core_link_address { } {
if {[have_spec x86 ]} { return "0x01100000" }
if {[have_spec arndale ]} { return "0x80100000" }
if {[have_spec rpi ]} { return "0x00800000" }
if {[have_spec panda ]} { return "0xa0000000" }
if {[have_spec pbxa9 ]} { return "0x76000000" }
if {[have_spec odroid_x2]} { return "0x80100000" }
if {[have_spec imx53 ]} { return "0x70140000" }
puts stderr "Error: platform not supported, core link address unknown"
exit 1
}
proc run_boot_dir_x86 {binaries} {
global fiasco_serial_esc_arg
exec mkdir -p [run_dir]/fiasco
copy_and_strip_binaries $binaries
set foc_targets { }
if {![fiasco_external] && ![file exists kernel]} { lappend foc_targets kernel }
if {![l4_dir_external]} {
@@ -146,12 +143,7 @@ proc run_boot_dir_x86 {binaries} {
puts $fh " module /fiasco/bootstrap"
puts $fh " module /fiasco/fiasco $fiasco_serial_esc_arg"
puts $fh " module /fiasco/sigma0"
puts $fh " module /genode/core"
puts $fh " module /genode/config"
foreach binary $binaries {
if {$binary != "core"} {
puts $fh " module /genode/$binary" } }
puts $fh " vbeset 0x117 506070"
puts $fh " module /image.elf"
close $fh
}
@@ -174,11 +166,7 @@ proc run_boot_dir_x86 {binaries} {
puts $fh " load /fiasco/bootstrap"
puts $fh " load /fiasco/fiasco -serial_esc"
puts $fh " load /fiasco/sigma0"
puts $fh " load /genode/core"
puts $fh " load /genode/config"
foreach binary $binaries {
if {$binary != "core"} {
puts $fh " load /genode/$binary" } }
puts $fh " load /image.elf"
close $fh
generate_tftp_config
@@ -197,8 +185,6 @@ proc run_boot_dir_arm {binaries} {
global run_target
global fiasco_serial_esc_arg
copy_and_strip_binaries $binaries
build "kernel sigma0 bootstrap"
#
@@ -209,11 +195,7 @@ proc run_boot_dir_arm {binaries} {
puts $fh "modaddr 0x01100000\n"
puts $fh "entry genode"
puts $fh "kernel [fiasco] $fiasco_serial_esc_arg"
puts $fh "roottask genode/core"
puts $fh "module genode/config"
foreach binary $binaries {
if {$binary != "core"} {
puts $fh "module genode/$binary" } }
puts $fh "roottask image.elf"
close $fh
@@ -229,6 +211,7 @@ proc run_boot_dir_arm {binaries} {
exit -4
}
exec cp [run_dir]/image.elf [run_dir]/core.elf
exec cp [bin_dir]/bootstrap.elf [run_dir]/image.elf
run_image [run_dir]/image.elf
@@ -256,6 +239,8 @@ proc run_boot_string { } {
# Populate boot directory with binaries on fiasco.OC
#
proc run_boot_dir {binaries} {
build_core_image $binaries
if {[have_spec x86]} { return [run_boot_dir_x86 $binaries] }
if {[have_spec arm]} { return [run_boot_dir_arm $binaries] }
}

View File

@@ -1,17 +1,23 @@
##
# 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 "\nkernel initialized"
}
proc run_boot_string { } {
return "\nkernel initialized"
proc core_link_address { } {
if {[have_spec "hw_odroid_xu"]} { return "0x80000000" }
if {[have_spec "hw_pbxa9"]} { return "0x70000000" }
if {[have_spec "hw_usb_armory"]} { return "0x72000000" }
if {[have_spec "hw_x86_64"]} { return "0x00200000" }
if {[have_spec "hw_wand_quad"]} { return "0x10001000" }
if {[have_spec "hw_imx53_qsb"]} { return "0x70010000" }
if {[have_spec "hw_arndale"]} { return "0x80000000" }
if {[have_spec "hw_panda"]} { return "0x81000000" }
if {[have_spec "hw_zynq"]} { return "0x00100000" }
if {[have_spec "hw_riscv"]} { return "0x00000200" }
if {[have_spec "hw_rpi"]} { return "0x00800000" }
puts "unknown platform no linker address known"
exit -1
}
@@ -27,130 +33,7 @@ proc run_boot_dir {binaries} {
close $fh
}
# strip binaries
copy_and_strip_genode_binaries_to_run_dir $binaries
# 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/hw'." \
"\n */" \
"\n" \
"\n /* core includes */" \
"\n.include \"macros.s\"" \
"\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 mv [run_dir]/genode/config [run_dir]/config
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"] || [have_spec "riscv"]]} {
exec cp -L bin/core $elf_img
}
exec [cross_dev_prefix]strip $elf_img
build_core_image $binaries
if {[have_include "image/iso"] || [have_include "image/disk"]} {
#
@@ -176,11 +59,11 @@ proc run_boot_dir {binaries} {
close $fh
}
run_image $elf_img
run_image [run_dir]/image.elf
# set symbolic link to image.elf file in TFTP directory for PXE boot
if {[have_spec arm] && [have_include "load/tftp"]} {
exec ln -sf [pwd]/$elf_img [load_tftp_base_dir][load_tftp_offset_dir]
exec ln -sf [run_dir]/image.elf [load_tftp_base_dir][load_tftp_offset_dir]
if {[have_include "image/uboot"]} {
exec ln -sf [pwd]/[run_dir]/uImage [load_tftp_base_dir][load_tftp_offset_dir]
@@ -227,8 +110,4 @@ proc run_boot_dir {binaries} {
update_ipxe_boot_dir
}
# retrieve stand-alone core
exec cp core/core.standalone bin/core
exec rm core/core.standalone
}

View File

@@ -29,6 +29,15 @@ proc run_boot_string { } {
}
proc core_link_address { } { return "0x100000" }
proc core_ld_opts { } {
set ret { -Wl,-T }
lappend ret "-Wl,[genode_dir]/repos/base/src/ld/genode.ld"
lappend ret "-Wl,[genode_dir]/repos/base-nova/src/core/core-bss.ld"
return $ret
}
##
# Populate directory with binaries on NOVA
#
@@ -37,7 +46,7 @@ proc run_boot_dir {binaries} {
#
# Collect contents of the ISO image
#
copy_and_strip_genode_binaries_to_run_dir $binaries
build_core_image $binaries
if {![nova_external]} { build { kernel } }
@@ -60,11 +69,7 @@ proc run_boot_dir {binaries} {
puts $fh "\ntitle Genode on NOVA"
puts $fh " kernel /boot/bender"
puts $fh " module /hypervisor iommu serial novpid novga"
puts $fh " module /genode/core"
puts $fh " module /genode/config"
foreach binary $binaries {
if {$binary != "core"} {
puts $fh " modulenounzip /genode/$binary" } }
puts $fh " module /image.elf"
close $fh
}
@@ -85,11 +90,7 @@ proc run_boot_dir {binaries} {
set fh [open "[run_dir]/config-52-54-00-12-34-56" "WRONLY CREAT TRUNC"]
puts $fh " exec /boot/bender"
puts $fh " load /hypervisor iommu serial novpid novga"
puts $fh " load /genode/core"
puts $fh " load /genode/config"
foreach binary $binaries {
if {$binary != "core"} {
puts $fh " load /genode/$binary" } }
puts $fh " load /image.elf"
close $fh
generate_tftp_config

View File

@@ -97,7 +97,7 @@ set weaver_xml_template {
</config>
</kernel>
<rootprogram file="core" virtpool="virtual" physpool="physical" />
<rootprogram file="core" virtpool="virtual" physpool="physical" direct="true" />
}
@@ -106,16 +106,17 @@ proc run_boot_string { } {
}
proc core_link_address { } { return "0x03000000" }
##
# Populate directory with binaries on OKL4
#
proc run_boot_dir {binaries} {
global weaver_xml_template
#
# Strip binaries
#
copy_and_strip_genode_binaries_to_run_dir $binaries
build_core_image $binaries
exec mv [run_dir]/image.elf [run_dir].image
#
# Build kernel if needed
@@ -138,15 +139,8 @@ proc run_boot_dir {binaries} {
puts $fh {<!DOCTYPE image SYSTEM "weaver-1.1.dtd">}
puts $fh {<image>}
regsub okl4_kernel $weaver_xml_template "[run_dir]/kernel" weaver_xml_template
regsub core $weaver_xml_template "[run_dir]/genode/core" weaver_xml_template
regsub core $weaver_xml_template "[run_dir].image" weaver_xml_template
puts $fh $weaver_xml_template
puts $fh { <pd name="modules">}
puts $fh " <memsection name=\"config\" file=\"[run_dir]/genode/config\" direct=\"true\" />"
foreach binary $binaries {
if {$binary != "core"} {
puts $fh " <memsection name=\"$binary\" file=\"[run_dir]/genode/$binary\" direct=\"true\" />" }
}
puts $fh { </pd>}
puts $fh {</image>}
close $fh
@@ -159,7 +153,6 @@ proc run_boot_dir {binaries} {
exit -6
}
exec [cross_dev_prefix]strip [run_dir]/image.elf
exec cp [run_dir]/image.elf [run_dir].elf
#
# Keep only the ELF boot image, but remove stripped binaries

View File

@@ -67,18 +67,16 @@ proc run_boot_string { } {
return "\n\r\033\\\[1m\033\\\[33mL4Ka::Pistachio -"
}
proc core_link_address { } { return "0x02000000" }
##
# Populdate boot directory with binaries on pistachio
#
proc run_boot_dir {binaries} {
exec mkdir -p [run_dir]/pistachio
build_core_image $binaries
#
# Collect contents of the ISO image
#
copy_and_strip_genode_binaries_to_run_dir $binaries
exec mkdir -p [run_dir]/pistachio
if {![kernel_external] && ![file exists [pistachio_kernel]]} { build { kernel } }
@@ -105,11 +103,7 @@ proc run_boot_dir {binaries} {
puts $fh " kernel /pistachio/kickstart"
puts $fh " module /pistachio/kernel"
puts $fh " module /pistachio/sigma0"
puts $fh " module /genode/core"
puts $fh " module /genode/config"
foreach binary $binaries {
if {$binary != "core"} {
puts $fh " module /genode/$binary" } }
puts $fh " module /image.elf"
close $fh
}
@@ -132,12 +126,7 @@ proc run_boot_dir {binaries} {
puts $fh " load /pistachio/kickstart"
puts $fh " load /pistachio/kernel"
puts $fh " load /pistachio/sigma0"
puts $fh " load /genode/core"
puts $fh " load /genode/config"
puts $fh " load /genode/config"
foreach binary $binaries {
if {$binary != "core"} {
puts $fh " load /genode/$binary" } }
puts $fh " load /image.elf"
close $fh
generate_tftp_config

View File

@@ -2,21 +2,10 @@
# 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_string { } { return "\n\rStarting node #0" }
proc run_boot_dir_hook { } {
clean_boot_modules
}
proc run_boot_string { } {
return "\n\rStarting node #0"
}
proc core_link_address { } { return "0x02000000" }
##
@@ -24,131 +13,11 @@ proc run_boot_string { } {
#
proc run_boot_dir {binaries} {
# strip binaries
copy_and_strip_genode_binaries_to_run_dir $binaries
# build sel4 kernel
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
build_core_image $binaries
if {[have_include "image/iso"] || [have_include "image/disk"]} {
#
@@ -170,7 +39,7 @@ proc run_boot_dir {binaries} {
close $fh
}
run_image $elf_img
run_image [run_dir]/image.elf
if {[have_include "load/tftp"]} {
#
@@ -195,8 +64,4 @@ proc run_boot_dir {binaries} {
update_ipxe_boot_dir
create_symlink_for_iso
}
# retrieve stand-alone core
exec cp core/core.standalone bin/core
exec rm core/core.standalone
}

View File

@@ -46,10 +46,6 @@ proc build {targets} {
if {[get_cmd_switch --skip-build]} return
if {[info exists run_boot_dir_hook]} {
run_boot_dir_hook
}
regsub -all {\s\s+} $targets " " targets
puts "building targets: $targets"
set timeout 10000
@@ -541,6 +537,20 @@ proc run_power_on { } { return true; }
proc run_power_off { } { return true; }
##
# Default core linker options
#
proc core_ld_opts { } {
set ret { -Wl,-T }
lappend ret "-Wl,[genode_dir]/repos/base/src/ld/genode.ld"
return $ret
}
##
# Default core link address
#
proc core_link_address { } { return "0x01000000" }
##
# Check if a specific file is included
#
@@ -626,6 +636,127 @@ proc check_installed {command} {
}
##
# Generate assembly code aggregating boot-module data from specified files.
#
proc generate_boot_modules_asm {path modules} {
# architecture dependent definitions
if {[have_spec "64bit"]} { set address_type ".quad"
} else { set address_type ".long" }
# header
set asm_src {}
append asm_src ".set MIN_PAGE_SIZE_LOG2, 12\n"
append asm_src ".set DATA_ACCESS_ALIGNM_LOG2, 3\n"
append asm_src "\n"
append asm_src ".section .data\n"
append asm_src "\n"
append asm_src ".p2align DATA_ACCESS_ALIGNM_LOG2\n"
append asm_src ".global _boot_modules_headers_begin\n"
append asm_src "_boot_modules_headers_begin:\n"
append asm_src "\n"
# module list
set i 0
foreach module $modules {
incr i
append asm_src "${address_type} _boot_module_${i}_name\n"
append asm_src "${address_type} _boot_module_${i}_begin\n"
append asm_src "${address_type} _boot_module_${i}_end -"
append asm_src " _boot_module_${i}_begin\n"
append asm_src "\n"
}
append asm_src ".global _boot_modules_headers_end\n"
append asm_src "_boot_modules_headers_end:\n"
append asm_src "\n"
# module names
set i 0
foreach module $modules {
incr i
append asm_src ".p2align DATA_ACCESS_ALIGNM_LOG2\n"
append asm_src "_boot_module_${i}_name:\n"
append asm_src ".string \"${module}\"\n"
append asm_src ".byte 0\n"
append asm_src "\n"
}
# header end
append asm_src ".section .data.boot_modules_binaries\n"
append asm_src "\n"
append asm_src ".global _boot_modules_binaries_begin\n"
append asm_src "_boot_modules_binaries_begin:\n"
append asm_src "\n"
# module data
set i 0
foreach module $modules {
incr i
append asm_src ".p2align MIN_PAGE_SIZE_LOG2\n"
append asm_src "_boot_module_${i}_begin:\n"
append asm_src ".incbin \"${path}/${module}\"\n"
append asm_src "_boot_module_${i}_end:\n"
append asm_src "\n"
}
append asm_src ".global _boot_modules_binaries_end\n"
append asm_src "_boot_modules_binaries_end:\n"
return $asm_src
}
##
# Link core image containing given modules
#
proc build_core {lib modules target} {
# generate assembly code aggregating the modules data
set asm_src [generate_boot_modules_asm [run_dir]/genode $modules]
# architecture dependent definitions
set arch {}
if {[have_spec "x86_64"]} { set arch -m64 }
if {[have_spec "x86_32"]} { set arch -m32 }
# determine the libgcc
set libgcc [exec [cross_dev_prefix]gcc -print-libgcc-file-name {*}$arch]
# compile the boot modules into one object file
exec [cross_dev_prefix]gcc {*}$arch -c -x assembler -o [run_dir].boot_modules.o - << $asm_src
# link final image
exec [cross_dev_prefix]g++ {*}$arch -nostdlib {*}[core_ld_opts] \
-Wl,-z -Wl,max-page-size=0x1000 \
-Wl,-Ttext=[core_link_address] -Wl,-gc-sections \
-Wl,-nostdlib -Wl,--whole-archive -Wl,--start-group \
$lib [run_dir].boot_modules.o -Wl,--no-whole-archive \
-Wl,--end-group $libgcc -o $target
}
##
# Generate bootable core image containing all boot-modules
#
proc build_core_image {binaries} {
# boot module list without core
set idx [lsearch $binaries "core"]
set modules [lreplace $binaries $idx $idx]
# strip binaries
copy_and_strip_genode_binaries_to_run_dir $modules
lappend modules "config"
# create core binary without modules for debugging
build_core core/core.o {} [run_dir].core
# create core binary containing the boot modules
build_core core/core.o $modules [run_dir]/image.elf
exec [cross_dev_prefix]strip [run_dir]/image.elf
}
##
## Execution of run scripts
##