mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 22:47:50 +00:00
pc/usb: defer startup until config is available
The commit also adds lx_kit/initial_config.h as utility.
This commit is contained in:
parent
e3706837b9
commit
7da691b52a
56
repos/dde_linux/src/include/lx_kit/initial_config.h
Normal file
56
repos/dde_linux/src/include/lx_kit/initial_config.h
Normal file
@ -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 <base/env.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
|
||||
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<Initial_config> 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_ */
|
@ -11,7 +11,6 @@
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <base/component.h>
|
||||
#include <base/env.h>
|
||||
|
||||
@ -19,6 +18,7 @@
|
||||
#include <lx_emul/usb.h>
|
||||
#include <lx_kit/env.h>
|
||||
#include <lx_kit/init.h>
|
||||
#include <lx_kit/initial_config.h>
|
||||
#include <lx_user/io.h>
|
||||
|
||||
#include <genode_c_api/usb.h>
|
||||
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user