diff --git a/repos/dde_linux/src/include/lx_kit/initial_config.h b/repos/dde_linux/src/include/lx_kit/initial_config.h new file mode 100644 index 0000000000..5048e87a93 --- /dev/null +++ b/repos/dde_linux/src/include/lx_kit/initial_config.h @@ -0,0 +1,56 @@ +/* + * \brief Lx_kit initial config utility + * \author Christian Helmuth + * \author Norman Feske + * \date 2022-03-11 + */ + +/* + * Copyright (C) 2022 Genode Labs GmbH + * + * This file is distributed under the terms of the GNU General Public License + * version 2. + */ + +#ifndef _LX_KIT__INITIAL_CONFIG_H_ +#define _LX_KIT__INITIAL_CONFIG_H_ + +#include +#include + +namespace Lx_kit { + using namespace Genode; + + struct Initial_config; +} + + +struct Lx_kit::Initial_config +{ + Attached_rom_dataspace rom; + + void _handle_signal() { rom.update(); } + + Initial_config(Genode::Env &env) : rom(env, "config") + { + /* + * Defer the startup of the USB driver until the first configuration + * becomes available. This is needed in scenarios where the configuration + * is dynamically generated and supplied to the USB driver via the + * report-ROM service. + */ + + Io_signal_handler sigh { + env.ep(), *this, &Initial_config::_handle_signal }; + + rom.sigh(sigh); + _handle_signal(); + + while (rom.xml().type() != "config") + env.ep().wait_and_dispatch_one_io_signal(); + + rom.sigh(Signal_context_capability()); + } +}; + +#endif /* _LX_KIT__INITIAL_CONFIG_H_ */ diff --git a/repos/pc/src/drivers/usb_host/pc/main.cc b/repos/pc/src/drivers/usb_host/pc/main.cc index 705340b00a..18e54eb7f2 100644 --- a/repos/pc/src/drivers/usb_host/pc/main.cc +++ b/repos/pc/src/drivers/usb_host/pc/main.cc @@ -11,7 +11,6 @@ * version 2. */ -#include #include #include @@ -19,6 +18,7 @@ #include #include #include +#include #include #include @@ -50,8 +50,6 @@ struct Main : private Entrypoint::Io_progress_handler &Main::handle_signal }; Sliced_heap sliced_heap { env.ram(), env.rm() }; - Attached_rom_dataspace config_rom { env, "config" }; - /** * Entrypoint::Io_progress_handler */ @@ -68,7 +66,11 @@ struct Main : private Entrypoint::Io_progress_handler Main(Env & env) : env(env) { - _bios_handoff = config_rom.xml().attribute_value("bios_handoff", true); + { + Lx_kit::Initial_config config { env }; + + _bios_handoff = config.rom.xml().attribute_value("bios_handoff", true); + } Lx_kit::initialize(env);