driver_manager: use componentized usb driver

Fixes #3943
This commit is contained in:
Alexander Boettcher 2020-11-06 13:23:26 +01:00 committed by Christian Helmuth
parent fae3c12366
commit 24181f2bf6
6 changed files with 62 additions and 41 deletions

View File

@ -1,7 +1,8 @@
_/src/platform_drv _/src/platform_drv
_/src/acpi_drv _/src/acpi_drv
_/src/ps2_drv _/src/ps2_drv
_/src/usb_drv _/src/usb_host_drv
_/src/usb_hid_drv
_/src/usb_block_drv _/src/usb_block_drv
_/src/vesa_drv _/src/vesa_drv
_/src/intel_fb_drv _/src/intel_fb_drv

View File

@ -15,6 +15,8 @@
<service name="Event"/> <service name="Event"/>
</parent-provides> </parent-provides>
<report child_caps="true" child_ram="true" init_caps="true" init_ram="true" delay_ms="5000"/>
<default-route> <default-route>
<any-service> <parent/> <any-child/> </any-service> <any-service> <parent/> <any-child/> </any-service>
</default-route> </default-route>
@ -44,6 +46,7 @@
<policy label="rom_reporter -> acpi" report="acpi_drv -> acpi"/> <policy label="rom_reporter -> acpi" report="acpi_drv -> acpi"/>
<policy label="rom_reporter -> pci_devices" report="platform_drv -> pci"/> <policy label="rom_reporter -> pci_devices" report="platform_drv -> pci"/>
<policy label="rom_reporter -> usb_devices" report="usb_drv -> devices"/> <policy label="rom_reporter -> usb_devices" report="usb_drv -> devices"/>
<policy label="usb_hid_drv -> report" report="usb_drv -> devices"/>
</config> </config>
</start> </start>
@ -121,15 +124,13 @@
</start> </start>
<start name="usb_drv" caps="200" priority="-1"> <start name="usb_drv" caps="200" priority="-1">
<binary name="x86_pc_usb_host_drv"/>
<resource name="RAM" quantum="16M"/> <resource name="RAM" quantum="16M"/>
<provides> <service name="Usb"/> </provides> <provides> <service name="Usb"/> </provides>
<route> <route>
<service name="Platform"> <child name="platform_drv"/> </service> <service name="Platform"> <child name="platform_drv"/> </service>
<service name="Event"> <child name="event_filter" label="usb"/> </service>
<service name="ROM" label="config"> <service name="ROM" label="config">
<child name="report_rom"/> </service> <child name="report_rom"/> </service>
<service name="ROM" label="capslock"> <parent label="capslock"/> </service>
<service name="ROM" label="numlock"> <parent label="numlock"/> </service>
<service name="Report" label="devices"> <child name="report_rom"/> </service> <service name="Report" label="devices"> <child name="report_rom"/> </service>
<service name="Report" label="config"> <parent label="usb_active_config"/> </service> <service name="Report" label="config"> <parent label="usb_active_config"/> </service>
<service name="ROM"> <parent/> </service> <service name="ROM"> <parent/> </service>
@ -141,6 +142,24 @@
</route> </route>
</start> </start>
<start name="usb_hid_drv" caps="140" priority="-1">
<resource name="RAM" quantum="11M"/>
<config use_report="yes" capslock_led="rom" numlock_led="rom"/>
<route>
<service name="ROM" label="report"> <child name="report_rom"/> </service>
<service name="ROM" label="capslock"> <parent label="capslock"/> </service>
<service name="ROM" label="numlock"> <parent label="numlock"/> </service>
<service name="ROM"> <parent/> </service>
<service name="PD"> <parent/> </service>
<service name="RM"> <parent/> </service>
<service name="CPU"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="Timer"> <parent/> </service>
<service name="Event"> <child name="event_filter" label="usb"/> </service>
<service name="Usb"> <child name="usb_drv"/> </service>
</route>
</start>
<start name="ps2_drv" priority="0"> <start name="ps2_drv" priority="0">
<resource name="RAM" quantum="1M"/> <resource name="RAM" quantum="1M"/>
<config capslock_led="rom" numlock_led="rom"/> <config capslock_led="rom" numlock_led="rom"/>

