mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-25 19:54:26 +00:00
os: make report_rom/rom_module.h better reusable
This commit is contained in:
parent
c0e0f2874a
commit
a27cbfd371
@ -117,6 +117,9 @@ struct Rom::Module : Module_list::Element, Readable_module
|
|||||||
|
|
||||||
Name _name;
|
Name _name;
|
||||||
|
|
||||||
|
Genode::Ram_session &_ram;
|
||||||
|
Genode::Region_map &_rm;
|
||||||
|
|
||||||
Read_policy const &_read_policy;
|
Read_policy const &_read_policy;
|
||||||
Write_policy const &_write_policy;
|
Write_policy const &_write_policy;
|
||||||
|
|
||||||
@ -152,17 +155,24 @@ struct Rom::Module : Module_list::Element, Readable_module
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
* \param ram RAM session from which to allocate the module's
|
||||||
|
* backing store
|
||||||
|
* \param rm region map of the local address space, needed
|
||||||
|
* to access the allocated backing store
|
||||||
* \param name module name
|
* \param name module name
|
||||||
* \param read_policy policy hook function that is evaluated each
|
* \param read_policy policy hook function that is evaluated each
|
||||||
* time when the module content is obtained
|
* time when the module content is obtained
|
||||||
* \param write_policy policy hook function that is evaluated each
|
* \param write_policy policy hook function that is evaluated each
|
||||||
* time when the module content is changed
|
* time when the module content is changed
|
||||||
*/
|
*/
|
||||||
Module(Name const &name,
|
Module(Genode::Ram_session &ram,
|
||||||
|
Genode::Region_map &rm,
|
||||||
|
Name const &name,
|
||||||
Read_policy const &read_policy,
|
Read_policy const &read_policy,
|
||||||
Write_policy const &write_policy)
|
Write_policy const &write_policy)
|
||||||
:
|
:
|
||||||
_name(name), _read_policy(read_policy), _write_policy(write_policy)
|
_name(name), _ram(ram), _rm(rm),
|
||||||
|
_read_policy(read_policy), _write_policy(write_policy)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
||||||
@ -240,7 +250,7 @@ struct Rom::Module : Module_list::Element, Readable_module
|
|||||||
* append a zero termination to textual reports.
|
* append a zero termination to textual reports.
|
||||||
*/
|
*/
|
||||||
if (!_ds.constructed() || _ds->size() < (src_len + 1))
|
if (!_ds.constructed() || _ds->size() < (src_len + 1))
|
||||||
_ds.construct(Genode::env()->ram_session(), (src_len + 1));
|
_ds.construct(_ram, _rm, (src_len + 1));
|
||||||
|
|
||||||
/* copy content into backing store */
|
/* copy content into backing store */
|
||||||
_size = src_len;
|
_size = src_len;
|
||||||
|
@ -59,10 +59,11 @@ struct Rom::Registry : Rom::Registry_for_reader, Rom::Registry_for_writer
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Registry(Module::Read_policy const &read_policy,
|
Registry(Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||||
|
Module::Read_policy const &read_policy,
|
||||||
Module::Write_policy const &write_policy)
|
Module::Write_policy const &write_policy)
|
||||||
:
|
:
|
||||||
module("clipboard", read_policy, write_policy)
|
module(ram, rm, "clipboard", read_policy, write_policy)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ struct Clipboard::Main : Rom::Module::Read_policy, Rom::Module::Write_policy
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rom::Registry _rom_registry { *this, *this };
|
Rom::Registry _rom_registry { _env.ram(), _env.rm(), *this, *this };
|
||||||
|
|
||||||
Report::Root report_root = { _env, _sliced_heap, _rom_registry, verbose };
|
Report::Root report_root = { _env, _sliced_heap, _rom_registry, verbose };
|
||||||
Rom ::Root rom_root = { _env, _sliced_heap, _rom_registry };
|
Rom ::Root rom_root = { _env, _sliced_heap, _rom_registry };
|
||||||
|
@ -32,7 +32,7 @@ struct Report_rom::Main
|
|||||||
|
|
||||||
Genode::Sliced_heap sliced_heap { env.ram(), env.rm() };
|
Genode::Sliced_heap sliced_heap { env.ram(), env.rm() };
|
||||||
|
|
||||||
Rom::Registry rom_registry { sliced_heap, config_rom };
|
Rom::Registry rom_registry { sliced_heap, env.ram(), env.rm(), config_rom };
|
||||||
|
|
||||||
Genode::Attached_rom_dataspace config_rom { env, "config" };
|
Genode::Attached_rom_dataspace config_rom { env, "config" };
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
Genode::Allocator &_md_alloc;
|
Genode::Allocator &_md_alloc;
|
||||||
|
Genode::Ram_session &_ram;
|
||||||
|
Genode::Region_map &_rm;
|
||||||
Genode::Attached_rom_dataspace &_config_rom;
|
Genode::Attached_rom_dataspace &_config_rom;
|
||||||
|
|
||||||
Module_list _modules;
|
Module_list _modules;
|
||||||
@ -70,7 +72,7 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy
|
|||||||
/* XXX if we run out of memory, the server will abort */
|
/* XXX if we run out of memory, the server will abort */
|
||||||
|
|
||||||
Module * const module = new (&_md_alloc)
|
Module * const module = new (&_md_alloc)
|
||||||
Module(name, _read_write_policy, _read_write_policy);
|
Module(_ram, _rm, name, _read_write_policy, _read_write_policy);
|
||||||
|
|
||||||
_modules.insert(module);
|
_modules.insert(module);
|
||||||
return *module;
|
return *module;
|
||||||
@ -144,9 +146,10 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Registry(Genode::Allocator &md_alloc,
|
Registry(Genode::Allocator &md_alloc,
|
||||||
|
Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||||
Genode::Attached_rom_dataspace &config_rom)
|
Genode::Attached_rom_dataspace &config_rom)
|
||||||
:
|
:
|
||||||
_md_alloc(md_alloc), _config_rom(config_rom)
|
_md_alloc(md_alloc), _ram(ram), _rm(rm), _config_rom(config_rom)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Module &lookup(Writer &writer, Module::Name const &name) override
|
Module &lookup(Writer &writer, Module::Name const &name) override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user