From 8d43b67ca6a52933c20f380350beebf888e4758b Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 5 May 2014 12:15:31 +0200 Subject: [PATCH] hw: map binaries of boot modules on demand fix #1139 --- repos/base-hw/run/env | 139 +++++++++--------- repos/base-hw/src/core/arm/boot_modules.s | 34 ----- repos/base-hw/src/core/arm/macros.s | 13 +- .../base-hw/src/core/arm_v7/mode_transition.s | 1 + repos/base-hw/src/core/boot_modules.s | 32 ++++ repos/base-hw/src/core/platform.cc | 17 ++- 6 files changed, 119 insertions(+), 117 deletions(-) delete mode 100644 repos/base-hw/src/core/arm/boot_modules.s create mode 100644 repos/base-hw/src/core/boot_modules.s diff --git a/repos/base-hw/run/env b/repos/base-hw/run/env index 5521d93fc..ebfc90093 100644 --- a/repos/base-hw/run/env +++ b/repos/base-hw/run/env @@ -74,82 +74,77 @@ proc build_boot_image {binaries} { # it depends on the individual run scenario. # set boot_modules "[run_dir]/boot_modules.s" - if { [have_spec {arm}] } { - set load_store_align_l2 2 - set min_page_align_l2 12 + # introduce boot module headers + exec echo -e \ + "/**" \ + "\n * This file was automatically generated by the procedure" \ + "\n * 'build_boot_image' in 'base-hw/run/env'." \ + "\n */" \ + "\n" \ + "\n /* core includes */" \ + "\n.include \"macros.s\"" \ + "\n" \ + "\n_common_constants" \ + "\n" \ + "\n.section .data" \ + "\n" \ + "\n.p2align data_access_alignm_log2" \ + "\n.global _boot_modules_headers_begin" \ + "\n_boot_modules_headers_begin:" > $boot_modules - # introduce boot module headers + # generate header for each boot module except core + set i 1 + foreach binary $binaries { + if {$binary == "core"} { continue } exec echo -e \ - "/**" \ - "\n * This file was automatically generated by the procedure" \ - "\n * 'build_boot_image' in 'base-hw/run/env'." \ - "\n */" \ - "\n" \ - "\n.section .data" \ - "\n" \ - "\n.p2align ${load_store_align_l2}" \ - "\n.global _boot_modules_begin" \ - "\n_boot_modules_begin:" \ - "\n.string \"GROM\"" \ - "\n" \ - "\n.p2align ${load_store_align_l2}" \ - "\n.global _boot_module_headers_begin" \ - "\n_boot_module_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.long mod${i}_name" \ - "\n.long mod${i}_start" \ - "\n.long mod${i}_end - mod${i}_start" >> $boot_modules - incr i - } - - # end boot module headers - exec echo -e \ - "\n.global _boot_module_headers_end" \ - "\n_boot_module_headers_end:" \ - "\n" >> $boot_modules - - # generate name string for each module except core - set i 1 - foreach binary $binaries { - if {$binary == "core"} { continue } - exec echo -e \ - ".p2align ${load_store_align_l2}" \ - "\nmod${i}_name:" \ - "\n.string \"${binary}\"" \ - "\n.byte 0" \ - "\n" >> $boot_modules - incr i - } - - # include raw data of modules consecutively but page aligned - set i 1 - foreach binary $binaries { - if {$binary == "core"} { continue } - exec echo -e \ - ".p2align ${min_page_align_l2}" \ - "\nmod${i}_start:" \ - "\n.incbin \"[run_dir]/genode/${binary}\"" \ - "\nmod${i}_end:" \ - "\n" >> $boot_modules - incr i - } - - # end boot-modules file - exec echo -e \ - ".global _boot_modules_end" \ - "\n_boot_modules_end:" >> $boot_modules - - } else { - puts stderr "Error: Unknown architecture" - puts stderr " SPEC must contain one of: 'arm'" - exit -1 + "\n.long _boot_module_${i}_name" \ + "\n.long _boot_module_${i}_begin" \ + "\n.long _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 diff --git a/repos/base-hw/src/core/arm/boot_modules.s b/repos/base-hw/src/core/arm/boot_modules.s deleted file mode 100644 index 98b204865..000000000 --- a/repos/base-hw/src/core/arm/boot_modules.s +++ /dev/null @@ -1,34 +0,0 @@ -/* - * \brief Dummy boot-modules-file to enable a 'core' standalone image - * \author Martin Stein - * \date 2011-12-16 - */ - -/* - * Copyright (C) 2011-2013 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -.section .data - -.align 2 -.global _boot_modules_begin -_boot_modules_begin: -.string "GROM" - -.align 2 -.global _boot_module_headers_begin -_boot_module_headers_begin: - -/* no module headers */ - -.global _boot_module_headers_end -_boot_module_headers_end: - -/* no modules */ - -.global _boot_modules_end -_boot_modules_end: - diff --git a/repos/base-hw/src/core/arm/macros.s b/repos/base-hw/src/core/arm/macros.s index 14601bc47..2387ebf11 100644 --- a/repos/base-hw/src/core/arm/macros.s +++ b/repos/base-hw/src/core/arm/macros.s @@ -72,13 +72,20 @@ .set contextidr_offset, 18 * 4 .set section_table_offset, 19 * 4 - /* alignment constraints */ - .set min_page_size_log2, 12 - /* size of local variables */ .set context_ptr_size, 1 * 4 .endm +/** + * Constant values that are pretty commonly used + */ +.macro _common_constants + + /* alignment constraints */ + .set min_page_size_log2, 12 + .set data_access_alignm_log2, 2 +.endm + /** * Local data structures that the mode transition uses */ diff --git a/repos/base-hw/src/core/arm_v7/mode_transition.s b/repos/base-hw/src/core/arm_v7/mode_transition.s index 04cabb289..603bbd0b3 100644 --- a/repos/base-hw/src/core/arm_v7/mode_transition.s +++ b/repos/base-hw/src/core/arm_v7/mode_transition.s @@ -32,6 +32,7 @@ /* common constants */ _mt_constants +_common_constants /************ diff --git a/repos/base-hw/src/core/boot_modules.s b/repos/base-hw/src/core/boot_modules.s new file mode 100644 index 000000000..53882f41e --- /dev/null +++ b/repos/base-hw/src/core/boot_modules.s @@ -0,0 +1,32 @@ +/* + * \brief Dummy boot-modules-file for building standalone images of core + * \author Martin Stein + * \date 2011-12-16 + */ + +/* + * Copyright (C) 2011-2014 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +.section .data + +.global _boot_modules_headers_begin +_boot_modules_headers_begin: + +/* no headers */ + +.global _boot_modules_headers_end +_boot_modules_headers_end: + +.section .data.boot_modules_binaries + +.global _boot_modules_binaries_begin +_boot_modules_binaries_begin: + +/* no binaries */ + +.global _boot_modules_binaries_end +_boot_modules_binaries_end: diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc index 61181e14d..06ab5dd07 100644 --- a/repos/base-hw/src/core/platform.cc +++ b/repos/base-hw/src/core/platform.cc @@ -43,10 +43,10 @@ struct Bm_header long size; /* size of module data in bytes */ }; -extern int _boot_modules_begin; -extern Bm_header _boot_module_headers_begin; -extern Bm_header _boot_module_headers_end; -extern int _boot_modules_end; +extern Bm_header _boot_modules_headers_begin; +extern Bm_header _boot_modules_headers_end; +extern int _boot_modules_binaries_begin; +extern int _boot_modules_binaries_end; /** * Functionpointer that provides accessor to a pool of address regions @@ -97,8 +97,9 @@ Native_region * Platform::_core_only_ram_regions(unsigned const i) (size_t)((addr_t)&_prog_img_end - (addr_t)&_prog_img_beg) }, /* boot modules */ - { (addr_t)&_boot_modules_begin, - (size_t)((addr_t)&_boot_modules_end - (addr_t)&_boot_modules_begin) } + { (addr_t)&_boot_modules_binaries_begin, + (size_t)((addr_t)&_boot_modules_binaries_end - + (addr_t)&_boot_modules_binaries_begin) } }; return i < sizeof(_r)/sizeof(_r[0]) ? &_r[i] : 0; } @@ -143,8 +144,8 @@ Platform::Platform() init_alloc(&_io_mem_alloc, _mmio_regions, _core_only_mmio_regions, 0); /* add boot modules to ROM FS */ - Bm_header * header = &_boot_module_headers_begin; - for (; header < &_boot_module_headers_end; header++) { + Bm_header * header = &_boot_modules_headers_begin; + for (; header < &_boot_modules_headers_end; header++) { Rom_module * rom_module = new (core_mem_alloc()) Rom_module(header->base, header->size, (const char*)header->name); _rom_fs.insert(rom_module);