From 1dc92c49ed84e62480cefd7fea68531ed63f64cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Tue, 29 Mar 2022 18:35:03 +0200 Subject: [PATCH] genode_c_api/usb: report iface class and protocol Enrich the device report with interface class and protocol information for the current active setting of the device. Fixes #4463. --- repos/os/src/lib/genode_c_api/usb.cc | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/repos/os/src/lib/genode_c_api/usb.cc b/repos/os/src/lib/genode_c_api/usb.cc index 76d2b318fe..f6e4ff6a81 100644 --- a/repos/os/src/lib/genode_c_api/usb.cc +++ b/repos/os/src/lib/genode_c_api/usb.cc @@ -602,6 +602,40 @@ void ::Root::_report() xml.attribute("bus", Value(Hex(d.bus))); xml.attribute("dev", Value(Hex(d.dev))); xml.attribute("class", Value(Hex(d.cla))); + + Usb::Device_descriptor device_descr { }; + Usb::Config_descriptor config_descr { }; + + if (!_callbacks->cfg_desc_fn(d.bus, d.dev, + (void*) &device_descr, + &config_descr)) + return; + + for (unsigned idx = 0; idx < config_descr.num_interfaces; idx++) { + + int const num_altsetting = _callbacks->alt_settings_fn(d.bus, d.dev, idx); + if (num_altsetting < 0) + continue; + + for (int adx = 0; adx < num_altsetting; adx++) { + + int active = false; + Usb::Interface_descriptor iface_desc { }; + if (_callbacks->iface_desc_fn(d.bus, d.dev, idx, adx, + (void*) &iface_desc, + sizeof (Usb::Interface_descriptor), + &active)) + continue; + + if (!active) + continue; + + xml.node("interface", [&] { + xml.attribute("class", Value(Hex(iface_desc.iclass))); + xml.attribute("protocol", Value(Hex(iface_desc.iprotocol))); + }); + } + } }); }); });