From a30c4281d2e503152e562429f68136bf75c70ebc Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Mon, 21 Feb 2022 14:59:15 +0100 Subject: [PATCH] genode_c_api: report usb config on demand Do not only report devices, but the current configuration of the driver too, as long as the `report` node in the configuration states it. Ref genodelabs/genode#4416 --- repos/os/src/lib/genode_c_api/usb.cc | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/repos/os/src/lib/genode_c_api/usb.cc b/repos/os/src/lib/genode_c_api/usb.cc index 01a3b2c91d..006d74e0ca 100644 --- a/repos/os/src/lib/genode_c_api/usb.cc +++ b/repos/os/src/lib/genode_c_api/usb.cc @@ -156,7 +156,8 @@ class Root : public Root_component Attached_rom_dataspace _config { _env, "config" }; Signal_handler _config_handler { _env.ep(), *this, &Root::_announce_service }; - Constructible _reporter { }; + Reporter _config_reporter { _env, "config" }; + Reporter _device_reporter { _env, "devices" }; Constructible _devices[MAX_DEVICES]; List> _sessions {}; Id_allocator _id_alloc {}; @@ -587,11 +588,7 @@ void ::Root::_report() { using Value = String<64>; - if (!_reporter.constructed()) - return; - - _reporter->enabled(true); - Reporter::Xml_generator xml(*_reporter, [&] () { + Reporter::Xml_generator xml(_device_reporter, [&] () { _for_each_device([&] (Device & d) { xml.node("device", [&] { xml.attribute("label", d.label()); @@ -620,13 +617,19 @@ void ::Root::_announce_service() * Check for report policy, and resp. con-/destruct device reporter */ _config.xml().with_sub_node("report", [&] (Xml_node node) { - if (node.attribute_value("devices", false)) { - if (!_reporter.constructed()) - _reporter.construct(_env, "devices"); - } else { - if (_reporter.constructed()) - _reporter.destruct(); - } + _device_reporter.enabled(node.attribute_value("devices", false)); + _config_reporter.enabled(node.attribute_value("config", false)); + }); + + /* + * Report the own configuration to show management component + * that we've consumed the configuration + */ + Reporter::Xml_generator xml(_config_reporter, [&] { + xml.attribute("bios_handoff", + _config.xml().attribute_value("bios_handoff", true)); + _config.xml().with_raw_content([&] (char const *start, size_t len) { + xml.append(start, len); }); }); if (_announced)