mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-20 16:10:29 +00:00
committed by
Christian Helmuth
parent
ec700e88f7
commit
c99fb2b69b
@ -15,49 +15,46 @@
|
||||
#ifndef _CORE__INCLUDE__ROM_FS_H_
|
||||
#define _CORE__INCLUDE__ROM_FS_H_
|
||||
|
||||
#include <util/avl_string.h>
|
||||
/* Genode includes */
|
||||
#include <util/dictionary.h>
|
||||
|
||||
/* core includes */
|
||||
#include <types.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
using Rom_name = String<64>;
|
||||
struct Rom_module;
|
||||
struct Rom_fs;
|
||||
}
|
||||
|
||||
|
||||
struct Core::Rom_module : Avl_string_base
|
||||
struct Core::Rom_module : Dictionary<Rom_module, Rom_name>::Element
|
||||
{
|
||||
addr_t const addr = 0;
|
||||
size_t const size = 0;
|
||||
|
||||
Rom_module() : Avl_string_base(nullptr) { }
|
||||
|
||||
Rom_module(addr_t const addr, size_t const size, char const * const name)
|
||||
: Avl_string_base(name), addr(addr), size(size) { }
|
||||
Rom_module(Dictionary<Rom_module, Rom_name> &dict, Rom_name const &name,
|
||||
addr_t addr, size_t size)
|
||||
:
|
||||
Dictionary<Rom_module, Rom_name>::Element(dict, name),
|
||||
addr(addr), size(size)
|
||||
{ }
|
||||
|
||||
bool valid() const { return size ? true : false; }
|
||||
|
||||
void print(Output & out) const {
|
||||
Genode::print(out, Hex_range<addr_t>(addr, size), " ", name()); }
|
||||
void print(Output &out) const {
|
||||
Genode::print(out, Hex_range<addr_t>(addr, size), " ", name); }
|
||||
};
|
||||
|
||||
|
||||
struct Core::Rom_fs : Avl_tree<Avl_string_base>
|
||||
struct Core::Rom_fs : Dictionary<Rom_module, Rom_name>
|
||||
{
|
||||
Rom_module const * find(char const * const name) const
|
||||
{
|
||||
return first() ? (Rom_module const *)first()->find_by_name(name)
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
void print(Output & out) const
|
||||
{
|
||||
if (!first()) Genode::print(out, "No modules in Rom_fs\n");
|
||||
|
||||
Genode::print(out, "ROM modules:\n");
|
||||
for_each([&] (Avl_string_base const & rom) {
|
||||
Genode::print(out, " ROM: ", *static_cast<Rom_module const *>(&rom), "\n"); });
|
||||
for_each([&] (Rom_module const &rom) {
|
||||
Genode::print(out, " ROM: ", rom, "\n"); });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -36,15 +36,13 @@ class Core::Rom_session_component : public Rpc_object<Rom_session>
|
||||
|
||||
Rom_module const &_find_rom(Rom_fs &rom_fs, const char *args)
|
||||
{
|
||||
/* extract label */
|
||||
Session_label const label = label_from_args(args);
|
||||
return rom_fs.with_element(label_from_args(args).last_element(),
|
||||
|
||||
/* find ROM module for trailing label element */
|
||||
Rom_module const * rom = rom_fs.find(label.last_element().string());
|
||||
if (rom)
|
||||
return *rom;
|
||||
[&] (Rom_module const &rom) -> Rom_module const & {
|
||||
return rom; },
|
||||
|
||||
throw Service_denied();
|
||||
[&] () -> Rom_module const & {
|
||||
throw Service_denied(); });
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -20,18 +20,18 @@ using namespace Core;
|
||||
|
||||
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++) {
|
||||
Boot_modules_header const *header_ptr = &_boot_modules_headers_begin;
|
||||
|
||||
if (!header->size) {
|
||||
warning("ignore zero-sized boot module '",
|
||||
Cstring((char const *)header->name), "'");
|
||||
for (; header_ptr < &_boot_modules_headers_end; header_ptr++) {
|
||||
|
||||
Rom_name const name((char const *)header_ptr->name);
|
||||
|
||||
if (!header_ptr->size) {
|
||||
warning("ignore zero-sized boot module '", name, "'");
|
||||
continue;
|
||||
}
|
||||
Rom_module &rom_module = *new (core_mem_alloc())
|
||||
Rom_module(_rom_module_phys(header->base), header->size,
|
||||
(char const *)header->name);
|
||||
_rom_fs.insert(&rom_module);
|
||||
new (core_mem_alloc())
|
||||
Rom_module(_rom_fs, name,
|
||||
_rom_module_phys(header_ptr->base), header_ptr->size);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user