From 24181f2bf6eb0f6652c1fe801518c39e4c490b95 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 6 Nov 2020 13:23:26 +0100 Subject: [PATCH] driver_manager: use componentized usb driver Fixes #3943 --- .../recipes/pkg/drivers_managed-pc/archives | 3 +- .../raw/drivers_managed-pc/drivers.config | 25 +++++++- repos/gems/run/sculpt.run | 4 +- repos/gems/src/app/driver_manager/main.cc | 64 ++++++++++--------- .../sculpt_manager/model/storage_devices.h | 3 +- repos/gems/src/app/sculpt_manager/storage.cc | 4 +- 6 files changed, 62 insertions(+), 41 deletions(-) diff --git a/repos/gems/recipes/pkg/drivers_managed-pc/archives b/repos/gems/recipes/pkg/drivers_managed-pc/archives index 3b2d9712b1..731eb056df 100644 --- a/repos/gems/recipes/pkg/drivers_managed-pc/archives +++ b/repos/gems/recipes/pkg/drivers_managed-pc/archives @@ -1,7 +1,8 @@ _/src/platform_drv _/src/acpi_drv _/src/ps2_drv -_/src/usb_drv +_/src/usb_host_drv +_/src/usb_hid_drv _/src/usb_block_drv _/src/vesa_drv _/src/intel_fb_drv diff --git a/repos/gems/recipes/raw/drivers_managed-pc/drivers.config b/repos/gems/recipes/raw/drivers_managed-pc/drivers.config index 2dfd804845..17da6f2a53 100644 --- a/repos/gems/recipes/raw/drivers_managed-pc/drivers.config +++ b/repos/gems/recipes/raw/drivers_managed-pc/drivers.config @@ -15,6 +15,8 @@ + + @@ -44,6 +46,7 @@ + @@ -121,15 +124,13 @@ + - - - @@ -141,6 +142,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/repos/gems/run/sculpt.run b/repos/gems/run/sculpt.run index 83088e3019..16f2335a94 100644 --- a/repos/gems/run/sculpt.run +++ b/repos/gems/run/sculpt.run @@ -231,8 +231,8 @@ install_config { - - + + diff --git a/repos/gems/src/app/driver_manager/main.cc b/repos/gems/src/app/driver_manager/main.cc index 7b9bfb3d64..348b334f6e 100644 --- a/repos/gems/src/app/driver_manager/main.cc +++ b/repos/gems/src/app/driver_manager/main.cc @@ -659,45 +659,49 @@ void Driver_manager::Main::_generate_usb_drv_config(Reporter &usb_drv_config, xml.attribute("xhci", true); xml.attribute("capslock_led", "rom"); xml.attribute("numlock_led", "rom"); - xml.node("hid", [&] () { }); - xml.node("raw", [&] () { - xml.node("report", [&] () { xml.attribute("devices", true); }); - /* incorporate user-managed policy */ - policy.with_raw_content([&] (char const *start, size_t length) { - xml.append(start, length); }); + xml.node("report", [&] () { xml.attribute("devices", true); }); - devices.for_each_sub_node("device", [&] (Xml_node device) { + /* incorporate user-managed policy */ + policy.with_raw_content([&] (char const *start, size_t length) { + xml.append(start, length); }); - typedef String<64> Label; - typedef String<32> Id; + /* usb hid drv gets all hid devices */ + xml.node("policy", [&] () { + xml.attribute("label_prefix", "usb_hid_drv"); + xml.attribute("class", "0x3"); + }); - Label const label = device.attribute_value("label", Label()); - Id const vendor_id = device.attribute_value("vendor_id", Id()); - Id const product_id = device.attribute_value("product_id", Id()); + devices.for_each_sub_node("device", [&] (Xml_node device) { - /* - * Limit USB sessions to storage and vendor specific in order to avoid - * conflicts with the USB driver's built-in HID drivers. - */ - unsigned long const class_code = device.attribute_value("class", 0UL); + typedef String<64> Label; + typedef String<32> Id; - enum { USB_CLASS_MASS_STORAGE = 8, USB_CLASS_VENDOR_SPECIFIC = 0xff }; + Label const label = device.attribute_value("label", Label()); + Id const vendor_id = device.attribute_value("vendor_id", Id()); + Id const product_id = device.attribute_value("product_id", Id()); - bool const expose_as_usb_raw = (class_code == USB_CLASS_MASS_STORAGE) || - (class_code == USB_CLASS_VENDOR_SPECIFIC); - if (!expose_as_usb_raw) - return; + /* + * Limit USB sessions to storage and vendor specific in order to avoid + * conflicts with the USB driver's built-in HID drivers. + */ + unsigned long const class_code = device.attribute_value("class", 0UL); - xml.node("policy", [&] () { - xml.attribute("label_suffix", label); - xml.attribute("vendor_id", vendor_id); - xml.attribute("product_id", product_id); + enum { USB_CLASS_MASS_STORAGE = 8, USB_CLASS_VENDOR_SPECIFIC = 0xff }; - /* annotate policy to make storage devices easy to spot */ - if (class_code == USB_CLASS_MASS_STORAGE) - xml.attribute("class", "storage"); - }); + bool const expose_as_usb_raw = (class_code == USB_CLASS_MASS_STORAGE) || + (class_code == USB_CLASS_VENDOR_SPECIFIC); + if (!expose_as_usb_raw) + return; + + xml.node("policy", [&] () { + xml.attribute("label_suffix", label); + xml.attribute("vendor_id", vendor_id); + xml.attribute("product_id", product_id); + + /* annotate policy to make storage devices easy to spot */ + if (class_code == USB_CLASS_MASS_STORAGE) + xml.attribute("class", "storage"); }); }); }); diff --git a/repos/gems/src/app/sculpt_manager/model/storage_devices.h b/repos/gems/src/app/sculpt_manager/model/storage_devices.h index ca69af954b..9da1188deb 100644 --- a/repos/gems/src/app/sculpt_manager/model/storage_devices.h +++ b/repos/gems/src/app/sculpt_manager/model/storage_devices.h @@ -51,8 +51,7 @@ struct Sculpt::Storage_devices { usb_storage_devices.update_from_xml(policy, node); - if (node.has_type("raw")) - _usb_active_config_valid = true; + _usb_active_config_valid = true; usb_present = false; usb_storage_devices.for_each([&] (Storage_device const &) { diff --git a/repos/gems/src/app/sculpt_manager/storage.cc b/repos/gems/src/app/sculpt_manager/storage.cc index 2563cb3f17..b0803afeb6 100644 --- a/repos/gems/src/app/sculpt_manager/storage.cc +++ b/repos/gems/src/app/sculpt_manager/storage.cc @@ -36,10 +36,8 @@ void Sculpt::Storage::handle_storage_devices_update() _usb_active_config_rom.update(); Usb_storage_device_update_policy policy(_env, _alloc, _storage_device_update_handler); Xml_node const config = _usb_active_config_rom.xml(); - Xml_node const raw = config.has_sub_node("raw") - ? config.sub_node("raw") : Xml_node(""); - _storage_devices.update_usb_storage_devices_from_xml(policy, raw); + _storage_devices.update_usb_storage_devices_from_xml(policy, config); if (policy.device_added_or_vanished) reconfigure_runtime = true;