platform_drv: some small and cosmetic fixups

* Some fixups for the README
* Make config ROM const when used for the session policies
* Turn Reporter into Expanding_reporter
* Always first register ROM signal handler before parsing it the first time
This commit is contained in:
Stefan Kalkowski 2022-05-11 17:03:54 +02:00 committed by Christian Helmuth
parent 14f192fb00
commit e9b666d1a8
9 changed files with 82 additions and 79 deletions

View File

@ -5,7 +5,7 @@ Devices ROM
The platform driver knows which devices exist, as well as what resources
they need by parsing XML information from a devices ROM. This ROM might be
a boot module written by a system integrator, or is dynamically produced
a boot module, written by a system integrator, or is dynamically produced
after investigating ACPI and PCI(*) information. The devices ROM name can be
defined by setting the "devices_rom" attribute in the config of the
platform driver:
@ -20,11 +20,11 @@ If the attribute isn't set, the platform driver asks for a ROM called
Behavior
--------
Per client a policy must be configured that states which client can
Per client a policy must be configured that states, which client can
access certain devices to form a virtual bus per client. The client may
iterate through the virtual bus using the devices_rom() function of
the platform_session interface to discover all available devices of the virtual
bus. When identified a specific device its device capability can be obtained
bus. When identified a specific device, its device capability can be obtained
via its unique name. Simple device drivers that drive exactly one device do
not need the devices ROM, but can simply obtain their device capability via
the acquire_single_device() function of the platform session interface.
@ -48,20 +48,20 @@ A policy may contain several nodes describing several devices.
! </config>
! ...
The managing_system attribute is evaluated by init. If set to "yes" it
The managing_system attribute is evaluated by init. If set to "yes", it
permits a component, the platform driver, to restrict the allocation of memory to
specific physical RAM ranges. The platform driver uses this feature to ensure that
the allocation of DMA capable memory consider several restrictions. For
example, some drivers, as the UHCI controller, requires a
physical memory address below 4G. Another example is that on 32bit hosts
physical to virtual identical mappings of DMA memory for the device_pd
physical memory address below 4G. Another example is: on 32bit hosts
physical to virtual identical mappings of DMA memory for the device PD
(required when IOMMU is used) must be below the kernel memory boundary (3G).
On some systems, e.g., base-hw kernel on certain ARM platforms, it allows the
platform driver to call system management firmware via kernel syscalls.
The 'info' attribute in a policy node describe, whether the client's devices
ROM will contain detailed information about physical resources of the devices
of its virtual bus. This is only useful when using ported legacy drivers, which
of its virtual bus. This is only useful, when using ported legacy drivers, which
operate with global names of physical resources.
Policy for PCI devices
@ -87,11 +87,11 @@ By default the platform driver does not report anything. But when adding a
report node:
! <config>
! <report devices="yes" config="yes"
! <report devices="yes" config="yes"/>
! ...
! </config>
it is possible to enable either a devices and/or config report. The first will
open up a Report session to dynamically report all accessible devices and its
open up a Report session to dynamically report all accessible devices, and its
state. Whereby the second report states the currently active configuration of
the platform driver.

View File

