mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
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:
parent
abc80b7782
commit
23f35370a2
@ -25,6 +25,7 @@ SRC_CC += stack_area.cc \
|
||||
ram_dataspace_factory.cc \
|
||||
pd_session_support.cc \
|
||||
platform.cc \
|
||||
platform_rom_modules.cc \
|
||||
platform_pd.cc \
|
||||
platform_services.cc \
|
||||
platform_thread.cc \
|
||||
@ -74,3 +75,4 @@ vpath default_log.cc $(GEN_CORE_DIR)
|
||||
vpath dump_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath stack_area.cc $(GEN_CORE_DIR)
|
||||
vpath pager_ep.cc $(GEN_CORE_DIR)
|
||||
vpath platform_rom_modules.cc $(GEN_CORE_DIR)
|
||||
|
@ -80,13 +80,15 @@ namespace Genode {
|
||||
/**
|
||||
* Parse multi-boot information and update ROM database
|
||||
*/
|
||||
void _setup_rom();
|
||||
void _init_rom_modules();
|
||||
|
||||
/**
|
||||
* Setup pager for core-internal threads
|
||||
*/
|
||||
void _setup_core_pager();
|
||||
|
||||
addr_t _rom_module_phys(addr_t virt) { return virt; }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -410,18 +410,6 @@ void Platform::_setup_basics()
|
||||
}
|
||||
|
||||
|
||||
void Platform::_setup_rom()
|
||||
{
|
||||
/* add boot modules to ROM FS */
|
||||
Boot_modules_header * header = &_boot_modules_headers_begin;
|
||||
for (; header < &_boot_modules_headers_end; header++) {
|
||||
Rom_module * rom = new (core_mem_alloc())
|
||||
Rom_module(header->base, header->size, (const char*)header->name);
|
||||
_rom_fs.insert(rom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Platform::Platform() :
|
||||
_ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()),
|
||||
_io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()),
|
||||
@ -439,7 +427,7 @@ Platform::Platform() :
|
||||
_setup_mem_alloc();
|
||||
_setup_io_port_alloc();
|
||||
_setup_irq_alloc();
|
||||
_setup_rom();
|
||||
_init_rom_modules();
|
||||
|
||||
log(":ram_alloc: ", _ram_alloc);
|
||||
log(":region_alloc: ", _region_alloc);
|
||||
|
@ -23,6 +23,7 @@ SRC_CC += stack_area.cc \
|
||||
native_cpu_component.cc \
|
||||
rpc_cap_factory.cc \
|
||||
platform.cc \
|
||||
platform_rom_modules.cc \
|
||||
platform_pd.cc \
|
||||
platform_services.cc \
|
||||
platform_thread.cc \
|
||||
@ -66,5 +67,6 @@ vpath signal_transmitter_proxy.cc $(GEN_CORE_DIR)
|
||||
vpath signal_receiver.cc $(GEN_CORE_DIR)
|
||||
vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath core_region_map.cc $(GEN_CORE_DIR)
|
||||
vpath platform_rom_modules.cc $(GEN_CORE_DIR)
|
||||
vpath %.cc $(REP_DIR)/src/core
|
||||
vpath %.cc $(REP_DIR)/src/lib/base
|
||||
|
@ -98,13 +98,15 @@ namespace Genode {
|
||||
/**
|
||||
* Parse multi-boot information and update ROM database
|
||||
*/
|
||||
void _setup_rom();
|
||||
void _init_rom_modules();
|
||||
|
||||
/**
|
||||
* Setup pager for core-internal threads
|
||||
*/
|
||||
void _setup_core_pager();
|
||||
|
||||
addr_t _rom_module_phys(addr_t virt) { return virt; }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -410,18 +410,6 @@ void Platform::_setup_basics()
|
||||
}
|
||||
|
||||
|
||||
void Platform::_setup_rom()
|
||||
{
|
||||
/* add boot modules to ROM FS */
|
||||
Boot_modules_header * header = &_boot_modules_headers_begin;
|
||||
for (; header < &_boot_modules_headers_end; header++) {
|
||||
Rom_module * rom = new (core_mem_alloc())
|
||||
Rom_module(header->base, header->size, (const char*)header->name);
|
||||
_rom_fs.insert(rom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Platform::Platform() :
|
||||
_ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()),
|
||||
_io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()),
|
||||
@ -440,7 +428,7 @@ Platform::Platform() :
|
||||
_setup_mem_alloc();
|
||||
_setup_io_port_alloc();
|
||||
_setup_irq_alloc();
|
||||
_setup_rom();
|
||||
_init_rom_modules();
|
||||
|
||||
log(":ram_alloc: ", _ram_alloc);
|
||||
log(":region_alloc: ", _region_alloc);
|
||||
|
@ -32,6 +32,7 @@ SRC_CC += main.cc
|
||||
SRC_CC += native_pd_component.cc
|
||||
SRC_CC += pd_session_support.cc
|
||||
SRC_CC += platform.cc
|
||||
SRC_CC += platform_rom_modules.cc
|
||||
SRC_CC += platform_pd.cc
|
||||
SRC_CC += platform_thread.cc
|
||||
SRC_CC += stack_area.cc
|
||||
|
@ -120,16 +120,7 @@ Platform::Platform()
|
||||
}
|
||||
|
||||
_init_io_mem_alloc();
|
||||
|
||||
/* add boot modules to ROM FS */
|
||||
Boot_modules_header * header = &_boot_modules_headers_begin;
|
||||
for (; header < &_boot_modules_headers_end; header++) {
|
||||
Rom_module * rom_module = new (core_mem_alloc())
|
||||
Rom_module(Platform::core_phys_addr(header->base), header->size,
|
||||
(const char*)header->name);
|
||||
_rom_fs.insert(rom_module);
|
||||
}
|
||||
|
||||
_init_rom_modules();
|
||||
_init_additional();
|
||||
|
||||
/* print ressource summary */
|
||||
|
@ -51,7 +51,7 @@ class Genode::Platform : public Genode::Platform_generic
|
||||
/**
|
||||
* Initialize I/O port allocator
|
||||
*/
|
||||
void _init_io_port_alloc();
|
||||
void _init_io_port_alloc();
|
||||
|
||||
/**
|
||||
* Initialize IO memory allocator
|
||||
@ -61,12 +61,16 @@ class Genode::Platform : public Genode::Platform_generic
|
||||
* driven outside of core. Using byte granularity allows handing
|
||||
* out the MMIO page to trusted user-level device drivers.
|
||||
*/
|
||||
void _init_io_mem_alloc();
|
||||
void _init_io_mem_alloc();
|
||||
|
||||
/**
|
||||
* Perform additional platform-specific initialization.
|
||||
*/
|
||||
void _init_additional();
|
||||
void _init_additional();
|
||||
|
||||
void _init_rom_modules();
|
||||
|
||||
addr_t _rom_module_phys(addr_t virt) { return core_phys_addr(virt); }
|
||||
|
||||
public:
|
||||
|
||||
|
@ -28,6 +28,7 @@ SRC_CC += stack_area.cc \
|
||||
rpc_cap_factory.cc \
|
||||
ram_dataspace_factory.cc \
|
||||
platform.cc \
|
||||
platform_rom_modules.cc \
|
||||
platform_pd.cc \
|
||||
platform_services.cc \
|
||||
platform_thread.cc \
|
||||
@ -69,6 +70,7 @@ vpath dataspace_component.cc $(GEN_CORE_DIR)
|
||||
vpath core_mem_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath default_log.cc $(GEN_CORE_DIR)
|
||||
vpath dump_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath platform_rom_modules.cc $(GEN_CORE_DIR)
|
||||
vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath stack_area.cc $(GEN_CORE_DIR)
|
||||
vpath core_printf.cc $(BASE_DIR)/src/lib/base
|
||||
|
@ -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:
|
||||
|
||||
/**
|
||||
|
@ -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])) {
|
||||
|
@ -28,6 +28,7 @@ SRC_CC += stack_area.cc \
|
||||
rpc_cap_factory_l4.cc \
|
||||
ram_dataspace_factory.cc \
|
||||
platform.cc \
|
||||
platform_rom_modules.cc \
|
||||
platform_pd.cc \
|
||||
platform_services.cc \
|
||||
platform_thread.cc \
|
||||
@ -72,3 +73,4 @@ vpath dump_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath default_log.cc $(GEN_CORE_DIR)
|
||||
vpath stack_area.cc $(GEN_CORE_DIR)
|
||||
vpath pager_ep.cc $(GEN_CORE_DIR)
|
||||
vpath platform_rom_modules.cc $(GEN_CORE_DIR)
|
||||
|
@ -64,7 +64,9 @@ namespace Genode {
|
||||
*/
|
||||
addr_t _utcb_base;
|
||||
|
||||
void _setup_rom();
|
||||
void _init_rom_modules();
|
||||
|
||||
addr_t _rom_module_phys(addr_t virt) { return virt; }
|
||||
|
||||
public:
|
||||
|
||||
|
@ -92,18 +92,6 @@ int Platform::bi_add_phys_mem(Okl4::bi_name_t pool, Okl4::uintptr_t base,
|
||||
}
|
||||
|
||||
|
||||
void Platform::_setup_rom()
|
||||
{
|
||||
/* add boot modules to ROM FS */
|
||||
Boot_modules_header * header = &_boot_modules_headers_begin;
|
||||
for (; header < &_boot_modules_headers_end; header++) {
|
||||
Rom_module * rom = new (core_mem_alloc())
|
||||
Rom_module(header->base, header->size, (const char*)header->name);
|
||||
_rom_fs.insert(rom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static char init_slab_block_rom[get_page_size()];
|
||||
static char init_slab_block_thread[get_page_size()];
|
||||
|
||||
@ -173,7 +161,7 @@ Platform::Platform() :
|
||||
/* I/O port allocator (only meaningful for x86) */
|
||||
_io_port_alloc.add_range(0, 0x10000);
|
||||
|
||||
_setup_rom();
|
||||
_init_rom_modules();
|
||||
|
||||
/* preserve stack area in core's virtual address space */
|
||||
_core_mem_alloc.virt_alloc()->remove_range(stack_area_virtual_base(),
|
||||
|
@ -26,6 +26,7 @@ SRC_CC = stack_area.cc \
|
||||
pager_ep.cc \
|
||||
pager_object.cc \
|
||||
platform.cc \
|
||||
platform_rom_modules.cc \
|
||||
platform_pd.cc \
|
||||
platform_services.cc \
|
||||
platform_thread.cc \
|
||||
@ -70,3 +71,4 @@ vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath core_region_map.cc $(GEN_CORE_DIR)
|
||||
vpath stack_area.cc $(GEN_CORE_DIR)
|
||||
vpath pager_ep.cc $(GEN_CORE_DIR)
|
||||
vpath platform_rom_modules.cc $(GEN_CORE_DIR)
|
||||
|
@ -86,7 +86,9 @@ namespace Genode {
|
||||
/**
|
||||
* Parse multi-boot information and update ROM database
|
||||
*/
|
||||
void _setup_rom();
|
||||
void _init_rom_modules();
|
||||
|
||||
addr_t _rom_module_phys(addr_t virt) { return virt; }
|
||||
|
||||
public:
|
||||
|
||||
|
@ -575,18 +575,6 @@ void Platform::_setup_basics()
|
||||
}
|
||||
|
||||
|
||||
void Platform::_setup_rom()
|
||||
{
|
||||
/* add boot modules to ROM FS */
|
||||
Boot_modules_header * header = &_boot_modules_headers_begin;
|
||||
for (; header < &_boot_modules_headers_end; header++) {
|
||||
Rom_module * rom = new (core_mem_alloc())
|
||||
Rom_module(header->base, header->size, (const char*)header->name);
|
||||
_rom_fs.insert(rom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Platform_pd *Platform::core_pd()
|
||||
{
|
||||
/* on first call, setup task object for core task */
|
||||
@ -614,12 +602,13 @@ Platform::Platform() :
|
||||
_setup_mem_alloc();
|
||||
_setup_io_port_alloc();
|
||||
_setup_irq_alloc();
|
||||
_setup_rom();
|
||||
_init_rom_modules();
|
||||
|
||||
/*
|
||||
* When dumping 'ram_alloc', there are several small blocks in addition
|
||||
* to the available free memory visible. These small blocks are used to
|
||||
* hold the meta data for the ROM modules as initialized by '_setup_rom'.
|
||||
* hold the meta data for the ROM modules as initialized by
|
||||
* '_init_rom_modules'.
|
||||
*/
|
||||
if (verbose) {
|
||||
log(":ram_alloc: ", _ram_alloc);
|
||||
|
32
repos/base/src/core/platform_rom_modules.cc
Normal file
32
repos/base/src/core/platform_rom_modules.cc
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* \brief Default implementation of the ROM modules initialization
|
||||
* \author Martin Stein
|
||||
* \date 2017-08-17
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
/* core includes */
|
||||
#include <boot_modules.h>
|
||||
#include <platform.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Platform::_init_rom_modules()
|
||||
{
|
||||
/* add boot modules to ROM FS */
|
||||
Boot_modules_header *header = &_boot_modules_headers_begin;
|
||||
for (; header < &_boot_modules_headers_end; header++) {
|
||||
|
||||
Rom_module *rom_module = new (core_mem_alloc())
|
||||
Rom_module(_rom_module_phys(header->base), header->size,
|
||||
(const char*)header->name);
|
||||
_rom_fs.insert(rom_module);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user