diff --git a/repos/base-fiasco/src/core/target.inc b/repos/base-fiasco/lib/mk/core.inc similarity index 96% rename from repos/base-fiasco/src/core/target.inc rename to repos/base-fiasco/lib/mk/core.inc index 1cb620ded..a5363a561 100644 --- a/repos/base-fiasco/src/core/target.inc +++ b/repos/base-fiasco/lib/mk/core.inc @@ -1,5 +1,3 @@ -TARGET = core - GEN_CORE_DIR = $(BASE_DIR)/src/core SRC_CC += stack_area.cc \ @@ -19,7 +17,6 @@ SRC_CC += stack_area.cc \ io_port_session_support.cc \ irq_session_component.cc \ main.cc \ - multiboot_info.cc \ pager.cc \ pager_ep.cc \ pager_object.cc \ @@ -50,7 +47,6 @@ LIBS += base-common include $(GEN_CORE_DIR)/version.inc vpath main.cc $(GEN_CORE_DIR) -vpath multiboot_info.cc $(GEN_CORE_DIR) vpath ram_session_component.cc $(GEN_CORE_DIR) vpath rom_session_component.cc $(GEN_CORE_DIR) vpath cap_session_component.cc $(GEN_CORE_DIR) diff --git a/repos/base-fiasco/src/core/spec/x86/target.mk b/repos/base-fiasco/lib/mk/spec/x86/core.mk similarity index 69% rename from repos/base-fiasco/src/core/spec/x86/target.mk rename to repos/base-fiasco/lib/mk/spec/x86/core.mk index 919ee322f..4e0e0d36e 100644 --- a/repos/base-fiasco/src/core/spec/x86/target.mk +++ b/repos/base-fiasco/lib/mk/spec/x86/core.mk @@ -1,4 +1,4 @@ -include $(PRG_DIR)/../../target.inc +include $(REP_DIR)/lib/mk/core.inc REQUIRES += x86 SRC_CC += platform_x86.cc @@ -6,4 +6,4 @@ SRC_CC += platform_x86.cc vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86 vpath io_port_session_support.cc $(GEN_CORE_DIR)/spec/x86 vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86 - +vpath platform_x86.cc $(REP_DIR)/src/core/spec/x86 diff --git a/repos/base-fiasco/mk/spec/fiasco_x86.mk b/repos/base-fiasco/mk/spec/fiasco_x86.mk index 4f55d3050..012c51648 100644 --- a/repos/base-fiasco/mk/spec/fiasco_x86.mk +++ b/repos/base-fiasco/mk/spec/fiasco_x86.mk @@ -11,11 +11,6 @@ SPECS += pci ps2 vesa framebuffer L4_INC_DIR += $(L4_BUILD_DIR)/include/x86/l4v2 \ $(L4_BUILD_DIR)/include/x86 -# -# Linker options that are specific for x86 -# -LD_TEXT_ADDR ?= 0x01000000 - # # Also include less-specific configuration last # diff --git a/repos/base-fiasco/src/core/include/platform.h b/repos/base-fiasco/src/core/include/platform.h index a584fe7d8..917e928e8 100644 --- a/repos/base-fiasco/src/core/include/platform.h +++ b/repos/base-fiasco/src/core/include/platform.h @@ -21,7 +21,7 @@ #include "platform_generic.h" #include "platform_thread.h" #include "platform_pd.h" -#include "multiboot.h" +#include "boot_modules.h" namespace Genode { @@ -42,7 +42,6 @@ namespace Genode { Phys_allocator _io_port_alloc; /* I/O port allocator */ Phys_allocator _irq_alloc; /* IRQ allocator */ Phys_allocator _region_alloc; /* virtual memory allocator for core */ - Multiboot_info _mb_info; /* multiboot information */ Rom_fs _rom_fs; /* ROM file system */ Rom_module _kip_rom; /* ROM module for Fiasco KIP */ @@ -59,7 +58,6 @@ namespace Genode { * * - Map and provide KIP as ROM module * - Initializes region allocator - * - Initializes multiboot info structure */ void _setup_basics(); diff --git a/repos/base-fiasco/src/core/platform.cc b/repos/base-fiasco/src/core/platform.cc index e21b2046b..ae1038066 100644 --- a/repos/base-fiasco/src/core/platform.cc +++ b/repos/base-fiasco/src/core/platform.cc @@ -30,7 +30,6 @@ #include #include #include -#include /* Fiasco includes */ namespace Fiasco { @@ -364,10 +363,6 @@ void Platform::_setup_basics() _kip_rom = Rom_module((addr_t)kip, L4_PAGESIZE, "l4v2_kip"); _rom_fs.insert(&_kip_rom); - /* update multi-boot info pointer from KIP */ - addr_t mb_info_addr = kip->user_ptr; - log("MBI @ ", Hex(mb_info_addr)); - /* parse memory descriptors - look for virtual memory configuration */ /* XXX we support only one VM region (here and also inside RM) */ using L4::Kip::Mem_desc; @@ -398,11 +393,9 @@ void Platform::_setup_basics() /* FIXME if the kernel helps to find out max address - use info here */ _io_mem_alloc.add_range(0, ~0); - /* remove KIP and MBI area from region and IO_MEM allocator */ + /* remove KIP area from region and IO_MEM allocator */ remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _region_alloc); remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _io_mem_alloc); - remove_region(Region(mb_info_addr, mb_info_addr + _mb_info.size()), _region_alloc); - remove_region(Region(mb_info_addr, mb_info_addr + _mb_info.size()), _io_mem_alloc); /* remove core program image memory from region and IO_MEM allocator */ addr_t img_start = (addr_t) &_prog_img_beg; @@ -417,29 +410,12 @@ void Platform::_setup_basics() void Platform::_setup_rom() { - Rom_module rom; - - for (unsigned i = FIRST_ROM; i < _mb_info.num_modules(); i++) { - if (!(rom = _mb_info.get_module(i)).valid()) continue; - - Rom_module *new_rom = new(core_mem_alloc()) Rom_module(rom); - _rom_fs.insert(new_rom); - - log(" mod[", i, "] ", - Hex_range(new_rom->addr(), new_rom->size()), " ", - new_rom->name()); - - /* zero remainder of last ROM page */ - size_t count = L4_PAGESIZE - rom.size() % L4_PAGESIZE; - if (count != L4_PAGESIZE) - memset(reinterpret_cast(rom.addr() + rom.size()), 0, count); - - /* remove ROM area from region and IO_MEM allocator */ - remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _region_alloc); - remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _io_mem_alloc); - - /* add area to core-accessible ranges */ - add_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _core_address_ranges()); + /* 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); } } @@ -447,8 +423,7 @@ void Platform::_setup_rom() Platform::Platform() : _ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()), - _region_alloc(core_mem_alloc()), - _mb_info(get_kip()->user_ptr, true) + _region_alloc(core_mem_alloc()) { /* * We must be single-threaded at this stage and so this is safe. diff --git a/repos/base-foc/src/core/target.inc b/repos/base-foc/lib/mk/core.inc similarity index 96% rename from repos/base-foc/src/core/target.inc rename to repos/base-foc/lib/mk/core.inc index 60836a50a..5ed1e9608 100644 --- a/repos/base-foc/src/core/target.inc +++ b/repos/base-foc/lib/mk/core.inc @@ -1,4 +1,3 @@ -TARGET = core REQUIRES += foc GEN_CORE_DIR = $(BASE_DIR)/src/core @@ -20,7 +19,6 @@ SRC_CC += stack_area.cc \ ipc_pager.cc \ irq_session_component.cc \ main.cc \ - multiboot_info.cc \ pager.cc \ pager_object.cc \ pd_session_component.cc \ @@ -59,7 +57,6 @@ vpath default_log.cc $(GEN_CORE_DIR) vpath io_mem_session_component.cc $(GEN_CORE_DIR) vpath io_mem_session_support.cc $(GEN_CORE_DIR) vpath main.cc $(GEN_CORE_DIR) -vpath multiboot_info.cc $(GEN_CORE_DIR) vpath pd_session_component.cc $(GEN_CORE_DIR) vpath pd_assign_pci.cc $(GEN_CORE_DIR) vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR) diff --git a/repos/base-foc/src/core/spec/arm/target.inc b/repos/base-foc/lib/mk/spec/arm/core.mk similarity index 84% rename from repos/base-foc/src/core/spec/arm/target.inc rename to repos/base-foc/lib/mk/spec/arm/core.mk index 89518d79f..b489cb0bf 100644 --- a/repos/base-foc/src/core/spec/arm/target.inc +++ b/repos/base-foc/lib/mk/spec/arm/core.mk @@ -5,6 +5,6 @@ SRC_CC += spec/arm/platform_arm.cc \ # override default stack-area location INC_DIR += $(REP_DIR)/src/include/spec/arm -include $(REP_DIR)/src/core/target.inc +include $(REP_DIR)/lib/mk/core.inc vpath platform_services.cc $(GEN_CORE_DIR) diff --git a/repos/base-foc/src/core/spec/x86/target.inc b/repos/base-foc/lib/mk/spec/x86/core.inc similarity index 85% rename from repos/base-foc/src/core/spec/x86/target.inc rename to repos/base-foc/lib/mk/spec/x86/core.inc index 6528f4ec2..50db05df6 100644 --- a/repos/base-foc/src/core/spec/x86/target.inc +++ b/repos/base-foc/lib/mk/spec/x86/core.inc @@ -1,4 +1,3 @@ -LD_TEXT_ADDR = 0x500000 REQUIRES += x86 SRC_CC += io_port_session_component.cc \ io_port_session_support.cc \ @@ -9,4 +8,4 @@ vpath io_port_session_component.cc $(BASE_DIR)/src/core/spec/x86 vpath io_port_session_support.cc $(BASE_DIR)/src/core/spec/x86 vpath platform_services.cc $(BASE_DIR)/src/core/spec/x86 -include $(REP_DIR)/src/core/target.inc +include $(REP_DIR)/lib/mk/core.inc diff --git a/repos/base-foc/src/core/spec/x86_32/target.mk b/repos/base-foc/lib/mk/spec/x86_32/core.mk similarity index 55% rename from repos/base-foc/src/core/spec/x86_32/target.mk rename to repos/base-foc/lib/mk/spec/x86_32/core.mk index 0bc5f3157..529c64ce2 100644 --- a/repos/base-foc/src/core/spec/x86_32/target.mk +++ b/repos/base-foc/lib/mk/spec/x86_32/core.mk @@ -1,4 +1,4 @@ REQUIRES += foc_x86_32 SRC_CC += spec/x86_32/ipc_pager.cc -include $(REP_DIR)/src/core/spec/x86/target.inc +include $(REP_DIR)/lib/mk/spec/x86/core.inc diff --git a/repos/base-foc/src/core/spec/x86_64/target.mk b/repos/base-foc/lib/mk/spec/x86_64/core.mk similarity index 55% rename from repos/base-foc/src/core/spec/x86_64/target.mk rename to repos/base-foc/lib/mk/spec/x86_64/core.mk index 54ff8c86f..d73055232 100644 --- a/repos/base-foc/src/core/spec/x86_64/target.mk +++ b/repos/base-foc/lib/mk/spec/x86_64/core.mk @@ -1,4 +1,4 @@ REQUIRES += foc_x86_64 SRC_CC += spec/x86_64/ipc_pager.cc -include $(REP_DIR)/src/core/spec/x86/target.inc +include $(REP_DIR)/lib/mk/spec/x86/core.inc diff --git a/repos/base-foc/mk/spec/foc_arm.mk b/repos/base-foc/mk/spec/foc_arm.mk index d605a1e0f..c616e3e97 100644 --- a/repos/base-foc/mk/spec/foc_arm.mk +++ b/repos/base-foc/mk/spec/foc_arm.mk @@ -4,11 +4,6 @@ SPECS += foc -# -# Linker options that are specific for arm -# -LD_TEXT_ADDR ?= 0x01000000 - # # ARM-specific L4/sys headers # diff --git a/repos/base-foc/mk/spec/foc_x86_32.mk b/repos/base-foc/mk/spec/foc_x86_32.mk index b110cc7f7..ae9faba34 100644 --- a/repos/base-foc/mk/spec/foc_x86_32.mk +++ b/repos/base-foc/mk/spec/foc_x86_32.mk @@ -5,11 +5,6 @@ SPECS += x86_32 foc SPECS += pci ps2 vesa framebuffer -# -# Linker options that are specific for x86 -# -LD_TEXT_ADDR ?= 0x01000000 - # # L4/sys headers # diff --git a/repos/base-foc/mk/spec/foc_x86_64.mk b/repos/base-foc/mk/spec/foc_x86_64.mk index cd9b8d52c..c9557cdaa 100644 --- a/repos/base-foc/mk/spec/foc_x86_64.mk +++ b/repos/base-foc/mk/spec/foc_x86_64.mk @@ -5,11 +5,6 @@ SPECS += x86_64 foc SPECS += pci ps2 vesa framebuffer -# -# Linker options that are specific for x86 -# -LD_TEXT_ADDR ?= 0x01000000 - # # L4/sys headers # diff --git a/repos/base-foc/src/core/include/platform.h b/repos/base-foc/src/core/include/platform.h index e00993f9f..b790c1d53 100644 --- a/repos/base-foc/src/core/include/platform.h +++ b/repos/base-foc/src/core/include/platform.h @@ -26,7 +26,6 @@ #include #include #include -#include namespace Genode { @@ -60,7 +59,6 @@ namespace Genode { Phys_allocator _irq_alloc; /* IRQ allocator */ Phys_allocator _region_alloc; /* virtual memory allocator for core */ Cap_id_allocator _cap_id_alloc; /* capability id allocator */ - Multiboot_info _mb_info; /* multiboot information */ Rom_fs _rom_fs; /* ROM file system */ Rom_module _kip_rom; /* ROM module for Fiasco KIP */ Sigma0 _sigma0; @@ -79,7 +77,6 @@ namespace Genode { * * - Map and provide KIP as ROM module * - Initializes region allocator - * - Initializes multiboot info structure */ void _setup_basics(); diff --git a/repos/base-foc/src/core/platform.cc b/repos/base-foc/src/core/platform.cc index 7a2576e4a..f7c443092 100644 --- a/repos/base-foc/src/core/platform.cc +++ b/repos/base-foc/src/core/platform.cc @@ -24,12 +24,12 @@ #include /* core includes */ +#include #include #include #include #include #include -#include /* Fiasco includes */ namespace Fiasco { @@ -397,8 +397,6 @@ void Platform::_setup_basics() /* remove KIP and MBI area from region and IO_MEM allocator */ remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _region_alloc); remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _io_mem_alloc); - remove_region(Region(mb_info_addr, mb_info_addr + _mb_info.size()), _region_alloc); - remove_region(Region(mb_info_addr, mb_info_addr + _mb_info.size()), _io_mem_alloc); /* remove core program image memory from region and IO_MEM allocator */ addr_t img_start = (addr_t) &_prog_img_beg; @@ -413,28 +411,12 @@ void Platform::_setup_basics() void Platform::_setup_rom() { - Rom_module rom; - - for (unsigned i = FIRST_ROM; i < _mb_info.num_modules(); i++) { - if (!(rom = _mb_info.get_module(i)).valid()) continue; - - Rom_module *new_rom = new(core_mem_alloc()) Rom_module(rom); - _rom_fs.insert(new_rom); - - /* map module */ - touch_ro((const void*)new_rom->addr(), new_rom->size()); - - /* zero remainder of last ROM page */ - size_t count = L4_PAGESIZE - rom.size() % L4_PAGESIZE; - if (count != L4_PAGESIZE) - memset(reinterpret_cast(rom.addr() + rom.size()), 0, count); - - /* remove ROM area from region and IO_MEM allocator */ - remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _region_alloc); - remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _io_mem_alloc); - - /* add area to core-accessible ranges */ - add_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _core_address_ranges()); + /* 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); } Rom_module *kip_rom = new(core_mem_alloc()) @@ -447,7 +429,6 @@ Platform::Platform() : _ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()), _region_alloc(core_mem_alloc()), _cap_id_alloc(core_mem_alloc()), - _mb_info(sigma0_map_kip()->user_ptr, true), _sigma0(cap_map()->insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_PAGER_CAP)) { /* diff --git a/repos/base-foc/src/core/rpc_cap_factory.cc b/repos/base-foc/src/core/rpc_cap_factory.cc index 4127ab2e1..4ee0040e8 100644 --- a/repos/base-foc/src/core/rpc_cap_factory.cc +++ b/repos/base-foc/src/core/rpc_cap_factory.cc @@ -14,6 +14,7 @@ /* Genode includes */ #include +#include #include /* core includes */ diff --git a/repos/base-foc/src/core/spec/arndale/target.mk b/repos/base-foc/src/core/spec/arndale/target.mk deleted file mode 100644 index dd78d5799..000000000 --- a/repos/base-foc/src/core/spec/arndale/target.mk +++ /dev/null @@ -1,4 +0,0 @@ -LD_TEXT_ADDR = 0x80100000 -REQUIRES += foc_arndale - -include $(REP_DIR)/src/core/spec/arm/target.inc diff --git a/repos/base-foc/src/core/spec/imx53/target.mk b/repos/base-foc/src/core/spec/imx53/target.mk deleted file mode 100644 index d0f262dad..000000000 --- a/repos/base-foc/src/core/spec/imx53/target.mk +++ /dev/null @@ -1,4 +0,0 @@ -LD_TEXT_ADDR = 0x70140000 -REQUIRES += foc_imx53 - -include $(REP_DIR)/src/core/spec/arm/target.inc diff --git a/repos/base-foc/src/core/spec/odroid_x2/target.mk b/repos/base-foc/src/core/spec/odroid_x2/target.mk deleted file mode 100644 index 6e50fe2ed..000000000 --- a/repos/base-foc/src/core/spec/odroid_x2/target.mk +++ /dev/null @@ -1,4 +0,0 @@ -LD_TEXT_ADDR = 0x80100000 -REQUIRES += foc_odroid_x2 - -include $(REP_DIR)/src/core/spec/arm/target.inc diff --git a/repos/base-foc/src/core/spec/panda/target.mk b/repos/base-foc/src/core/spec/panda/target.mk deleted file mode 100644 index 261c6498c..000000000 --- a/repos/base-foc/src/core/spec/panda/target.mk +++ /dev/null @@ -1,4 +0,0 @@ -LD_TEXT_ADDR = 0x80140000 -REQUIRES += foc_panda - -include $(REP_DIR)/src/core/spec/arm/target.inc diff --git a/repos/base-foc/src/core/spec/pbxa9/target.mk b/repos/base-foc/src/core/spec/pbxa9/target.mk deleted file mode 100644 index 2503f11d9..000000000 --- a/repos/base-foc/src/core/spec/pbxa9/target.mk +++ /dev/null @@ -1,4 +0,0 @@ -LD_TEXT_ADDR = 0x70490000 -REQUIRES += foc_pbxa9 - -include $(REP_DIR)/src/core/spec/arm/target.inc diff --git a/repos/base-foc/src/core/spec/rpi/target.mk b/repos/base-foc/src/core/spec/rpi/target.mk deleted file mode 100644 index e5b98dfbb..000000000 --- a/repos/base-foc/src/core/spec/rpi/target.mk +++ /dev/null @@ -1,5 +0,0 @@ -REQUIRES += foc_rpi -LD_TEXT_ADDR ?= 0x800000 - -include $(REP_DIR)/src/core/spec/arm/target.inc - diff --git a/repos/base-hw/lib/mk/core.inc b/repos/base-hw/lib/mk/core.inc index cc7c2c997..a10857784 100644 --- a/repos/base-hw/lib/mk/core.inc +++ b/repos/base-hw/lib/mk/core.inc @@ -62,22 +62,9 @@ SRC_CC += kernel/object.cc SRC_CC += init_main_thread.cc SRC_CC += capability.cc -# add assembly sources -SRC_S += boot_modules.s - # provide Genode version information include $(BASE_DIR)/src/core/version.inc -# switch to build-specific boot-modules if further images shall be available -ifneq ($(wildcard $(BUILD_BASE_DIR)/boot_modules.s),) - BOOT_MODULES_VPATH = $(BUILD_BASE_DIR) - INC_DIR += $(BOOT_MODULES_VPATH) -else - # use dummy boot-modules per default - BOOT_MODULES_VPATH = $(BASE_DIR)/../base-hw/src/core/ -endif -vpath boot_modules.s $(BOOT_MODULES_VPATH) - # declare source locations vpath % $(BASE_DIR)/../base-hw/src/core vpath % $(BASE_DIR)/src/core diff --git a/repos/base-hw/mk/spec/hw_arndale.mk b/repos/base-hw/mk/spec/hw_arndale.mk index fa240172c..8507e7617 100644 --- a/repos/base-hw/mk/spec/hw_arndale.mk +++ b/repos/base-hw/mk/spec/hw_arndale.mk @@ -13,9 +13,6 @@ NR_OF_CPUS = 2 # add repository relative paths REP_INC_DIR += include/exynos5_uart -# set address where to link the text segment at -LD_TEXT_ADDR ?= 0x80000000 - # include implied specs include $(call select_from_repositories,mk/spec/hw.mk) include $(call select_from_repositories,mk/spec/arndale.mk) diff --git a/repos/base-hw/mk/spec/hw_imx53_qsb.mk b/repos/base-hw/mk/spec/hw_imx53_qsb.mk index 0ab751733..94d681899 100644 --- a/repos/base-hw/mk/spec/hw_imx53_qsb.mk +++ b/repos/base-hw/mk/spec/hw_imx53_qsb.mk @@ -10,9 +10,6 @@ SPECS += hw imx53_qsb imx53 # configure multiprocessor mode NR_OF_CPUS = 1 -# set address where to link the text segment at -LD_TEXT_ADDR ?= 0x70010000 - # add repository relative include paths REP_INC_DIR += include/spec/imx53_qsb diff --git a/repos/base-hw/mk/spec/hw_odroid_xu.mk b/repos/base-hw/mk/spec/hw_odroid_xu.mk index 4c6b97139..77c099319 100644 --- a/repos/base-hw/mk/spec/hw_odroid_xu.mk +++ b/repos/base-hw/mk/spec/hw_odroid_xu.mk @@ -13,9 +13,6 @@ NR_OF_CPUS = 1 # add repository relative paths REP_INC_DIR += include/exynos5_uart -# set address where to link the text segment at -LD_TEXT_ADDR ?= 0x80000000 - # include implied specs include $(call select_from_repositories,mk/spec/hw.mk) include $(call select_from_repositories,mk/spec/odroid_xu.mk) diff --git a/repos/base-hw/mk/spec/hw_panda.mk b/repos/base-hw/mk/spec/hw_panda.mk index 0073363a0..f18ffd79b 100644 --- a/repos/base-hw/mk/spec/hw_panda.mk +++ b/repos/base-hw/mk/spec/hw_panda.mk @@ -10,9 +10,6 @@ SPECS += hw panda # configure multiprocessor mode NR_OF_CPUS = 2 -# set address where to link the text segment at -LD_TEXT_ADDR ?= 0x81000000 - # include implied specs include $(call select_from_repositories,mk/spec/hw.mk) include $(call select_from_repositories,mk/spec/panda.mk) diff --git a/repos/base-hw/mk/spec/hw_pbxa9.mk b/repos/base-hw/mk/spec/hw_pbxa9.mk index 6cebb79a6..8d3d47aad 100644 --- a/repos/base-hw/mk/spec/hw_pbxa9.mk +++ b/repos/base-hw/mk/spec/hw_pbxa9.mk @@ -10,9 +10,6 @@ SPECS += hw pbxa9 # configure multiprocessor mode NR_OF_CPUS = 1 -# set address where to link text segment at -LD_TEXT_ADDR ?= 0x70000000 - # include implied specs include $(call select_from_repositories,mk/spec/hw.mk) include $(call select_from_repositories,mk/spec/pbxa9.mk) diff --git a/repos/base-hw/mk/spec/hw_riscv.mk b/repos/base-hw/mk/spec/hw_riscv.mk index 1c3ece662..c8a1d4e97 100644 --- a/repos/base-hw/mk/spec/hw_riscv.mk +++ b/repos/base-hw/mk/spec/hw_riscv.mk @@ -1,9 +1,6 @@ -SPECS += hw riscv platform_riscv 64bit - -LD_TEXT_ADDR ?= 0x1000000 -CORE_LD_TEXT_ADDR = 0x200 -NR_OF_CPUS = 1 -REP_INC_DIR += include/spec/riscv +SPECS += hw riscv platform_riscv 64bit +NR_OF_CPUS = 1 +REP_INC_DIR += include/spec/riscv include $(call select_from_repositories,mk/spec/64bit.mk) include $(call select_from_repositories,mk/spec/hw.mk) diff --git a/repos/base-hw/mk/spec/hw_rpi.mk b/repos/base-hw/mk/spec/hw_rpi.mk index 39a0d0977..fa0b1b328 100644 --- a/repos/base-hw/mk/spec/hw_rpi.mk +++ b/repos/base-hw/mk/spec/hw_rpi.mk @@ -10,9 +10,6 @@ SPECS += hw rpi # configure multiprocessor mode NR_OF_CPUS = 1 -# set address where to link the text segment at -LD_TEXT_ADDR ?= 0x800000 - # include implied specs include $(call select_from_repositories,mk/spec/hw.mk) include $(call select_from_repositories,mk/spec/rpi.mk) diff --git a/repos/base-hw/mk/spec/hw_usb_armory.mk b/repos/base-hw/mk/spec/hw_usb_armory.mk index e23ac8589..018d09982 100644 --- a/repos/base-hw/mk/spec/hw_usb_armory.mk +++ b/repos/base-hw/mk/spec/hw_usb_armory.mk @@ -10,9 +10,6 @@ SPECS += hw usb_armory imx53 trustzone # configure multiprocessor mode NR_OF_CPUS = 1 -# set address where to link the text segment at -LD_TEXT_ADDR ?= 0x72000000 - # add repository relative include paths REP_INC_DIR += include/spec/usb_armory diff --git a/repos/base-hw/mk/spec/hw_wand_quad.mk b/repos/base-hw/mk/spec/hw_wand_quad.mk index 6a7c7ca82..793b9d9ab 100644 --- a/repos/base-hw/mk/spec/hw_wand_quad.mk +++ b/repos/base-hw/mk/spec/hw_wand_quad.mk @@ -12,9 +12,6 @@ SPECS += hw imx6 # configure multiprocessor mode NR_OF_CPUS = 1 -# set address where to link the text segment at -LD_TEXT_ADDR ?= 0x10001000 - # include implied specs include $(call select_from_repositories,mk/spec/hw.mk) include $(call select_from_repositories,mk/spec/imx6.mk) diff --git a/repos/base-hw/mk/spec/hw_x86_64.mk b/repos/base-hw/mk/spec/hw_x86_64.mk index 48af6be89..dffd8088a 100644 --- a/repos/base-hw/mk/spec/hw_x86_64.mk +++ b/repos/base-hw/mk/spec/hw_x86_64.mk @@ -11,9 +11,6 @@ SPECS += pci ps2 vesa framebuffer # configure multiprocessor mode NR_OF_CPUS = 1 -# set address where to link text segment at -LD_TEXT_ADDR ?= 0x200000 - # include implied specs include $(call select_from_repositories,mk/spec/hw.mk) include $(call select_from_repositories,mk/spec/x86_64.mk) diff --git a/repos/base-hw/mk/spec/hw_zynq.mk b/repos/base-hw/mk/spec/hw_zynq.mk index 3afeb66d9..7dfc8c205 100644 --- a/repos/base-hw/mk/spec/hw_zynq.mk +++ b/repos/base-hw/mk/spec/hw_zynq.mk @@ -10,8 +10,5 @@ SPECS += hw # configure multiprocessor mode NR_OF_CPUS = 1 -# set address where to link the text segment at -LD_TEXT_ADDR ?= 0x00100000 - # include implied specs include $(call select_from_repositories,mk/spec/hw.mk) diff --git a/repos/base-hw/src/core/boot_modules.s b/repos/base-hw/src/core/boot_modules.s deleted file mode 100644 index 53882f41e..000000000 --- a/repos/base-hw/src/core/boot_modules.s +++ /dev/null @@ -1,32 +0,0 @@ -/* - * \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/src/core/include/multiboot.h b/repos/base-hw/src/core/include/spec/x86_64/multiboot.h similarity index 64% rename from repos/base/src/core/include/multiboot.h rename to repos/base-hw/src/core/include/spec/x86_64/multiboot.h index 4afd94ede..adc8f9d1b 100644 --- a/repos/base/src/core/include/multiboot.h +++ b/repos/base-hw/src/core/include/spec/x86_64/multiboot.h @@ -12,15 +12,12 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _CORE__INCLUDE__MULTIBOOT_H_ -#define _CORE__INCLUDE__MULTIBOOT_H_ +#ifndef _MULTIBOOT_H_ +#define _MULTIBOOT_H_ /* base includes */ #include -/* core includes */ -#include - namespace Genode { class Multiboot_info; } class Genode::Multiboot_info : Mmio @@ -30,8 +27,6 @@ class Genode::Multiboot_info : Mmio struct Flags : Register<0x00, 32> { struct Mem_map : Bitfield<6, 1> { }; }; - struct Mods_count : Register<0x14, 32> { }; - struct Mods_addr : Register<0x18, 32> { }; struct Mmap_length: Register<0x2c, 32> { }; struct Mmap_addr : Register<0x30, 32> { }; @@ -50,41 +45,6 @@ class Genode::Multiboot_info : Mmio Mmap(addr_t mmap = 0) : Mmio(mmap) { } }; - struct Mods : Genode::Mmio { - struct Start : Register <0x00, 32> { }; - struct End : Register <0x04, 32> { }; - struct Cmdline : Register <0x08, 32> { }; - struct Padding : Register <0x0c, 32> { }; - - Mods(addr_t mods) : Mmio(mods) { } - }; - - private: - - Mods _get_mod(unsigned i) { - Genode::addr_t mods_addr = read(); - - enum { MODS_SIZE_OF = 16 }; - return Mods(mods_addr + i * MODS_SIZE_OF); - } - - public: - - /** - * Number of boot modules - */ - unsigned num_modules(); - - /* Accessors */ - size_t size() const { return 0x1000; } - - /** - * Use boot module num - * - * The module is marked as invalid in MBI and cannot be gotten again - */ - Rom_module get_module(unsigned num); - /** * Physical ram regions */ @@ -121,4 +81,4 @@ class Genode::Multiboot_info : Mmio } }; -#endif /* _CORE__INCLUDE__MULTIBOOT_H_ */ +#endif /* _MULTIBOOT_H_ */ diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc index 263d5a4ed..56c0d44cc 100644 --- a/repos/base-hw/src/core/platform.cc +++ b/repos/base-hw/src/core/platform.cc @@ -16,6 +16,7 @@ #include /* core includes */ +#include #include #include #include @@ -37,22 +38,6 @@ extern int _prog_img_end; void __attribute__((weak)) Kernel::init_trustzone(Pic & pic) { } -/** - * Format of a boot-module header - */ -struct Bm_header -{ - long name; /* physical address of null-terminated string */ - long base; /* physical address of module data */ - long size; /* size of module data in bytes */ -}; - -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; - - /** * Helper to initialise allocators through include/exclude region lists */ @@ -152,7 +137,7 @@ Platform::Platform() _init_io_mem_alloc(); /* add boot modules to ROM FS */ - Bm_header * header = &_boot_modules_headers_begin; + 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, header->size, (const char*)header->name); diff --git a/repos/base-hw/src/core/target.mk b/repos/base-hw/src/core/target.mk deleted file mode 100644 index e05563282..000000000 --- a/repos/base-hw/src/core/target.mk +++ /dev/null @@ -1,30 +0,0 @@ -# -# \brief Build config for Genodes core process -# \author Martin Stein -# \author Sebastian Sumpf -# \date 2011-12-16 -# - -# set target name that this configuration applies to -TARGET = core - -# library that provides the whole configuration -LIBS += core - -# -# On RISCV we need a link address for core that differs from that of the other -# components. -# -ifneq ($(filter riscv, $(SPECS)),) -LD_TEXT_ADDR = $(CORE_LD_TEXT_ADDR) -endif - -# -# We do not have additional source files than the core library -# so we need to define a dummy compilation unit, -# otherwise our build-system won't link -# -SRC_C += dummy.cc - -dummy.cc: - $(VERBOSE)touch $@ diff --git a/repos/base-linux/mk/spec/linux.mk b/repos/base-linux/mk/spec/linux.mk index 96bd24e04..d920aab7a 100644 --- a/repos/base-linux/mk/spec/linux.mk +++ b/repos/base-linux/mk/spec/linux.mk @@ -12,6 +12,7 @@ LD_TEXT_ADDR ?= 0x01000000 LD_SCRIPT_STATIC = $(call select_from_repositories,src/ld/genode.ld) \ $(call select_from_repositories,src/ld/stack_area.nostdlib.ld) else +LD_TEXT_ADDR ?= LD_SCRIPT_STATIC ?= endif diff --git a/repos/base-nova/lib/mk/core.inc b/repos/base-nova/lib/mk/core.inc index 1067180d5..5e6509046 100644 --- a/repos/base-nova/lib/mk/core.inc +++ b/repos/base-nova/lib/mk/core.inc @@ -1,6 +1,72 @@ -SRC_CC += pager.cc +LIBS = base-common -INC_DIR = $(REP_DIR)/src/core/include \ - $(BASE_DIR)/src/core/include \ - $(REP_DIR)/src/include \ - $(BASE_DIR)/src/include +GEN_CORE_DIR = $(BASE_DIR)/src/core + +SRC_CC += stack_area.cc \ + core_mem_alloc.cc \ + core_log.cc \ + core_region_map.cc \ + core_rpc_cap_alloc.cc \ + cpu_session_component.cc \ + cpu_session_support.cc \ + cpu_thread_component.cc \ + dataspace_component.cc \ + default_log.cc \ + dump_alloc.cc \ + echo.cc \ + io_mem_session_component.cc \ + io_mem_session_support.cc \ + io_port_session_component.cc \ + io_port_session_support.cc \ + ipc_pager.cc \ + irq_session_component.cc \ + main.cc \ + pager.cc \ + pd_session_component.cc \ + native_pd_component.cc \ + native_cpu_component.cc \ + pd_upgrade_ram_quota.cc \ + pd_assign_pci.cc \ + rpc_cap_factory.cc \ + platform.cc \ + platform_pd.cc \ + platform_services.cc \ + platform_thread.cc \ + ram_session_component.cc \ + ram_session_support.cc \ + region_map_component.cc \ + region_map_support.cc \ + rom_session_component.cc \ + thread_start.cc \ + bios_data_area.cc \ + trace_session_component.cc + +INC_DIR = $(REP_DIR)/src/core/include \ + $(REP_DIR)/src/include \ + $(BASE_DIR)/src/include \ + $(GEN_CORE_DIR)/include + +include $(GEN_CORE_DIR)/version.inc + +vpath main.cc $(GEN_CORE_DIR) +vpath ram_session_component.cc $(GEN_CORE_DIR) +vpath rom_session_component.cc $(GEN_CORE_DIR) +vpath cpu_session_component.cc $(GEN_CORE_DIR) +vpath cpu_session_support.cc $(GEN_CORE_DIR) +vpath cpu_thread_component.cc $(GEN_CORE_DIR) +vpath pd_session_component.cc $(GEN_CORE_DIR) +vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR) +vpath region_map_component.cc $(GEN_CORE_DIR) +vpath trace_session_component.cc $(GEN_CORE_DIR) +vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86 +vpath io_port_session_support.cc $(GEN_CORE_DIR)/spec/x86 +vpath io_mem_session_component.cc $(GEN_CORE_DIR) +vpath io_mem_session_support.cc $(GEN_CORE_DIR) +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_services.cc $(GEN_CORE_DIR)/spec/x86 +vpath stack_area.cc $(GEN_CORE_DIR) +vpath core_printf.cc $(BASE_DIR)/src/lib/base +vpath %.cc $(REP_DIR)/src/core diff --git a/repos/base-nova/lib/mk/spec/x86_32/core.mk b/repos/base-nova/lib/mk/spec/x86_32/core.mk index 2f6dfad37..123786d51 100644 --- a/repos/base-nova/lib/mk/spec/x86_32/core.mk +++ b/repos/base-nova/lib/mk/spec/x86_32/core.mk @@ -1,3 +1,3 @@ -include $(REP_DIR)/lib/mk/core.inc +SRC_CC += spec/x86_32/pager.cc -vpath %.cc $(REP_DIR)/src/core/spec/x86_32 +include $(REP_DIR)/lib/mk/core.inc diff --git a/repos/base-nova/lib/mk/spec/x86_64/core.mk b/repos/base-nova/lib/mk/spec/x86_64/core.mk index b51370fb7..9943890cd 100644 --- a/repos/base-nova/lib/mk/spec/x86_64/core.mk +++ b/repos/base-nova/lib/mk/spec/x86_64/core.mk @@ -1,3 +1,3 @@ -include $(REP_DIR)/lib/mk/core.inc +SRC_CC += spec/x86_64/pager.cc -vpath %.cc $(REP_DIR)/src/core/spec/x86_64 +include $(REP_DIR)/lib/mk/core.inc diff --git a/repos/base-nova/mk/spec/nova.mk b/repos/base-nova/mk/spec/nova.mk index ff778d9c5..c8547a420 100644 --- a/repos/base-nova/mk/spec/nova.mk +++ b/repos/base-nova/mk/spec/nova.mk @@ -5,11 +5,6 @@ SPECS += nova SPECS += pci ps2 vesa framebuffer -# -# Linker options that are specific for x86 -# -LD_TEXT_ADDR ?= 0x01000000 - # # We would normally have to do this only in the kernel lib. We do it in # general nonetheless to ensure that the kernel port, if missing, is added to diff --git a/repos/base-nova/src/core/core-bss.ld b/repos/base-nova/src/core/core-bss.ld new file mode 100644 index 000000000..994c3a21a --- /dev/null +++ b/repos/base-nova/src/core/core-bss.ld @@ -0,0 +1,6 @@ +SECTIONS +{ + .data : { + *(.bss .bss.* .gnu.linkonce.b.* COMMON) + } : rw +} diff --git a/repos/base-nova/src/core/core.ld b/repos/base-nova/src/core/core.ld deleted file mode 100644 index 480780518..000000000 --- a/repos/base-nova/src/core/core.ld +++ /dev/null @@ -1,105 +0,0 @@ -/* - * \brief Linker script for Genode programs - * \author Christian Helmuth - * \date 2006-04-12 - */ - -/* - * Copyright (C) 2006-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. - */ - -/* - * NOVA-specific change: NOVA does not support the BSS segment for - * roottask. Therefore, we have to place all BSS content into the - * data section. - */ - -ENTRY(_start) - -PHDRS -{ - ro PT_LOAD; - rw PT_LOAD; -} - -SECTIONS -{ - .text : { - /* begin of program image (link address) */ - _prog_img_beg = .; - - /* put entry code at the start of the text segment / raw binary */ - *(.text.crt0) - - *(.init) - *(.text .text.* .gnu.linkonce.t.*) - *(.fini) - *(.rodata .rodata.* .gnu.linkonce.r.*) - - . = ALIGN(0x08); - - _ctors_start = .; - KEEP (*(.ctors)) - KEEP (*(SORT(.ctors.*))) - _ctors_end = .; - _dtors_start = .; - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - _dtors_end = .; - } : ro = 0x0 - - /* Linux: exception section for uaccess mechanism */ - __ex_table : { *(__ex_table) } - - .eh_frame_hdr : { *(.eh_frame_hdr) } - - . = ALIGN(0x1000); - - .data : { - /* - * Leave space for parent capability parameters at start of data - * section. The protection domain creator is reponsible for storing - * sane values here. - */ - _parent_cap = .; - _parent_cap_thread_id = .; - LONG(0xffffffff); - _parent_cap_local_name = .; - LONG(0xffffffff); - - *(.data .data.* .gnu.linkonce.d.*) - *(.bss .bss.* .gnu.linkonce.b.* COMMON) - } : rw - - /* exception frames for C++ */ - .eh_frame : { - __eh_frame_start__ = .; - KEEP (*(.eh_frame)) - LONG(0) - } : rw - - .init_array : { - __init_array_start = .; - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array)) - __init_array_end = .; - } - - .gcc_except_table : { - KEEP(*(.gcc_except_table)) - KEEP(*(.gcc_except_table.*)) - } - .dynamic : { *(.dynamic) } - - /* end of program image -- must be after last section */ - _prog_img_end = .; - - /DISCARD/ : { - *(.note) - *(.note.ABI-tag) - *(.comment) - } -} diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc index 1060a6d0f..f94e5921b 100644 --- a/repos/base-nova/src/core/platform.cc +++ b/repos/base-nova/src/core/platform.cc @@ -20,6 +20,7 @@ #include /* core includes */ +#include #include #include #include @@ -257,7 +258,13 @@ static void init_core_page_fault_handler() static bool cpuid_invariant_tsc() { unsigned long cpuid = 0x80000007, edx = 0; - asm volatile ("cpuid" : "+a" (cpuid), "=d" (edx) : : "ebx", "ecx"); +#ifdef __x86_64__ + asm volatile ("cpuid" : "+a" (cpuid), "=d" (edx) : : "rbx", "rcx"); +#else + asm volatile ("push %%ebx \n" + "cpuid \n" + "pop %%ebx" : "+a" (cpuid), "=d" (edx) : : "ecx"); +#endif return edx & 0x100; } @@ -397,11 +404,28 @@ Platform::Platform() : _core_mem_alloc.virt_alloc()->add_range(virt_beg, virt_end - virt_beg); /* exclude core image from core's virtual address allocator */ - addr_t core_virt_beg = trunc_page((addr_t)&_prog_img_beg); - addr_t core_virt_end = round_page((addr_t)&_prog_img_end); - size_t core_size = core_virt_end - core_virt_beg; + addr_t const core_virt_beg = trunc_page((addr_t)&_prog_img_beg); + addr_t const core_virt_end = round_page((addr_t)&_prog_img_end); + addr_t const binaries_beg = trunc_page((addr_t)&_boot_modules_binaries_begin); + addr_t const binaries_end = round_page((addr_t)&_boot_modules_binaries_end); + + size_t const core_size = binaries_beg - core_virt_beg; region_alloc()->remove_range(core_virt_beg, core_size); + if (verbose_boot_info || binaries_end != core_virt_end) { + log("core image ", + Hex_range(core_virt_beg, core_virt_end - core_virt_beg)); + log("binaries region ", + Hex_range(binaries_beg, binaries_end - binaries_beg), + " free for reuse"); + } + if (binaries_end != core_virt_end) + nova_die(); + + /* ROM modules are un-used by core - de-detach region */ + addr_t const binaries_size = binaries_end - binaries_beg; + unmap_local(__main_thread_utcb, binaries_beg, binaries_size >> 12); + /* preserve Bios Data Area (BDA) in core's virtual address space */ region_alloc()->remove_range(BDA_VIRT_ADDR, 0x1000); @@ -558,114 +582,24 @@ Platform::Platform() : * From now on, it is save to use the core allocators... */ - /* - * Allocate ever an extra page behind the command line pointer. If it turns - * out that this page is unused, because the command line was short enough, - * the mapping is revoked and the virtual and physical regions are put back - * to the allocator. - */ - mem_desc = (Hip::Mem_desc *)mem_desc_base; - prev_cmd_line_page = ~0UL, curr_cmd_line_page = 0; - addr_t mapped_cmd_line = 0; - addr_t aux = ~0UL; - size_t aux_len = 0; /* 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::MULTIBOOT_MODULE) continue; if (!mem_desc->addr || !mem_desc->size || !mem_desc->aux) continue; - /* convenience */ - addr_t const rom_mem_start = trunc_page(mem_desc->addr); - addr_t const rom_mem_end = round_page(mem_desc->addr + mem_desc->size); - addr_t const rom_mem_size = rom_mem_end - rom_mem_start; - bool const aux_in_rom_area = (rom_mem_start <= mem_desc->aux) && - (mem_desc->aux < rom_mem_end); - addr_t const pages_mapped = (rom_mem_size >> get_page_size_log2()) + - (aux_in_rom_area ? 1 : 0); + /* 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; - /* map ROM + extra page for the case aux crosses page boundary */ - addr_t core_local_addr = _map_pages(rom_mem_start >> get_page_size_log2(), - pages_mapped); - if (!core_local_addr) { - error("could not map multi boot module"); - nova_die(); + /* 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); } - - /* adjust core_local_addr of module if it was not page aligned */ - core_local_addr += mem_desc->addr - rom_mem_start; - - char *name = nullptr; - if (aux_in_rom_area) { - aux = core_local_addr + (mem_desc->aux - mem_desc->addr); - aux_len = strlen(reinterpret_cast(aux)) + 1; - - /* all behind rom module will be cleared, copy the command line */ - char *name_tmp = commandline_to_basename(reinterpret_cast(aux)); - unsigned name_tmp_size = aux_len - (name_tmp - reinterpret_cast(aux)); - name = new (core_mem_alloc()) char [name_tmp_size]; - memcpy(name, name_tmp, name_tmp_size); - - } else { - - curr_cmd_line_page = mem_desc->aux >> get_page_size_log2(); - if (curr_cmd_line_page != prev_cmd_line_page) { - int err = 1; - if (curr_cmd_line_page == prev_cmd_line_page + 1) { - /* try to allocate subsequent virtual region */ - addr_t const virt = mapped_cmd_line + get_page_size() * 2; - addr_t const phys = round_page(mem_desc->aux); - - if (region_alloc()->alloc_addr(get_page_size(), virt).ok()) { - /* we got the virtual region */ - err = map_local(__main_thread_utcb, phys, virt, 1, - Nova::Rights(true, false, false), true); - if (!err) { - /* we got the mapping */ - mapped_cmd_line += get_page_size(); - prev_cmd_line_page += 1; - } - } - } - - /* allocate new pages if it was not successful beforehand */ - if (err) { - mapped_cmd_line = _map_pages(curr_cmd_line_page, 2); - prev_cmd_line_page = curr_cmd_line_page; - - if (!mapped_cmd_line) { - error("could not map command line"); - nova_die(); - } - } - } - aux = mapped_cmd_line + (mem_desc->aux - trunc_page(mem_desc->aux)); - aux_len = strlen(reinterpret_cast(aux)) + 1; - name = commandline_to_basename(reinterpret_cast(aux)); - - } - - /* set zero out range */ - addr_t const zero_out = core_local_addr + mem_desc->size; - /* zero out behind rom module */ - memset(reinterpret_cast(zero_out), 0, round_page(zero_out) - - zero_out); - - if (verbose_boot_info) - log("map multi-boot module: physical ", - Hex((addr_t)mem_desc->addr, Hex::PREFIX, Hex::PAD), "+", - Hex((size_t)mem_desc->size, Hex::PREFIX, Hex::PAD), " - ", - Cstring(name)); - - /* revoke mapping of rom module - not needed */ - unmap_local(__main_thread_utcb, trunc_page(core_local_addr), - pages_mapped); - region_alloc()->free(reinterpret_cast(trunc_page(core_local_addr)), - pages_mapped << get_page_size_log2()); - - /* create rom module */ - Rom_module *rom_module = new (core_mem_alloc()) - Rom_module(rom_mem_start, mem_desc->size, name); - _rom_fs.insert(rom_module); } /* export hypervisor info page as ROM module */ @@ -697,6 +631,7 @@ Platform::Platform() : log(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); log(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); log(":io_mem_alloc: "); _io_mem_alloc()->dump_addr_tree(); + log(":rom_fs: "); _rom_fs.print_fs(); } /* add capability selector ranges to map */ diff --git a/repos/base-nova/src/core/target.inc b/repos/base-nova/src/core/target.inc deleted file mode 100644 index f78f3c2ca..000000000 --- a/repos/base-nova/src/core/target.inc +++ /dev/null @@ -1,72 +0,0 @@ -TARGET = core -LIBS = base-common core - -GEN_CORE_DIR = $(BASE_DIR)/src/core - -SRC_CC = stack_area.cc \ - core_mem_alloc.cc \ - core_log.cc \ - core_region_map.cc \ - core_rpc_cap_alloc.cc \ - cpu_session_component.cc \ - cpu_session_support.cc \ - cpu_thread_component.cc \ - dataspace_component.cc \ - default_log.cc \ - dump_alloc.cc \ - echo.cc \ - io_mem_session_component.cc \ - io_mem_session_support.cc \ - io_port_session_component.cc \ - io_port_session_support.cc \ - ipc_pager.cc \ - irq_session_component.cc \ - main.cc \ - pager.cc \ - pd_session_component.cc \ - native_pd_component.cc \ - native_cpu_component.cc \ - pd_upgrade_ram_quota.cc \ - pd_assign_pci.cc \ - rpc_cap_factory.cc \ - platform.cc \ - platform_pd.cc \ - platform_services.cc \ - platform_thread.cc \ - ram_session_component.cc \ - ram_session_support.cc \ - region_map_component.cc \ - region_map_support.cc \ - rom_session_component.cc \ - thread_start.cc \ - bios_data_area.cc \ - trace_session_component.cc - -INC_DIR = $(REP_DIR)/src/core/include \ - $(REP_DIR)/src/include \ - $(BASE_DIR)/src/include \ - $(GEN_CORE_DIR)/include - -include $(GEN_CORE_DIR)/version.inc - -vpath main.cc $(GEN_CORE_DIR) -vpath ram_session_component.cc $(GEN_CORE_DIR) -vpath rom_session_component.cc $(GEN_CORE_DIR) -vpath cpu_session_component.cc $(GEN_CORE_DIR) -vpath cpu_session_support.cc $(GEN_CORE_DIR) -vpath cpu_thread_component.cc $(GEN_CORE_DIR) -vpath pd_session_component.cc $(GEN_CORE_DIR) -vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR) -vpath region_map_component.cc $(GEN_CORE_DIR) -vpath trace_session_component.cc $(GEN_CORE_DIR) -vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86 -vpath io_port_session_support.cc $(GEN_CORE_DIR)/spec/x86 -vpath io_mem_session_component.cc $(GEN_CORE_DIR) -vpath io_mem_session_support.cc $(GEN_CORE_DIR) -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_services.cc $(GEN_CORE_DIR)/spec/x86 -vpath stack_area.cc $(GEN_CORE_DIR) -vpath %.cc $(REP_DIR)/src/core diff --git a/repos/base-nova/src/core/target.mk b/repos/base-nova/src/core/target.mk deleted file mode 100644 index 6b55ce983..000000000 --- a/repos/base-nova/src/core/target.mk +++ /dev/null @@ -1,4 +0,0 @@ -include $(PRG_DIR)/target.inc - -LD_SCRIPT_STATIC = $(REP_DIR)/src/core/core.ld -LD_TEXT_ADDR = 0x100000 diff --git a/repos/base-okl4/src/core/target.inc b/repos/base-okl4/lib/mk/core.inc similarity index 99% rename from repos/base-okl4/src/core/target.inc rename to repos/base-okl4/lib/mk/core.inc index 0309e9143..58c3b2c2a 100644 --- a/repos/base-okl4/src/core/target.inc +++ b/repos/base-okl4/lib/mk/core.inc @@ -1,4 +1,4 @@ -TARGET = core +CC_OPT_PIC = LIBS += boot_info base-common diff --git a/repos/base-okl4/src/core/spec/x86/target.mk b/repos/base-okl4/lib/mk/spec/x86/core.mk similarity index 80% rename from repos/base-okl4/src/core/spec/x86/target.mk rename to repos/base-okl4/lib/mk/spec/x86/core.mk index c55a85cf1..340df644c 100644 --- a/repos/base-okl4/src/core/spec/x86/target.mk +++ b/repos/base-okl4/lib/mk/spec/x86/core.mk @@ -1,4 +1,4 @@ -include $(REP_DIR)/src/core/target.inc +include $(REP_DIR)/lib/mk/core.inc REQUIRES += x86 @@ -9,6 +9,6 @@ SRC_CC += io_port_session_component.cc \ vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86 vpath io_port_session_support.cc $(GEN_CORE_DIR)/spec/x86 vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86 -vpath platform_thread_x86.cc $(GEN_CORE_DIR)/spec/x86 +vpath platform_thread_x86.cc $(REP_DIR)/src/core/spec/x86 vpath crt0.s $(dir $(call select_from_repositories,src/lib/startup/spec/x86_32/crt0.s)) diff --git a/repos/base-okl4/mk/spec/okl4_x86.mk b/repos/base-okl4/mk/spec/okl4_x86.mk index 18771aa51..86eac58aa 100644 --- a/repos/base-okl4/mk/spec/okl4_x86.mk +++ b/repos/base-okl4/mk/spec/okl4_x86.mk @@ -5,11 +5,6 @@ SPECS += x86_32 okl4 SPECS += pci ps2 vesa framebuffer -# -# Linker options specific for x86 -# -LD_TEXT_ADDR ?= 0x00200000 - # # Also include less-specific configuration last # diff --git a/repos/base-okl4/src/core/include/platform.h b/repos/base-okl4/src/core/include/platform.h index c35be27bf..da18c7fda 100644 --- a/repos/base-okl4/src/core/include/platform.h +++ b/repos/base-okl4/src/core/include/platform.h @@ -61,6 +61,8 @@ namespace Genode { */ addr_t _utcb_base; + void _setup_rom(); + public: /** @@ -99,18 +101,6 @@ namespace Genode { Okl4::uintptr_t, Okl4::uintptr_t, const Okl4::bi_user_data_t *); - static int bi_export_object(Okl4::bi_name_t, Okl4::bi_name_t, - Okl4::bi_export_type_t, char *, - Okl4::size_t, - const Okl4::bi_user_data_t *); - - static Okl4::bi_name_t bi_new_ms(Okl4::bi_name_t, - Okl4::uintptr_t, Okl4::uintptr_t, - Okl4::uintptr_t, Okl4::uintptr_t, - Okl4::bi_name_t, Okl4::bi_name_t, - Okl4::bi_name_t, - const Okl4::bi_user_data_t *); - /******************************** ** Generic platform interface ** ********************************/ diff --git a/repos/base-okl4/src/core/platform.cc b/repos/base-okl4/src/core/platform.cc index 92c823ecf..2816e3f87 100644 --- a/repos/base-okl4/src/core/platform.cc +++ b/repos/base-okl4/src/core/platform.cc @@ -24,6 +24,7 @@ #include /* core includes */ +#include #include #include #include @@ -39,19 +40,6 @@ namespace Okl4 { using namespace Genode; -enum { MAX_BOOT_MODULES = 64 }; -enum { MAX_BOOT_MODULE_NAME_LEN = 32 }; -static struct -{ - char name[MAX_BOOT_MODULE_NAME_LEN]; - addr_t base; - size_t size; -} boot_modules[MAX_BOOT_MODULES]; - -static int num_boot_module_memsects; -static int num_boot_module_objects; - - /**************************************** ** Support for core memory management ** ****************************************/ @@ -105,68 +93,15 @@ int Platform::bi_add_phys_mem(Okl4::bi_name_t pool, Okl4::uintptr_t base, } -int Platform::bi_export_object(Okl4::bi_name_t pd, Okl4::bi_name_t obj, - Okl4::bi_export_type_t export_type, char *key, - Okl4::size_t key_len, const Okl4::bi_user_data_t * data) +void Platform::_setup_rom() { - /* - * We walk the boot info only once and collect all memory section - * objects. Each time we detect a memory section outside of roottask - * (PD 0), we increment the boot module index. - */ - - /* reset module index (roottask objects appear before other pd's objects) */ - if (pd == 0) num_boot_module_objects = 0; - - if (export_type != Okl4::BI_EXPORT_MEMSECTION_CAP) - return 0; - - if (num_boot_module_objects >= MAX_BOOT_MODULES) { - error("maximum number of boot modules exceeded"); - return -1; + /* 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); } - - /* copy name from object key */ - key_len = min((int)key_len, MAX_BOOT_MODULE_NAME_LEN - 1); - for (unsigned i = 0; i < key_len; i++) { - - /* convert letter to lower-case */ - char c = key[i]; - if (c >= 'A' && c <= 'Z') - c -= 'A' - 'a'; - - boot_modules[num_boot_module_objects].name[i] = c; - } - /* null-terminate string */ - boot_modules[num_boot_module_objects].name[key_len] = 0; - - num_boot_module_objects++; - return 0; -} - - -Okl4::bi_name_t Platform::bi_new_ms(Okl4::bi_name_t owner, - Okl4::uintptr_t base, Okl4::uintptr_t size, - Okl4::uintptr_t flags, Okl4::uintptr_t attr, - Okl4::bi_name_t physpool, Okl4::bi_name_t virtpool, - Okl4::bi_name_t zone, const Okl4::bi_user_data_t *data) -{ - /* reset module index (see comment in 'bi_export_object') */ - if (owner == 0) num_boot_module_memsects = 0; - - /* ignore memory pools other than pool 3 (this is just a heuristic) */ - if (virtpool != 3) return 0; - - if (num_boot_module_memsects >= MAX_BOOT_MODULES) { - error("maximum number of boot modules exceeded"); - return -1; - } - - boot_modules[num_boot_module_memsects].base = base; - boot_modules[num_boot_module_memsects].size = size; - - num_boot_module_memsects++; - return 0; } @@ -227,21 +162,9 @@ Platform::Platform() : callbacks.init_mem = Platform::bi_init_mem; callbacks.add_virt_mem = Platform::bi_add_virt_mem; callbacks.add_phys_mem = Platform::bi_add_phys_mem; - callbacks.export_object = Platform::bi_export_object; - callbacks.new_ms = Platform::bi_new_ms; Okl4::bootinfo_parse((void *)boot_info_addr, &callbacks, this); - /* make gathered boot-module info known to '_rom_fs' */ - int num_boot_modules = min(num_boot_module_objects, num_boot_module_memsects); - for (int i = 0; i < num_boot_modules; i++) { - Rom_module *r = new (&_rom_slab) - Rom_module(boot_modules[i].base, - boot_modules[i].size, - boot_modules[i].name); - _rom_fs.insert(r); - } - /* initialize interrupt allocator */ _irq_alloc.add_range(0, 0x10); @@ -251,6 +174,8 @@ Platform::Platform() : /* I/O port allocator (only meaningful for x86) */ _io_port_alloc.add_range(0, 0x10000); + _setup_rom(); + /* preserve stack area in core's virtual address space */ _core_mem_alloc.virt_alloc()->remove_range(stack_area_virtual_base(), stack_area_virtual_size()); diff --git a/repos/base-pistachio/src/core/target.inc b/repos/base-pistachio/lib/mk/core.inc similarity index 98% rename from repos/base-pistachio/src/core/target.inc rename to repos/base-pistachio/lib/mk/core.inc index ed4ddb64b..1a498bc37 100644 --- a/repos/base-pistachio/src/core/target.inc +++ b/repos/base-pistachio/lib/mk/core.inc @@ -1,4 +1,3 @@ -TARGET = core REQUIRES = pistachio LIBS = base-common @@ -20,7 +19,6 @@ SRC_CC = stack_area.cc \ irq_session_component.cc \ kip.cc \ main.cc \ - multiboot_info.cc \ pd_session_component.cc \ rpc_cap_factory_l4.cc \ pd_assign_pci.cc \ diff --git a/repos/base-pistachio/src/core/spec/x86/target.mk b/repos/base-pistachio/lib/mk/spec/x86/core.mk similarity index 75% rename from repos/base-pistachio/src/core/spec/x86/target.mk rename to repos/base-pistachio/lib/mk/spec/x86/core.mk index 6ce49cfa9..6cb90885b 100644 --- a/repos/base-pistachio/src/core/spec/x86/target.mk +++ b/repos/base-pistachio/lib/mk/spec/x86/core.mk @@ -1,4 +1,4 @@ -include $(REP_DIR)/src/core/target.inc +include $(REP_DIR)/lib/mk/core.inc REQUIRES += x86 SRC_CC += io_port_session_component.cc \ @@ -8,4 +8,4 @@ SRC_CC += io_port_session_component.cc \ vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86 vpath io_port_session_support.cc $(GEN_CORE_DIR)/spec/x86 vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86 - +vpath platform_x86.cc $(REP_DIR)/src/core/spec/x86 diff --git a/repos/base-pistachio/mk/spec/pistachio_x86.mk b/repos/base-pistachio/mk/spec/pistachio_x86.mk index aa19f464f..2b84547a3 100644 --- a/repos/base-pistachio/mk/spec/pistachio_x86.mk +++ b/repos/base-pistachio/mk/spec/pistachio_x86.mk @@ -5,10 +5,5 @@ SPECS += x86_32 pistachio SPECS += pci ps2 vesa framebuffer -# -# Linker options that are specific for x86 -# -LD_TEXT_ADDR ?= 0x00300000 - include $(call select_from_repositories,mk/spec/x86_32.mk) include $(call select_from_repositories,mk/spec/pistachio.mk) diff --git a/repos/base-pistachio/src/core/include/map_local.h b/repos/base-pistachio/src/core/include/map_local.h index 326e15528..ff90edab8 100644 --- a/repos/base-pistachio/src/core/include/map_local.h +++ b/repos/base-pistachio/src/core/include/map_local.h @@ -14,6 +14,8 @@ #ifndef _CORE__INCLUDE__MAP_LOCAL_H_ #define _CORE__INCLUDE__MAP_LOCAL_H_ +#include + /* core includes */ #include #include diff --git a/repos/base-pistachio/src/core/include/platform.h b/repos/base-pistachio/src/core/include/platform.h index 71e8ad2c4..33747a146 100644 --- a/repos/base-pistachio/src/core/include/platform.h +++ b/repos/base-pistachio/src/core/include/platform.h @@ -21,7 +21,6 @@ #include "platform_generic.h" #include "platform_thread.h" #include "platform_pd.h" -#include "multiboot.h" namespace Genode { @@ -40,7 +39,6 @@ namespace Genode { Phys_allocator _io_port_alloc; /* I/O port allocator */ Phys_allocator _irq_alloc; /* IRQ allocator */ Phys_allocator _region_alloc; /* virtual memory allocator for core */ - Multiboot_info _mb_info; /* multiboot information */ Rom_fs _rom_fs; /* ROM file system */ Rom_module _kip_rom; /* ROM module for Fiasco KIP */ @@ -57,7 +55,6 @@ namespace Genode { * * - Map and provide KIP as ROM module * - Initializes region allocator - * - Initializes multiboot info structure */ void _setup_basics(); diff --git a/repos/base-pistachio/src/core/multiboot_info.cc b/repos/base-pistachio/src/core/multiboot_info.cc deleted file mode 100644 index b95d9dd6d..000000000 --- a/repos/base-pistachio/src/core/multiboot_info.cc +++ /dev/null @@ -1,112 +0,0 @@ -/* - * \brief GRUB multi-boot information handling - * \author Christian Helmuth - * \date 2006-05-10 - */ - -/* - * Copyright (C) 2006-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. - */ - -/* Genode includes */ -#include -#include -#include - -/* core includes */ -#include -#include - -/* Pistachio includes */ -namespace Pistachio { -#include -#include -} - -using namespace Genode; - - -static const bool verbose = false; - - -#define VPRINTF(fmt...) if (verbose) printf(fmt); else {} - - -unsigned Multiboot_info::num_modules() -{ - using namespace Pistachio; - - unsigned int i = 0; - L4_Word_t entries; - L4_BootRec_t *rec; - for (entries = L4_BootInfo_Entries(reinterpret_cast(Mmio::base)), - rec = L4_BootInfo_FirstEntry(reinterpret_cast(Mmio::base)); - entries > 0; - entries--, rec = L4_Next(rec)) - { - if (L4_Type(rec) == L4_BootInfo_Module) - i++; - } - - /* return count of modules */ - return i; -} - - -Rom_module Multiboot_info::get_module(unsigned num) -{ - using namespace Pistachio; - - /* find the right record */ - bool found = false; - unsigned int i = 0; - L4_Word_t entries; - L4_BootRec_t *rec; - for (entries = L4_BootInfo_Entries(reinterpret_cast(Mmio::base)), - rec = L4_BootInfo_FirstEntry(reinterpret_cast(Mmio::base)); - entries > 0; - entries--, rec = L4_Next(rec)) - { - if ((L4_Type(rec) == L4_BootInfo_Module) && - (i++ == num)) { - found = true; - break; - } - } - - if (!found) - panic("No such rom module"); - - /* strip path info and command line */ - char *name = L4_Module_Cmdline(rec); - for (char *c = name; *c != 0; c++) { - if (*c == '/') name = c + 1; - if (*c == ' ') { - *c = 0; - break; - } - } - - /* request the memory from sigma0 and create the rom_module object */ - L4_Word_t start = L4_Module_Start(rec); - L4_Word_t size = L4_Module_Size(rec); - - if (start != trunc_page(start)) - panic("Module is not aligned to page boundary."); - - L4_ThreadId_t s0 = get_sigma0(); - addr_t ps = get_page_size(); - for (addr_t cur = start; cur < start + size; cur += ps) { - L4_Fpage_t fp = L4_Sigma0_GetPage(s0, L4_Fpage(cur, ps)); - - if (L4_IsNilFpage(fp) || - L4_Address(fp) != cur) - panic("Unable to map module data."); - } - - Rom_module ret = Rom_module(start, size, name); - return ret; -} diff --git a/repos/base-pistachio/src/core/platform.cc b/repos/base-pistachio/src/core/platform.cc index 2afd14b0d..604c94250 100644 --- a/repos/base-pistachio/src/core/platform.cc +++ b/repos/base-pistachio/src/core/platform.cc @@ -25,6 +25,7 @@ #include /* core includes */ +#include #include #include #include @@ -46,8 +47,8 @@ namespace Pistachio { using namespace Genode; -static const bool verbose = false; -static const bool verbose_core_pf = false; +static const bool verbose = true; +static const bool verbose_core_pf = true; static const bool verbose_region_alloc = false; @@ -508,9 +509,6 @@ void Platform::_setup_basics() _kip_rom = Rom_module((addr_t)kip, sizeof(L4_KernelInterfacePage_t), "pistachio_kip"); _rom_fs.insert(&_kip_rom); - /* update multi-boot info pointer from KIP */ - void *mb_info_ptr = (void *)kip->BootInfo; - // Get virtual bootinfo address. L4_Fpage_t bipage = L4_Sigma0_GetPage(get_sigma0(), @@ -519,16 +517,8 @@ void Platform::_setup_basics() if (L4_IsNilFpage(bipage)) panic("Could not map BootInfo."); - if (!L4_BootInfo_Valid(mb_info_ptr)) - panic("No valid boot info."); - - if (L4_BootInfo_Size(mb_info_ptr) > get_page_size()) - panic("TODO Our multiboot info is bigger than a page..."); - /* done magic */ - if (verbose) log("MBI @ ", mb_info_ptr); - /* get UTCB memory */ Platform_pd::touch_utcb_space(); @@ -572,11 +562,9 @@ void Platform::_setup_basics() _region_alloc.remove_range(stack_area_virtual_base(), stack_area_virtual_size()); - /* remove KIP and MBI area from region and IO_MEM allocator */ + /* remove KIP area from region and IO_MEM allocator */ remove_region(Region((addr_t)kip, (addr_t)kip + kip_size), _region_alloc); remove_region(Region((addr_t)kip, (addr_t)kip + kip_size), _io_mem_alloc); - remove_region(Region((addr_t)mb_info_ptr, (addr_t)mb_info_ptr + _mb_info.size()), _region_alloc); - remove_region(Region((addr_t)mb_info_ptr, (addr_t)mb_info_ptr + _mb_info.size()), _io_mem_alloc); /* remove utcb area */ addr_t utcb_ptr = (addr_t)Platform_pd::_core_utcb_ptr; @@ -597,31 +585,12 @@ void Platform::_setup_basics() void Platform::_setup_rom() { - Rom_module rom; - - Pistachio::L4_Word_t page_size = Pistachio::get_page_size(); - - for (unsigned i = 0; i < _mb_info.num_modules(); i++) { - if (!(rom = _mb_info.get_module(i)).valid()) continue; - - Rom_module *new_rom = new(core_mem_alloc()) Rom_module(rom); - - _rom_fs.insert(new_rom); - - if (verbose) - log(" mod[", i, "] ", *new_rom); - - /* zero remainder of last ROM page */ - size_t count = page_size - rom.size() % page_size; - if (count != page_size) - memset(reinterpret_cast(rom.addr() + rom.size()), 0, count); - - /* remove ROM area from region and IO_MEM allocator */ - remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _region_alloc); - remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _io_mem_alloc); - - /* add area to core-accessible ranges */ - add_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _core_address_ranges()); + /* 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); } } @@ -637,8 +606,7 @@ Platform_pd *Platform::core_pd() Platform::Platform() : _ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()), - _region_alloc(core_mem_alloc()), - _mb_info(init_kip()->BootInfo) + _region_alloc(core_mem_alloc()) { /* * We must be single-threaded at this stage and so this is safe. diff --git a/repos/base-pistachio/src/core/region_map_support.cc b/repos/base-pistachio/src/core/region_map_support.cc index 3949c0976..65c0050de 100644 --- a/repos/base-pistachio/src/core/region_map_support.cc +++ b/repos/base-pistachio/src/core/region_map_support.cc @@ -11,6 +11,8 @@ * under the terms of the GNU General Public License version 2. */ +#include + /* core includes */ #include diff --git a/repos/base-sel4/lib/mk/core.mk b/repos/base-sel4/lib/mk/core.mk index 00cad504d..c565e562b 100644 --- a/repos/base-sel4/lib/mk/core.mk +++ b/repos/base-sel4/lib/mk/core.mk @@ -1,5 +1,3 @@ -TARGET = core - GEN_CORE_DIR = $(BASE_DIR)/src/core SRC_CC += \ diff --git a/repos/base-sel4/mk/spec/sel4.mk b/repos/base-sel4/mk/spec/sel4.mk index a63456091..0537e6b79 100644 --- a/repos/base-sel4/mk/spec/sel4.mk +++ b/repos/base-sel4/mk/spec/sel4.mk @@ -1,5 +1,3 @@ -LD_TEXT_ADDR ?= 0x01000000 - # # Clean rule for removing the side effects of building the platform library # diff --git a/repos/base-sel4/src/core/boot_modules.s b/repos/base-sel4/src/core/boot_modules.s deleted file mode 100644 index 53882f41e..000000000 --- a/repos/base-sel4/src/core/boot_modules.s +++ /dev/null @@ -1,32 +0,0 @@ -/* - * \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-sel4/src/core/platform.cc b/repos/base-sel4/src/core/platform.cc index a38ebf160..39a8bc985 100644 --- a/repos/base-sel4/src/core/platform.cc +++ b/repos/base-sel4/src/core/platform.cc @@ -17,6 +17,7 @@ #include /* core includes */ +#include #include #include #include @@ -40,23 +41,6 @@ static bool const verbose_boot_info = true; extern unsigned _prog_img_beg, _prog_img_end; -/****************** - ** Boot modules ** - ******************/ - -struct Boot_module_header -{ - char const *name; /* physical address of null-terminated string */ - addr_t const base; /* physical address of module data */ - size_t const size; /* size of module data in bytes */ -}; - -extern Boot_module_header _boot_modules_headers_begin; -extern Boot_module_header _boot_modules_headers_end; -extern int _boot_modules_binaries_begin; -extern int _boot_modules_binaries_end; - - /**************************************** ** Support for core memory management ** ****************************************/ @@ -176,7 +160,7 @@ void Platform::_init_allocators() * attempt to map a page frame. */ addr_t const core_virt_beg = trunc_page((addr_t)&_prog_img_beg), - core_virt_end = round_page((addr_t)&_boot_modules_binaries_end) + core_virt_end = round_page((addr_t)&_prog_img_end) + 4096; size_t const core_size = core_virt_end - core_virt_beg; @@ -366,7 +350,7 @@ void Platform::_init_rom_modules() addr_t const modules_first_frame_sel = bi.userImageFrames.start + (modules_core_offset >> get_page_size_log2()); - Boot_module_header const *header = &_boot_modules_headers_begin; + Boot_modules_header const *header = &_boot_modules_headers_begin; for (; header < &_boot_modules_headers_end; header++) { /* offset relative to first module */ diff --git a/repos/base-sel4/src/core/target.mk b/repos/base-sel4/src/core/target.mk deleted file mode 100644 index eea05ddff..000000000 --- a/repos/base-sel4/src/core/target.mk +++ /dev/null @@ -1,15 +0,0 @@ -TARGET = core -LIBS += core -SRC_S = boot_modules.s - -LD_TEXT_ADDR ?= 0x02000000 - -# XXX hack, based on base-hw/lib/mk/core.mk -ifneq ($(wildcard $(BUILD_BASE_DIR)/boot_modules.s),) - BOOT_MODULES_VPATH = $(BUILD_BASE_DIR) - INC_DIR += $(BOOT_MODULES_VPATH) -else - # use dummy boot-modules by default - BOOT_MODULES_VPATH = $(REP_DIR)/src/core/ -endif -vpath boot_modules.s $(BOOT_MODULES_VPATH) diff --git a/repos/base/mk/prg.mk b/repos/base/mk/prg.mk index 42b0b31eb..de6c019d6 100644 --- a/repos/base/mk/prg.mk +++ b/repos/base/mk/prg.mk @@ -52,6 +52,7 @@ include $(BASE_DIR)/mk/global.mk # # Assemble linker options for static and dynamic linkage # +LD_TEXT_ADDR ?= 0x01000000 ifneq ($(LD_TEXT_ADDR),) CXX_LINK_OPT += -Wl,-Ttext=$(LD_TEXT_ADDR) endif diff --git a/repos/base/src/core/include/boot_modules.h b/repos/base/src/core/include/boot_modules.h new file mode 100644 index 000000000..f83121ec2 --- /dev/null +++ b/repos/base/src/core/include/boot_modules.h @@ -0,0 +1,31 @@ +/* + * \brief Boot modules + * \author Stefan Kalkowski + * \date 2016-09-15 + */ + +/* + * Copyright (C) 2016 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. + */ + +#ifndef _CORE__INCLUDE__BOOT_MODULES_H_ +#define _CORE__INCLUDE__BOOT_MODULES_H_ + +namespace Genode { struct Boot_modules_header; } + +struct Genode::Boot_modules_header +{ + long name; /* physical address of null-terminated string */ + long base; /* physical address of module data */ + long size; /* size of module data in bytes */ +}; + +extern Genode::Boot_modules_header _boot_modules_headers_begin; +extern Genode::Boot_modules_header _boot_modules_headers_end; +extern int _boot_modules_binaries_begin; +extern int _boot_modules_binaries_end; + +#endif /* _CORE__INCLUDE__BOOT_MODULES_H_ */ diff --git a/repos/base/src/core/multiboot_info.cc b/repos/base/src/core/multiboot_info.cc deleted file mode 100644 index 6c5eb2cf5..000000000 --- a/repos/base/src/core/multiboot_info.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* - * \brief GRUB multi-boot information handling - * \author Christian Helmuth - * \date 2006-05-10 - */ - -/* - * Copyright (C) 2006-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. - */ - -#include - -using namespace Genode; - - -unsigned Multiboot_info::num_modules() { return read(); } - - -Rom_module Multiboot_info::get_module(unsigned num) -{ - if (num >= num_modules()) return Rom_module(); - - Mods mods = _get_mod(num); - - char *cmdline = reinterpret_cast(mods.read()); - /* invalid module -- maybe returned earlier */ - if (!cmdline) return Rom_module(); - - /* skip everything in front of the base name of the file */ - for (unsigned i = 0; cmdline[i]; i++) { - - if (cmdline[i] != '/') continue; - - /* - * If we detect the end of a directory name, take the - * next character as the start of the command line - */ - cmdline = cmdline + i + 1; - i = 0; - } - - Rom_module ret = Rom_module(mods.read(), - mods.read() - mods.read(), - cmdline); - - /* mark module as invalid */ - mods.write(0); - - return ret; -} - - -/** - * Constructor - */ -Multiboot_info::Multiboot_info(addr_t mbi, bool path_strip) -: Mmio(mbi) -{ - if (!path_strip) - return; - - /* strip path and arguments from module name */ - for (unsigned i = 0; i < num_modules(); i++) { - Mods mods = _get_mod(i); - char *cmdline = reinterpret_cast(mods.read()); - mods.write((addr_t)commandline_to_basename(cmdline)); - } -} diff --git a/repos/base/src/core/target.mk b/repos/base/src/core/target.mk new file mode 100644 index 000000000..1cabfdcb4 --- /dev/null +++ b/repos/base/src/core/target.mk @@ -0,0 +1,13 @@ +TARGET = core +LIBS = core +CORE_OBJ = core.o + +$(TARGET): $(CORE_OBJ) + $(VERBOSE)true + +.PHONY: $(CORE_OBJ) +$(CORE_OBJ): + $(VERBOSE)$(LD) $(LD_MARCH) -u _start --whole-archive -r $(LINK_ITEMS) $(LIBCXX_GCC) -o $@ + +clean cleanall: + $(VERBOSE)rm -f $(CORE_OBJ) diff --git a/repos/base/src/ld/genode.ld b/repos/base/src/ld/genode.ld index fd7eebd4c..955db108d 100644 --- a/repos/base/src/ld/genode.ld +++ b/repos/base/src/ld/genode.ld @@ -17,6 +17,7 @@ PHDRS { ro PT_LOAD; rw PT_LOAD; + boot PT_LOAD FLAGS(4); } SECTIONS @@ -118,18 +119,12 @@ SECTIONS } _bss_end = ALIGN(4); + /* separate location for the binaries of the boot modules */ + .data.boot_modules_binaries : { *(.data.boot_modules_binaries) } : boot + /* end of program image -- must be after last section */ _prog_img_end = .; - /* - * Separate location for the binaries of the boot modules - * - * This is merely used by base-hw yet to enable on-demand mapping. - * Must be a subsection of data as object copy may not copy the content - * to the uImage otherwise. - */ - .data.boot_modules_binaries : { *(.data.boot_modules_binaries) } : rw - /DISCARD/ : { *(.note) *(.note.ABI-tag) diff --git a/repos/base/src/lib/base/child_process.cc b/repos/base/src/lib/base/child_process.cc index ff4c3c97c..a952daa28 100644 --- a/repos/base/src/lib/base/child_process.cc +++ b/repos/base/src/lib/base/child_process.cc @@ -73,7 +73,8 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds Elf_segment seg; for (unsigned n = 0; (seg = elf.get_segment(n)).valid(); ++n) { - if (seg.flags().skip) continue; + if (seg.flags().skip) continue; + if (seg.mem_size() == 0) continue; /* same values for r/o and r/w segments */ addr_t const addr = (addr_t)seg.start(); diff --git a/tool/run/boot_dir/fiasco b/tool/run/boot_dir/fiasco index dac7fe441..4ac46ad3f 100644 --- a/tool/run/boot_dir/fiasco +++ b/tool/run/boot_dir/fiasco @@ -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 diff --git a/tool/run/boot_dir/foc b/tool/run/boot_dir/foc index 0c70eada6..5d2d5f4c3 100644 --- a/tool/run/boot_dir/foc +++ b/tool/run/boot_dir/foc @@ -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] } } diff --git a/tool/run/boot_dir/hw b/tool/run/boot_dir/hw index 953095284..3dacf895a 100644 --- a/tool/run/boot_dir/hw +++ b/tool/run/boot_dir/hw @@ -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 } diff --git a/tool/run/boot_dir/nova b/tool/run/boot_dir/nova index 98f6a4f3d..11cae43ce 100644 --- a/tool/run/boot_dir/nova +++ b/tool/run/boot_dir/nova @@ -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 diff --git a/tool/run/boot_dir/okl4 b/tool/run/boot_dir/okl4 index 71927a2b4..74f996abe 100644 --- a/tool/run/boot_dir/okl4 +++ b/tool/run/boot_dir/okl4 @@ -97,7 +97,7 @@ set weaver_xml_template { - + } @@ -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 {} puts $fh {} 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 { } - puts $fh " " - foreach binary $binaries { - if {$binary != "core"} { - puts $fh " " } - } - puts $fh { } puts $fh {} 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 diff --git a/tool/run/boot_dir/pistachio b/tool/run/boot_dir/pistachio index 50421a763..9842862f1 100644 --- a/tool/run/boot_dir/pistachio +++ b/tool/run/boot_dir/pistachio @@ -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 diff --git a/tool/run/boot_dir/sel4 b/tool/run/boot_dir/sel4 index d915f95af..1384cab2c 100644 --- a/tool/run/boot_dir/sel4 +++ b/tool/run/boot_dir/sel4 @@ -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 } diff --git a/tool/run/run b/tool/run/run index fab251c7b..8b585a555 100755 --- a/tool/run/run +++ b/tool/run/run @@ -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 ##