diff --git a/repos/base-fiasco/lib/mk/core-fiasco.inc b/repos/base-fiasco/lib/mk/core-fiasco.inc index b887d67912..6ca11281df 100644 --- a/repos/base-fiasco/lib/mk/core-fiasco.inc +++ b/repos/base-fiasco/lib/mk/core-fiasco.inc @@ -25,6 +25,7 @@ SRC_CC += stack_area.cc \ ram_dataspace_factory.cc \ pd_session_support.cc \ platform.cc \ + platform_rom_modules.cc \ platform_pd.cc \ platform_services.cc \ platform_thread.cc \ @@ -74,3 +75,4 @@ vpath default_log.cc $(GEN_CORE_DIR) vpath dump_alloc.cc $(GEN_CORE_DIR) vpath stack_area.cc $(GEN_CORE_DIR) vpath pager_ep.cc $(GEN_CORE_DIR) +vpath platform_rom_modules.cc $(GEN_CORE_DIR) diff --git a/repos/base-fiasco/src/core/include/platform.h b/repos/base-fiasco/src/core/include/platform.h index 8c2ee23f15..6690602964 100644 --- a/repos/base-fiasco/src/core/include/platform.h +++ b/repos/base-fiasco/src/core/include/platform.h @@ -80,13 +80,15 @@ namespace Genode { /** * Parse multi-boot information and update ROM database */ - void _setup_rom(); + void _init_rom_modules(); /** * Setup pager for core-internal threads */ void _setup_core_pager(); + addr_t _rom_module_phys(addr_t virt) { return virt; } + public: /** diff --git a/repos/base-fiasco/src/core/platform.cc b/repos/base-fiasco/src/core/platform.cc index 5f66adfa95..28ee35914e 100644 --- a/repos/base-fiasco/src/core/platform.cc +++ b/repos/base-fiasco/src/core/platform.cc @@ -410,18 +410,6 @@ void Platform::_setup_basics() } -void Platform::_setup_rom() -{ - /* add boot modules to ROM FS */ - Boot_modules_header * header = &_boot_modules_headers_begin; - for (; header < &_boot_modules_headers_end; header++) { - Rom_module * rom = new (core_mem_alloc()) - Rom_module(header->base, header->size, (const char*)header->name); - _rom_fs.insert(rom); - } -} - - Platform::Platform() : _ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()), @@ -439,7 +427,7 @@ Platform::Platform() : _setup_mem_alloc(); _setup_io_port_alloc(); _setup_irq_alloc(); - _setup_rom(); + _init_rom_modules(); log(":ram_alloc: ", _ram_alloc); log(":region_alloc: ", _region_alloc); diff --git a/repos/base-foc/lib/mk/core-foc.inc b/repos/base-foc/lib/mk/core-foc.inc index 379ab28038..2d17f20563 100644 --- a/repos/base-foc/lib/mk/core-foc.inc +++ b/repos/base-foc/lib/mk/core-foc.inc @@ -23,6 +23,7 @@ SRC_CC += stack_area.cc \ native_cpu_component.cc \ rpc_cap_factory.cc \ platform.cc \ + platform_rom_modules.cc \ platform_pd.cc \ platform_services.cc \ platform_thread.cc \ @@ -66,5 +67,6 @@ vpath signal_transmitter_proxy.cc $(GEN_CORE_DIR) vpath signal_receiver.cc $(GEN_CORE_DIR) vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR) vpath core_region_map.cc $(GEN_CORE_DIR) +vpath platform_rom_modules.cc $(GEN_CORE_DIR) vpath %.cc $(REP_DIR)/src/core vpath %.cc $(REP_DIR)/src/lib/base diff --git a/repos/base-foc/src/core/include/platform.h b/repos/base-foc/src/core/include/platform.h index 9af71887f2..525b183857 100644 --- a/repos/base-foc/src/core/include/platform.h +++ b/repos/base-foc/src/core/include/platform.h @@ -98,13 +98,15 @@ namespace Genode { /** * Parse multi-boot information and update ROM database */ - void _setup_rom(); + void _init_rom_modules(); /** * Setup pager for core-internal threads */ void _setup_core_pager(); + addr_t _rom_module_phys(addr_t virt) { return virt; } + public: /** diff --git a/repos/base-foc/src/core/platform.cc b/repos/base-foc/src/core/platform.cc index 6034a2c4bd..f0ba5df1af 100644 --- a/repos/base-foc/src/core/platform.cc +++ b/repos/base-foc/src/core/platform.cc @@ -410,18 +410,6 @@ void Platform::_setup_basics() } -void Platform::_setup_rom() -{ - /* add boot modules to ROM FS */ - Boot_modules_header * header = &_boot_modules_headers_begin; - for (; header < &_boot_modules_headers_end; header++) { - Rom_module * rom = new (core_mem_alloc()) - Rom_module(header->base, header->size, (const char*)header->name); - _rom_fs.insert(rom); - } -} - - Platform::Platform() : _ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()), @@ -440,7 +428,7 @@ Platform::Platform() : _setup_mem_alloc(); _setup_io_port_alloc(); _setup_irq_alloc(); - _setup_rom(); + _init_rom_modules(); log(":ram_alloc: ", _ram_alloc); log(":region_alloc: ", _region_alloc); diff --git a/repos/base-hw/lib/mk/core-hw.inc b/repos/base-hw/lib/mk/core-hw.inc index 36ddfd27c8..be88204843 100644 --- a/repos/base-hw/lib/mk/core-hw.inc +++ b/repos/base-hw/lib/mk/core-hw.inc @@ -32,6 +32,7 @@ SRC_CC += main.cc SRC_CC += native_pd_component.cc SRC_CC += pd_session_support.cc SRC_CC += platform.cc +SRC_CC += platform_rom_modules.cc SRC_CC += platform_pd.cc SRC_CC += platform_thread.cc SRC_CC += stack_area.cc diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc index 926668ec57..142a3c70cd 100644 --- a/repos/base-hw/src/core/platform.cc +++ b/repos/base-hw/src/core/platform.cc @@ -120,16 +120,7 @@ Platform::Platform() } _init_io_mem_alloc(); - - /* add boot modules to ROM FS */ - Boot_modules_header * header = &_boot_modules_headers_begin; - for (; header < &_boot_modules_headers_end; header++) { - Rom_module * rom_module = new (core_mem_alloc()) - Rom_module(Platform::core_phys_addr(header->base), header->size, - (const char*)header->name); - _rom_fs.insert(rom_module); - } - + _init_rom_modules(); _init_additional(); /* print ressource summary */ diff --git a/repos/base-hw/src/core/platform.h b/repos/base-hw/src/core/platform.h index 48be5e995e..bef41be531 100644 --- a/repos/base-hw/src/core/platform.h +++ b/repos/base-hw/src/core/platform.h @@ -51,7 +51,7 @@ class Genode::Platform : public Genode::Platform_generic /** * Initialize I/O port allocator */ - void _init_io_port_alloc(); + void _init_io_port_alloc(); /** * Initialize IO memory allocator @@ -61,12 +61,16 @@ class Genode::Platform : public Genode::Platform_generic * driven outside of core. Using byte granularity allows handing * out the MMIO page to trusted user-level device drivers. */ - void _init_io_mem_alloc(); + void _init_io_mem_alloc(); /** * Perform additional platform-specific initialization. */ - void _init_additional(); + void _init_additional(); + + void _init_rom_modules(); + + addr_t _rom_module_phys(addr_t virt) { return core_phys_addr(virt); } public: diff --git a/repos/base-nova/lib/mk/core-nova.inc b/repos/base-nova/lib/mk/core-nova.inc index 73b70ffdaa..3c5761c6f2 100644 --- a/repos/base-nova/lib/mk/core-nova.inc +++ b/repos/base-nova/lib/mk/core-nova.inc @@ -28,6 +28,7 @@ SRC_CC += stack_area.cc \ rpc_cap_factory.cc \ ram_dataspace_factory.cc \ platform.cc \ + platform_rom_modules.cc \ platform_pd.cc \ platform_services.cc \ platform_thread.cc \ @@ -69,6 +70,7 @@ vpath dataspace_component.cc $(GEN_CORE_DIR) vpath core_mem_alloc.cc $(GEN_CORE_DIR) vpath default_log.cc $(GEN_CORE_DIR) vpath dump_alloc.cc $(GEN_CORE_DIR) +vpath platform_rom_modules.cc $(GEN_CORE_DIR) vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86 vpath stack_area.cc $(GEN_CORE_DIR) vpath core_printf.cc $(BASE_DIR)/src/lib/base diff --git a/repos/base-nova/src/core/include/platform.h b/repos/base-nova/src/core/include/platform.h index bde2302962..54c025cd37 100644 --- a/repos/base-nova/src/core/include/platform.h +++ b/repos/base-nova/src/core/include/platform.h @@ -36,6 +36,7 @@ namespace Genode { Rom_fs _rom_fs; /* ROM file system */ unsigned _gsi_base_sel; /* cap selector of 1st IRQ */ unsigned _core_pd_sel; /* cap selector of root PD */ + addr_t _core_phys_start { 0ULL }; /** * Virtual address range usable by non-core processes @@ -53,6 +54,10 @@ namespace Genode { size_t _max_caps = 0; + void _init_rom_modules(); + + addr_t _rom_module_phys(addr_t virt); + public: /** diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc index 19f094433c..c52104985e 100644 --- a/repos/base-nova/src/core/platform.cc +++ b/repos/base-nova/src/core/platform.cc @@ -617,7 +617,6 @@ Platform::Platform() : }; } mbi_fb; - /* build ROM file system */ mem_desc = (Hip::Mem_desc *)mem_desc_base; for (unsigned i = 0; i < num_mem_desc; i++, mem_desc++) { if (mem_desc->type == Hip::Mem_desc::ACPI_RSDT) rsdt = mem_desc->addr; @@ -631,19 +630,11 @@ Platform::Platform() : if (!mem_desc->addr || !mem_desc->size) continue; /* assume core's ELF image has one-page header */ - addr_t const core_phys_start = trunc_page(mem_desc->addr + get_page_size()); - addr_t const core_virt_start = (addr_t) &_prog_img_beg; - - /* add boot modules to ROM FS */ - Boot_modules_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 - core_virt_start + core_phys_start, - header->size, (const char*)header->name); - _rom_fs.insert(rom_module); - } + _core_phys_start = trunc_page(mem_desc->addr + get_page_size()); } + _init_rom_modules(); + { /* export x86 platform specific infos */ @@ -784,6 +775,12 @@ Platform::Platform() : } +addr_t Platform::_rom_module_phys(addr_t virt) +{ + return virt - (addr_t)&_prog_img_beg + _core_phys_start; +} + + unsigned Platform::kernel_cpu_id(unsigned genode_cpu_id) { if (genode_cpu_id >= sizeof(map_cpu_ids) / sizeof(map_cpu_ids[0])) { diff --git a/repos/base-okl4/lib/mk/core-okl4.inc b/repos/base-okl4/lib/mk/core-okl4.inc index f591e69df6..596b238423 100644 --- a/repos/base-okl4/lib/mk/core-okl4.inc +++ b/repos/base-okl4/lib/mk/core-okl4.inc @@ -28,6 +28,7 @@ SRC_CC += stack_area.cc \ rpc_cap_factory_l4.cc \ ram_dataspace_factory.cc \ platform.cc \ + platform_rom_modules.cc \ platform_pd.cc \ platform_services.cc \ platform_thread.cc \ @@ -72,3 +73,4 @@ vpath dump_alloc.cc $(GEN_CORE_DIR) vpath default_log.cc $(GEN_CORE_DIR) vpath stack_area.cc $(GEN_CORE_DIR) vpath pager_ep.cc $(GEN_CORE_DIR) +vpath platform_rom_modules.cc $(GEN_CORE_DIR) diff --git a/repos/base-okl4/src/core/include/platform.h b/repos/base-okl4/src/core/include/platform.h index 4e72dd383a..5c98150373 100644 --- a/repos/base-okl4/src/core/include/platform.h +++ b/repos/base-okl4/src/core/include/platform.h @@ -64,7 +64,9 @@ namespace Genode { */ addr_t _utcb_base; - void _setup_rom(); + void _init_rom_modules(); + + addr_t _rom_module_phys(addr_t virt) { return virt; } public: diff --git a/repos/base-okl4/src/core/platform.cc b/repos/base-okl4/src/core/platform.cc index a2900d1b6b..01044d966d 100644 --- a/repos/base-okl4/src/core/platform.cc +++ b/repos/base-okl4/src/core/platform.cc @@ -92,18 +92,6 @@ int Platform::bi_add_phys_mem(Okl4::bi_name_t pool, Okl4::uintptr_t base, } -void Platform::_setup_rom() -{ - /* add boot modules to ROM FS */ - Boot_modules_header * header = &_boot_modules_headers_begin; - for (; header < &_boot_modules_headers_end; header++) { - Rom_module * rom = new (core_mem_alloc()) - Rom_module(header->base, header->size, (const char*)header->name); - _rom_fs.insert(rom); - } -} - - static char init_slab_block_rom[get_page_size()]; static char init_slab_block_thread[get_page_size()]; @@ -173,7 +161,7 @@ Platform::Platform() : /* I/O port allocator (only meaningful for x86) */ _io_port_alloc.add_range(0, 0x10000); - _setup_rom(); + _init_rom_modules(); /* preserve stack area in core's virtual address space */ _core_mem_alloc.virt_alloc()->remove_range(stack_area_virtual_base(), diff --git a/repos/base-pistachio/lib/mk/core-pistachio.inc b/repos/base-pistachio/lib/mk/core-pistachio.inc index 1d2dc822cb..c2b6f6a353 100644 --- a/repos/base-pistachio/lib/mk/core-pistachio.inc +++ b/repos/base-pistachio/lib/mk/core-pistachio.inc @@ -26,6 +26,7 @@ SRC_CC = stack_area.cc \ pager_ep.cc \ pager_object.cc \ platform.cc \ + platform_rom_modules.cc \ platform_pd.cc \ platform_services.cc \ platform_thread.cc \ @@ -70,3 +71,4 @@ vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR) vpath core_region_map.cc $(GEN_CORE_DIR) vpath stack_area.cc $(GEN_CORE_DIR) vpath pager_ep.cc $(GEN_CORE_DIR) +vpath platform_rom_modules.cc $(GEN_CORE_DIR) diff --git a/repos/base-pistachio/src/core/include/platform.h b/repos/base-pistachio/src/core/include/platform.h index d86f2d709d..d3c4007a97 100644 --- a/repos/base-pistachio/src/core/include/platform.h +++ b/repos/base-pistachio/src/core/include/platform.h @@ -86,7 +86,9 @@ namespace Genode { /** * Parse multi-boot information and update ROM database */ - void _setup_rom(); + void _init_rom_modules(); + + addr_t _rom_module_phys(addr_t virt) { return virt; } public: diff --git a/repos/base-pistachio/src/core/platform.cc b/repos/base-pistachio/src/core/platform.cc index 6db04048f9..1a8434c1c4 100644 --- a/repos/base-pistachio/src/core/platform.cc +++ b/repos/base-pistachio/src/core/platform.cc @@ -575,18 +575,6 @@ void Platform::_setup_basics() } -void Platform::_setup_rom() -{ - /* add boot modules to ROM FS */ - Boot_modules_header * header = &_boot_modules_headers_begin; - for (; header < &_boot_modules_headers_end; header++) { - Rom_module * rom = new (core_mem_alloc()) - Rom_module(header->base, header->size, (const char*)header->name); - _rom_fs.insert(rom); - } -} - - Platform_pd *Platform::core_pd() { /* on first call, setup task object for core task */ @@ -614,12 +602,13 @@ Platform::Platform() : _setup_mem_alloc(); _setup_io_port_alloc(); _setup_irq_alloc(); - _setup_rom(); + _init_rom_modules(); /* * When dumping 'ram_alloc', there are several small blocks in addition * to the available free memory visible. These small blocks are used to - * hold the meta data for the ROM modules as initialized by '_setup_rom'. + * hold the meta data for the ROM modules as initialized by + * '_init_rom_modules'. */ if (verbose) { log(":ram_alloc: ", _ram_alloc); diff --git a/repos/base/src/core/platform_rom_modules.cc b/repos/base/src/core/platform_rom_modules.cc new file mode 100644 index 0000000000..3ac0f6fc0f --- /dev/null +++ b/repos/base/src/core/platform_rom_modules.cc @@ -0,0 +1,32 @@ +/* + * \brief Default implementation of the ROM modules initialization + * \author Martin Stein + * \date 2017-08-17 + */ + +/* + * Copyright (C) 2017 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +/* core includes */ +#include +#include + +using namespace Genode; + + +void Platform::_init_rom_modules() +{ + /* add boot modules to ROM FS */ + Boot_modules_header *header = &_boot_modules_headers_begin; + for (; header < &_boot_modules_headers_end; header++) { + + Rom_module *rom_module = new (core_mem_alloc()) + Rom_module(_rom_module_phys(header->base), header->size, + (const char*)header->name); + _rom_fs.insert(rom_module); + } +}