View File

@ -231,8 +231,8 @@ install_config {
</route> </route>
</start> </start>
<start name="drivers" caps="3100" priority="-1" managing_system="yes"> <start name="drivers" caps="3150" priority="-1" managing_system="yes">
<resource name="RAM" quantum="96M"/> <resource name="RAM" quantum="128M"/>
<binary name="init"/> <binary name="init"/>
<route> <route>
<service name="LOG"> <child name="log"/> </service> <service name="LOG"> <child name="log"/> </service>

View File

@ -659,45 +659,49 @@ void Driver_manager::Main::_generate_usb_drv_config(Reporter &usb_drv_config,
xml.attribute("xhci", true); xml.attribute("xhci", true);
xml.attribute("capslock_led", "rom"); xml.attribute("capslock_led", "rom");
xml.attribute("numlock_led", "rom"); xml.attribute("numlock_led", "rom");
xml.node("hid", [&] () { });
xml.node("raw", [&] () {
xml.node("report", [&] () { xml.attribute("devices", true); });
/* incorporate user-managed policy */ xml.node("report", [&] () { xml.attribute("devices", true); });
policy.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
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; /* usb hid drv gets all hid devices */
typedef String<32> Id; xml.node("policy", [&] () {
xml.attribute("label_prefix", "usb_hid_drv");
xml.attribute("class", "0x3");
});
Label const label = device.attribute_value("label", Label()); devices.for_each_sub_node("device", [&] (Xml_node device) {
Id const vendor_id = device.attribute_value("vendor_id", Id());
Id const product_id = device.attribute_value("product_id", Id());
/* typedef String<64> Label;
* Limit USB sessions to storage and vendor specific in order to avoid typedef String<32> Id;
* conflicts with the USB driver's built-in HID drivers.
*/
unsigned long const class_code = device.attribute_value("class", 0UL);
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); * Limit USB sessions to storage and vendor specific in order to avoid
if (!expose_as_usb_raw) * conflicts with the USB driver's built-in HID drivers.
return; */
unsigned long const class_code = device.attribute_value("class", 0UL);
xml.node("policy", [&] () { enum { USB_CLASS_MASS_STORAGE = 8, USB_CLASS_VENDOR_SPECIFIC = 0xff };
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 */ bool const expose_as_usb_raw = (class_code == USB_CLASS_MASS_STORAGE) ||
if (class_code == USB_CLASS_MASS_STORAGE) (class_code == USB_CLASS_VENDOR_SPECIFIC);
xml.attribute("class", "storage"); 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");
}); });
}); });
}); });

View File

@ -51,8 +51,7 @@ struct Sculpt::Storage_devices
{ {
usb_storage_devices.update_from_xml(policy, node); 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_present = false;
usb_storage_devices.for_each([&] (Storage_device const &) { usb_storage_devices.for_each([&] (Storage_device const &) {

View File

@ -36,10 +36,8 @@ void Sculpt::Storage::handle_storage_devices_update()
_usb_active_config_rom.update(); _usb_active_config_rom.update();
Usb_storage_device_update_policy policy(_env, _alloc, _storage_device_update_handler); Usb_storage_device_update_policy policy(_env, _alloc, _storage_device_update_handler);
Xml_node const config = _usb_active_config_rom.xml(); Xml_node const config = _usb_active_config_rom.xml();
Xml_node const raw = config.has_sub_node("raw")
? config.sub_node("raw") : Xml_node("<raw/>");
_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) if (policy.device_added_or_vanished)
reconfigure_runtime = true; reconfigure_runtime = true;