@ -22,8 +22,6 @@ class Driver::Common
Env & _env;
String<64> _rom_name;
Attached_rom_dataspace _devices_rom { _env, _rom_name.string() };
Reporter _cfg_reporter { _env, "config" };
Reporter _dev_reporter { _env, "devices" };
Heap _heap { _env.ram(), _env.rm() };
Sliced_heap _sliced_heap { _env.ram(), _env.rm() };
Device_model _devices { _heap, _dev_reporter };
@ -31,6 +29,9 @@ class Driver::Common
&Common::_handle_devices };
Driver::Root _root;
Constructible<Expanding_reporter> _cfg_reporter { };
Constructible<Expanding_reporter> _dev_reporter { };
void _handle_devices();
public:
@ -42,7 +43,7 @@ class Driver::Common
void announce_service();
Common(Genode::Env & env,
Attached_rom_dataspace & config_rom);
Attached_rom_dataspace const & config_rom);
};
@ -57,20 +58,21 @@ void Driver::Common::_handle_devices()
void Driver::Common::handle_config(Xml_node config)
{
config.for_each_sub_node("report", [&] (Xml_node const node) {
_dev_reporter.enabled(node.attribute_value("devices", false));
_cfg_reporter.enabled(node.attribute_value("config", false));
_dev_reporter.conditional(node.attribute_value("devices", false),
_env, "devices", "devices");
_cfg_reporter.conditional(node.attribute_value("config", false),
_env, "config", "config");
});
_root.update_policy();
if (_cfg_reporter.enabled()) {
Reporter::Xml_generator xml(_cfg_reporter, [&] () {
if (_cfg_reporter.constructed())
_cfg_reporter->generate([&] (Xml_generator & xml) {
config.with_raw_content([&] (char const *src, size_t len) {
xml.append(src, len);
});
});
}
}
void Driver::Common::announce_service()
@ -80,13 +82,13 @@ void Driver::Common::announce_service()
Driver::Common::Common(Genode::Env & env,
Attached_rom_dataspace & config_rom)
Attached_rom_dataspace const & config_rom)
:
_env(env),
_rom_name(config_rom.xml().attribute_value("devices_rom",
String<64>("devices"))),
_root(_env, _sliced_heap, config_rom, _devices)
{
_handle_devices();
_devices_rom.sigh(_dev_handler);
_handle_devices();
}

View File

@ -186,13 +186,12 @@ Driver::Device::~Device()
void Driver::Device_model::update_report()
{
if (_reporter.enabled()) {
Reporter::Xml_generator xml(_reporter, [&] () {
if (_reporter.constructed())
_reporter->generate([&] (Xml_generator & xml) {
for_each([&] (Device & device) {
device.report(xml, *this, true); });
});
}
}
void Driver::Device_model::update(Xml_node const & node)

View File

@ -258,18 +258,20 @@ class Driver::Device_model :
private:
Heap & _heap;
Reporter & _reporter;
List_model<Device> _model { };
Clocks _clocks { };
Resets _resets { };
Powers _powers { };
Constructible<Expanding_reporter> & _reporter;
public:
void update_report();
void update(Xml_node const & node);
Device_model(Heap & heap, Reporter & reporter)
Device_model(Heap & heap,
Constructible<Expanding_reporter> & reporter)
: _heap(heap), _reporter(reporter) { }
~Device_model() {

View File

@ -29,8 +29,8 @@ struct Driver::Main
Main(Genode::Env & e)
: _env(e)
{
_handle_config();
_config_rom.sigh(_config_handler);
_handle_config();
_common.announce_service();
}
};

View File

@ -69,7 +69,7 @@ void Driver::Root::_upgrade_session(Session_component * sc, const char * args)
Driver::Root::Root(Env & env,
Sliced_heap & sliced_heap,
Attached_rom_dataspace & config,
Attached_rom_dataspace const & config,
Device_model & devices)
: Root_component<Session_component>(env.ep(), sliced_heap),
_env(env), _config(config), _devices(devices) { }

View File

@ -29,7 +29,7 @@ class Driver::Root : public Root_component<Session_component>
Root(Env & env,
Sliced_heap & sliced_heap,
Attached_rom_dataspace & config,
Attached_rom_dataspace const & config,
Device_model & devices);
void update_policy();
@ -41,7 +41,7 @@ class Driver::Root : public Root_component<Session_component>
void _upgrade_session(Session_component *, const char *) override;
Env & _env;
Attached_rom_dataspace & _config;
Attached_rom_dataspace const & _config;
Device_model & _devices;
Registry<Session_component> _sessions {};
};

View File

@ -226,7 +226,7 @@ Genode::addr_t Session_component::dma_addr(Ram_dataspace_capability ram_cap)
Session_component::Session_component(Env & env,
Attached_rom_dataspace & config,
Attached_rom_dataspace const & config,
Device_model & devices,
Session_registry & registry,
Label const & label,

View File

@ -45,7 +45,7 @@ class Driver::Session_component
using Policy_version = String<64>;
Session_component(Env & env,
Attached_rom_dataspace & config,
Attached_rom_dataspace const & config,
Device_model & devices,
Session_registry & registry,
Label const & label,
@ -99,7 +99,7 @@ class Driver::Session_component
};
Env & _env;
Attached_rom_dataspace & _config;
Attached_rom_dataspace const & _config;
Device_model & _devices;
Device::Owner _owner_id { *this };
Constrained_ram_allocator _env_ram { _env.pd(),