core: unify handling of boot modules

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

This approach now works for all kernels except Linux.

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

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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -4,11 +4,6 @@
SPECS += foc
#
# Linker options that are specific for arm
#
LD_TEXT_ADDR ?= 0x01000000
#
# ARM-specific L4/sys headers
#

View File

@@ -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
#

View File

@@ -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
#

View File

@@ -26,7 +26,6 @@
#include <platform_generic.h>
#include <platform_thread.h>
#include <platform_pd.h>
#include <multiboot.h>
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();

View File

@@ -24,12 +24,12 @@
#include <base/internal/globals.h>
/* core includes */
#include <boot_modules.h>
#include <core_parent.h>
#include <platform.h>
#include <platform_thread.h>
#include <platform_pd.h>
#include <util.h>
#include <multiboot.h>
/* 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<void *>(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))
{
/*

View File

@@ -14,6 +14,7 @@
/* Genode includes */
#include <base/capability.h>
#include <base/printf.h>
#include <util/misc_math.h>
/* core includes */

View File

@@ -1,4 +0,0 @@
LD_TEXT_ADDR = 0x80100000
REQUIRES += foc_arndale
include $(REP_DIR)/src/core/spec/arm/target.inc

View File

@@ -1,4 +0,0 @@
LD_TEXT_ADDR = 0x70140000
REQUIRES += foc_imx53
include $(REP_DIR)/src/core/spec/arm/target.inc

View File

@@ -1,4 +0,0 @@
LD_TEXT_ADDR = 0x80100000
REQUIRES += foc_odroid_x2
include $(REP_DIR)/src/core/spec/arm/target.inc

View File

@@ -1,4 +0,0 @@
LD_TEXT_ADDR = 0x80140000
REQUIRES += foc_panda
include $(REP_DIR)/src/core/spec/arm/target.inc

View File

@@ -1,4 +0,0 @@
LD_TEXT_ADDR = 0x70490000
REQUIRES += foc_pbxa9
include $(REP_DIR)/src/core/spec/arm/target.inc

View File

@@ -1,5 +0,0 @@
REQUIRES += foc_rpi
LD_TEXT_ADDR ?= 0x800000
include $(REP_DIR)/src/core/spec/arm/target.inc