Support for dynamic ROM sessions, fix #170

This patch introduces support for ROM sessions that update their
provided data during the lifetime of the session. The 'Rom_session'
interface had been extended with the new 'release()' and 'sigh()'
functions, which are needed to support the new protocol. All ROM
services have been updated to the new interface.

Furthermore, the patch changes the child policy of init
with regard to the handling of configuration files. The 'Init::Child'
used to always provide the ROM dataspace with the child's config file
via a locally implemented ROM service. However, for dynamic ROM
sessions, we need to establish a session to the real supplier of the ROM
data. This is achieved by using a new 'Child_policy_redirect_rom_file'
policy to handle the 'configfile' rather than handling the 'configfile'
case entirely within 'Child_config'.

To see the new facility in action, the new 'os/run/dynamic_config.run'
script provides a simple scenario. The config file of the test program
is provided by a service, which generates and updates the config data
at regular intervals.

In addition, new support has been added to let slaves use dynamic
reconfiguration. By using the new 'Child_policy_dynamic_rom_file', the
configuration of a slave can be changed dynamically at runtime via the
new 'configure()' function.

The config is provided as plain null-terminated string (instead of a
dataspace capability) because we need to buffer the config data anyway.
So there is no benefit of using a dataspace. For buffering configuration
data, a 'Ram_session' must be supplied. If no 'Ram_session' is specified
at construction time of a 'Slave_policy', no config is supplied to the
slave (which is still a common case).

An example for dynamically reconfiguring a slave is provided by
'os/run/dynamic_config_slave.run'.
This commit is contained in:
Norman Feske
2012-04-04 17:07:19 +02:00
parent ba248fe554
commit 9a00ad7ae3
23 changed files with 752 additions and 68 deletions

View File

@ -140,15 +140,18 @@ struct Usb_policy : public Genode::Slave_policy
public:
Usb_policy(Genode::Rpc_entrypoint &entrypoint,
Input::Source_registry &input_source_registry,
Block::Driver_registry &block_driver_registry,
Genode::Dataspace_capability config)
Usb_policy(Genode::Rpc_entrypoint &entrypoint,
Input::Source_registry &input_source_registry,
Block::Driver_registry &block_driver_registry,
Genode::Ram_session *ram,
char const *config)
:
Genode::Slave_policy("usb_drv", entrypoint, config),
Genode::Slave_policy("usb_drv", entrypoint, ram),
_input_source_registry(input_source_registry),
_block_driver_registry(block_driver_registry)
{ }
{
configure(config);
}
bool announce_service(const char *service_name,
Genode::Root_capability root,
@ -238,19 +241,12 @@ int main(int argc, char **argv)
static Ps2_policy ps2_policy(ps2_ep, input_source_registry);
static Genode::Slave ps2_slave(ps2_ep, ps2_policy, 512*1024);
/*
* Create config dataspace for USB driver
*/
enum { USB_CONFIG_MAX_LEN = 4096 };
Genode::Attached_ram_dataspace usb_config_ds(Genode::env()->ram_session(),
USB_CONFIG_MAX_LEN);
char const *config = "<config><hid/><storage/></config>";
Genode::strncpy(usb_config_ds.local_addr<char>(), config, USB_CONFIG_MAX_LEN);
/* create USB driver */
char const *config = "<config><hid/><storage/></config>";
static Rpc_entrypoint usb_ep(&cap, STACK_SIZE, "usb_slave");
static Usb_policy usb_policy(usb_ep, input_source_registry,
block_driver_registry, usb_config_ds.cap());
block_driver_registry, env()->ram_session(),
config);
static Genode::Slave usb_slave(usb_ep, usb_policy, 3*1024*1024);
/* create ATAPI driver */