core: generic ROM module initialization

For most base platforms (except linux and sel4), the initialization of
boot modules is the same. Thus, merge this default implementation in the
new unit base/src/core/platform_rom_modules.cc.

Ref #2490
This commit is contained in:
Martin Stein
2017-08-17 16:20:56 +02:00
committed by Christian Helmuth
parent abc80b7782
commit 23f35370a2
19 changed files with 83 additions and 82 deletions

View File

@ -36,6 +36,7 @@ namespace Genode {
Rom_fs _rom_fs; /* ROM file system */
unsigned _gsi_base_sel; /* cap selector of 1st IRQ */
unsigned _core_pd_sel; /* cap selector of root PD */
addr_t _core_phys_start { 0ULL };
/**
* Virtual address range usable by non-core processes
@ -53,6 +54,10 @@ namespace Genode {
size_t _max_caps = 0;
void _init_rom_modules();
addr_t _rom_module_phys(addr_t virt);
public:
/**

View File

@ -617,7 +617,6 @@ Platform::Platform() :
};
} mbi_fb;
/* build ROM file system */
mem_desc = (Hip::Mem_desc *)mem_desc_base;
for (unsigned i = 0; i < num_mem_desc; i++, mem_desc++) {
if (mem_desc->type == Hip::Mem_desc::ACPI_RSDT) rsdt = mem_desc->addr;
@ -631,19 +630,11 @@ Platform::Platform() :
if (!mem_desc->addr || !mem_desc->size) continue;
/* assume core's ELF image has one-page header */
addr_t const core_phys_start = trunc_page(mem_desc->addr + get_page_size());
addr_t const core_virt_start = (addr_t) &_prog_img_beg;
/* add boot modules to ROM FS */
Boot_modules_header * header = &_boot_modules_headers_begin;
for (; header < &_boot_modules_headers_end; header++) {
Rom_module * rom_module = new (core_mem_alloc())
Rom_module(header->base - core_virt_start + core_phys_start,
header->size, (const char*)header->name);
_rom_fs.insert(rom_module);
}
_core_phys_start = trunc_page(mem_desc->addr + get_page_size());
}
_init_rom_modules();
{
/* export x86 platform specific infos */
@ -784,6 +775,12 @@ Platform::Platform() :
}
addr_t Platform::_rom_module_phys(addr_t virt)
{
return virt - (addr_t)&_prog_img_beg + _core_phys_start;
}
unsigned Platform::kernel_cpu_id(unsigned genode_cpu_id)
{
if (genode_cpu_id >= sizeof(map_cpu_ids) / sizeof(map_cpu_ids[0])) {