diff --git a/gems/src/server/d3m/main.cc b/gems/src/server/d3m/main.cc index 8316e6d6f5..686dbe7a39 100644 --- a/gems/src/server/d3m/main.cc +++ b/gems/src/server/d3m/main.cc @@ -129,6 +129,11 @@ struct Usb_policy : public Genode::Slave_policy Block::Driver_registry &_block_driver_registry; Block::Driver _block_driver; + Genode::Root_capability _input_root; + Genode::Root_capability _block_root; + Genode::Lock _input_root_lock; + Genode::Lock _block_root_lock; + protected: const char **_permitted_services() const @@ -150,7 +155,9 @@ struct Usb_policy : public Genode::Slave_policy : Genode::Slave_policy("usb_drv", entrypoint, ram), _input_source_registry(input_source_registry), - _block_driver_registry(block_driver_registry) + _block_driver_registry(block_driver_registry), + _input_root_lock(Genode::Lock::LOCKED), + _block_root_lock(Genode::Lock::LOCKED) { configure(config); } @@ -160,20 +167,35 @@ struct Usb_policy : public Genode::Slave_policy Genode::Allocator *alloc, Genode::Server *server) { + PINF("announce_service %s", service_name); if (Genode::strcmp(service_name, "Input") == 0) { - _input_source_registry_entry.connect(root); - _input_source_registry.add_source(&_input_source_registry_entry); + _input_root = root; + _input_root_lock.unlock(); return true; } if (Genode::strcmp(service_name, "Block") == 0) { - _block_driver.init("usb_drv", root); - _block_driver_registry.add_driver(&_block_driver); + _block_root = root; + _block_root_lock.unlock(); return true; } return false; } + + void connect_input() + { + _input_root_lock.lock(); + _input_source_registry_entry.connect(_input_root); + _input_source_registry.add_source(&_input_source_registry_entry); + } + + void connect_block() + { + _block_root_lock.lock(); + _block_driver.init("usb_drv", _block_root); + _block_driver_registry.add_driver(&_block_driver); + } }; @@ -287,6 +309,9 @@ int main(int argc, char **argv) env()->parent()->announce(ep.manage(&block_root)); } + usb_policy.connect_input(); + usb_policy.connect_block(); + Genode::sleep_forever(); return 0; }