mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-22 06:57:51 +00:00
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:
parent
14f192fb00
commit
e9b666d1a8
@ -5,7 +5,7 @@ Devices ROM
|
|||||||
|
|
||||||
The platform driver knows which devices exist, as well as what resources
|
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
|
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
|
after investigating ACPI and PCI(*) information. The devices ROM name can be
|
||||||
defined by setting the "devices_rom" attribute in the config of the
|
defined by setting the "devices_rom" attribute in the config of the
|
||||||
platform driver:
|
platform driver:
|
||||||
@ -20,11 +20,11 @@ If the attribute isn't set, the platform driver asks for a ROM called
|
|||||||
Behavior
|
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
|
access certain devices to form a virtual bus per client. The client may
|
||||||
iterate through the virtual bus using the devices_rom() function of
|
iterate through the virtual bus using the devices_rom() function of
|
||||||
the platform_session interface to discover all available devices of the virtual
|
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
|
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
|
not need the devices ROM, but can simply obtain their device capability via
|
||||||
the acquire_single_device() function of the platform session interface.
|
the acquire_single_device() function of the platform session interface.
|
||||||
@ -48,20 +48,20 @@ A policy may contain several nodes describing several devices.
|
|||||||
! </config>
|
! </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
|
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
|
specific physical RAM ranges. The platform driver uses this feature to ensure that
|
||||||
the allocation of DMA capable memory consider several restrictions. For
|
the allocation of DMA capable memory consider several restrictions. For
|
||||||
example, some drivers, as the UHCI controller, requires a
|
example, some drivers, as the UHCI controller, requires a
|
||||||
physical memory address below 4G. Another example is that on 32bit hosts
|
physical memory address below 4G. Another example is: on 32bit hosts
|
||||||
physical to virtual identical mappings of DMA memory for the device_pd
|
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).
|
(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
|
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.
|
platform driver to call system management firmware via kernel syscalls.
|
||||||
|
|
||||||
The 'info' attribute in a policy node describe, whether the client's devices
|
The 'info' attribute in a policy node describe, whether the client's devices
|
||||||
ROM will contain detailed information about physical resources of the 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.
|
operate with global names of physical resources.
|
||||||
|
|
||||||
Policy for PCI devices
|
Policy for PCI devices
|
||||||
@ -87,11 +87,11 @@ By default the platform driver does not report anything. But when adding a
|
|||||||
report node:
|
report node:
|
||||||
|
|
||||||
! <config>
|
! <config>
|
||||||
! <report devices="yes" config="yes"
|
! <report devices="yes" config="yes"/>
|
||||||
! ...
|
! ...
|
||||||
! </config>
|
! </config>
|
||||||
|
|
||||||
it is possible to enable either a devices and/or config report. The first will
|
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
|
state. Whereby the second report states the currently active configuration of
|
||||||
the platform driver.
|
the platform driver.
|
||||||
|
@ -22,8 +22,6 @@ class Driver::Common
|
|||||||
Env & _env;
|
Env & _env;
|
||||||
String<64> _rom_name;
|
String<64> _rom_name;
|
||||||
Attached_rom_dataspace _devices_rom { _env, _rom_name.string() };
|
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() };
|
Heap _heap { _env.ram(), _env.rm() };
|
||||||
Sliced_heap _sliced_heap { _env.ram(), _env.rm() };
|
Sliced_heap _sliced_heap { _env.ram(), _env.rm() };
|
||||||
Device_model _devices { _heap, _dev_reporter };
|
Device_model _devices { _heap, _dev_reporter };
|
||||||
@ -31,6 +29,9 @@ class Driver::Common
|
|||||||
&Common::_handle_devices };
|
&Common::_handle_devices };
|
||||||
Driver::Root _root;
|
Driver::Root _root;
|
||||||
|
|
||||||
|
Constructible<Expanding_reporter> _cfg_reporter { };
|
||||||
|
Constructible<Expanding_reporter> _dev_reporter { };
|
||||||
|
|
||||||
void _handle_devices();
|
void _handle_devices();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -41,8 +42,8 @@ class Driver::Common
|
|||||||
void handle_config(Xml_node config);
|
void handle_config(Xml_node config);
|
||||||
void announce_service();
|
void announce_service();
|
||||||
|
|
||||||
Common(Genode::Env & env,
|
Common(Genode::Env & env,
|
||||||
Attached_rom_dataspace & config_rom);
|
Attached_rom_dataspace const & config_rom);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -57,19 +58,20 @@ void Driver::Common::_handle_devices()
|
|||||||
void Driver::Common::handle_config(Xml_node config)
|
void Driver::Common::handle_config(Xml_node config)
|
||||||
{
|
{
|
||||||
config.for_each_sub_node("report", [&] (Xml_node const node) {
|
config.for_each_sub_node("report", [&] (Xml_node const node) {
|
||||||
_dev_reporter.enabled(node.attribute_value("devices", false));
|
_dev_reporter.conditional(node.attribute_value("devices", false),
|
||||||
_cfg_reporter.enabled(node.attribute_value("config", false));
|
_env, "devices", "devices");
|
||||||
|
_cfg_reporter.conditional(node.attribute_value("config", false),
|
||||||
|
_env, "config", "config");
|
||||||
});
|
});
|
||||||
|
|
||||||
_root.update_policy();
|
_root.update_policy();
|
||||||
|
|
||||||
if (_cfg_reporter.enabled()) {
|
if (_cfg_reporter.constructed())
|
||||||
Reporter::Xml_generator xml(_cfg_reporter, [&] () {
|
_cfg_reporter->generate([&] (Xml_generator & xml) {
|
||||||
config.with_raw_content([&] (char const *src, size_t len) {
|
config.with_raw_content([&] (char const *src, size_t len) {
|
||||||
xml.append(src, len);
|
xml.append(src, len);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,14 +81,14 @@ void Driver::Common::announce_service()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Driver::Common::Common(Genode::Env & env,
|
Driver::Common::Common(Genode::Env & env,
|
||||||
Attached_rom_dataspace & config_rom)
|
Attached_rom_dataspace const & config_rom)
|
||||||
:
|
:
|
||||||
_env(env),
|
_env(env),
|
||||||
_rom_name(config_rom.xml().attribute_value("devices_rom",
|
_rom_name(config_rom.xml().attribute_value("devices_rom",
|
||||||
String<64>("devices"))),
|
String<64>("devices"))),
|
||||||
_root(_env, _sliced_heap, config_rom, _devices)
|
_root(_env, _sliced_heap, config_rom, _devices)
|
||||||
{
|
{
|
||||||
_handle_devices();
|
|
||||||
_devices_rom.sigh(_dev_handler);
|
_devices_rom.sigh(_dev_handler);
|
||||||
|
_handle_devices();
|
||||||
}
|
}
|
||||||
|
@ -186,12 +186,11 @@ Driver::Device::~Device()
|
|||||||
|
|
||||||
void Driver::Device_model::update_report()
|
void Driver::Device_model::update_report()
|
||||||
{
|
{
|
||||||
if (_reporter.enabled()) {
|
if (_reporter.constructed())
|
||||||
Reporter::Xml_generator xml(_reporter, [&] () {
|
_reporter->generate([&] (Xml_generator & xml) {
|
||||||
for_each([&] (Device & device) {
|
for_each([&] (Device & device) {
|
||||||
device.report(xml, *this, true); });
|
device.report(xml, *this, true); });
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,19 +257,21 @@ class Driver::Device_model :
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Heap & _heap;
|
Heap & _heap;
|
||||||
Reporter & _reporter;
|
List_model<Device> _model { };
|
||||||
List_model<Device> _model { };
|
Clocks _clocks { };
|
||||||
Clocks _clocks { };
|
Resets _resets { };
|
||||||
Resets _resets { };
|
Powers _powers { };
|
||||||
Powers _powers { };
|
|
||||||
|
Constructible<Expanding_reporter> & _reporter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void update_report();
|
void update_report();
|
||||||
void update(Xml_node const & node);
|
void update(Xml_node const & node);
|
||||||
|
|
||||||
Device_model(Heap & heap, Reporter & reporter)
|
Device_model(Heap & heap,
|
||||||
|
Constructible<Expanding_reporter> & reporter)
|
||||||
: _heap(heap), _reporter(reporter) { }
|
: _heap(heap), _reporter(reporter) { }
|
||||||
|
|
||||||
~Device_model() {
|
~Device_model() {
|
||||||
|
@ -29,8 +29,8 @@ struct Driver::Main
|
|||||||
Main(Genode::Env & e)
|
Main(Genode::Env & e)
|
||||||
: _env(e)
|
: _env(e)
|
||||||
{
|
{
|
||||||
_handle_config();
|
|
||||||
_config_rom.sigh(_config_handler);
|
_config_rom.sigh(_config_handler);
|
||||||
|
_handle_config();
|
||||||
_common.announce_service();
|
_common.announce_service();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -67,9 +67,9 @@ void Driver::Root::_upgrade_session(Session_component * sc, const char * args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Driver::Root::Root(Env & env,
|
Driver::Root::Root(Env & env,
|
||||||
Sliced_heap & sliced_heap,
|
Sliced_heap & sliced_heap,
|
||||||
Attached_rom_dataspace & config,
|
Attached_rom_dataspace const & config,
|
||||||
Device_model & devices)
|
Device_model & devices)
|
||||||
: Root_component<Session_component>(env.ep(), sliced_heap),
|
: Root_component<Session_component>(env.ep(), sliced_heap),
|
||||||
_env(env), _config(config), _devices(devices) { }
|
_env(env), _config(config), _devices(devices) { }
|
||||||
|
@ -27,10 +27,10 @@ class Driver::Root : public Root_component<Session_component>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Root(Env & env,
|
Root(Env & env,
|
||||||
Sliced_heap & sliced_heap,
|
Sliced_heap & sliced_heap,
|
||||||
Attached_rom_dataspace & config,
|
Attached_rom_dataspace const & config,
|
||||||
Device_model & devices);
|
Device_model & devices);
|
||||||
|
|
||||||
void update_policy();
|
void update_policy();
|
||||||
|
|
||||||
@ -40,10 +40,10 @@ class Driver::Root : public Root_component<Session_component>
|
|||||||
|
|
||||||
void _upgrade_session(Session_component *, const char *) override;
|
void _upgrade_session(Session_component *, const char *) override;
|
||||||
|
|
||||||
Env & _env;
|
Env & _env;
|
||||||
Attached_rom_dataspace & _config;
|
Attached_rom_dataspace const & _config;
|
||||||
Device_model & _devices;
|
Device_model & _devices;
|
||||||
Registry<Session_component> _sessions {};
|
Registry<Session_component> _sessions {};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _SRC__DRIVERS__PLATFORM__ROOT_H_ */
|
#endif /* _SRC__DRIVERS__PLATFORM__ROOT_H_ */
|
||||||
|
@ -225,15 +225,15 @@ Genode::addr_t Session_component::dma_addr(Ram_dataspace_capability ram_cap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Session_component::Session_component(Env & env,
|
Session_component::Session_component(Env & env,
|
||||||
Attached_rom_dataspace & config,
|
Attached_rom_dataspace const & config,
|
||||||
Device_model & devices,
|
Device_model & devices,
|
||||||
Session_registry & registry,
|
Session_registry & registry,
|
||||||
Label const & label,
|
Label const & label,
|
||||||
Resources const & resources,
|
Resources const & resources,
|
||||||
Diag const & diag,
|
Diag const & diag,
|
||||||
bool const info,
|
bool const info,
|
||||||
Policy_version const version)
|
Policy_version const version)
|
||||||
:
|
:
|
||||||
Session_object<Platform::Session>(env.ep(), resources, label, diag),
|
Session_object<Platform::Session>(env.ep(), resources, label, diag),
|
||||||
Session_registry::Element(registry, *this),
|
Session_registry::Element(registry, *this),
|
||||||
|
@ -44,15 +44,15 @@ class Driver::Session_component
|
|||||||
using Session_registry = Registry<Session_component>;
|
using Session_registry = Registry<Session_component>;
|
||||||
using Policy_version = String<64>;
|
using Policy_version = String<64>;
|
||||||
|
|
||||||
Session_component(Env & env,
|
Session_component(Env & env,
|
||||||
Attached_rom_dataspace & config,
|
Attached_rom_dataspace const & config,
|
||||||
Device_model & devices,
|
Device_model & devices,
|
||||||
Session_registry & registry,
|
Session_registry & registry,
|
||||||
Label const & label,
|
Label const & label,
|
||||||
Resources const & resources,
|
Resources const & resources,
|
||||||
Diag const & diag,
|
Diag const & diag,
|
||||||
bool const info,
|
bool const info,
|
||||||
Policy_version const version);
|
Policy_version const version);
|
||||||
|
|
||||||
~Session_component();
|
~Session_component();
|
||||||
|
|
||||||
@ -98,23 +98,23 @@ class Driver::Session_component
|
|||||||
: Registry<Dma_buffer>::Element(registry, *this), cap(cap) {}
|
: Registry<Dma_buffer>::Element(registry, *this), cap(cap) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
Env & _env;
|
Env & _env;
|
||||||
Attached_rom_dataspace & _config;
|
Attached_rom_dataspace const & _config;
|
||||||
Device_model & _devices;
|
Device_model & _devices;
|
||||||
Device::Owner _owner_id { *this };
|
Device::Owner _owner_id { *this };
|
||||||
Constrained_ram_allocator _env_ram { _env.pd(),
|
Constrained_ram_allocator _env_ram { _env.pd(),
|
||||||
_ram_quota_guard(),
|
_ram_quota_guard(),
|
||||||
_cap_quota_guard() };
|
_cap_quota_guard() };
|
||||||
Heap _md_alloc { _env_ram, _env.rm() };
|
Heap _md_alloc { _env_ram, _env.rm() };
|
||||||
Registry<Device_component> _device_registry { };
|
Registry<Device_component> _device_registry { };
|
||||||
Registry<Dma_buffer> _buffer_registry { };
|
Registry<Dma_buffer> _buffer_registry { };
|
||||||
Dynamic_rom_session _rom_session { _env.ep(), _env.ram(),
|
Dynamic_rom_session _rom_session { _env.ep(), _env.ram(),
|
||||||
_env.rm(), *this };
|
_env.rm(), *this };
|
||||||
bool _info;
|
bool _info;
|
||||||
Policy_version _version;
|
Policy_version _version;
|
||||||
Device_pd _device_pd { _env,
|
Device_pd _device_pd { _env,
|
||||||
_ram_quota_guard(),
|
_ram_quota_guard(),
|
||||||
_cap_quota_guard() };
|
_cap_quota_guard() };
|
||||||
|
|
||||||
Device_capability _acquire(Device & device);
|
Device_capability _acquire(Device & device);
|
||||||
void _release_device(Device_component & dc);
|
void _release_device(Device_component & dc);
|
||||||
|
Loading…
Reference in New Issue
Block a user