diff --git a/Kernel/Bus/PCI/Definitions.h b/Kernel/Bus/PCI/Definitions.h index 55bf83f11c..cdbe15a62d 100644 --- a/Kernel/Bus/PCI/Definitions.h +++ b/Kernel/Bus/PCI/Definitions.h @@ -199,6 +199,15 @@ enum class SubclassID { USB = 0x03, }; +enum class USBProgIf { + UHCI = 0x00, + OHCI = 0x10, + EHCI = 0x20, + xHCI = 0x30, + None = 0x80, + Device = 0xFE +}; + } AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, CapabilityID); @@ -336,6 +345,8 @@ AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, Base::SubclassID); AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, SerialBus::SubclassID); AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, ProgrammingInterface); +AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(ProgrammingInterface, SerialBus::USBProgIf); + AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, RevisionID); AK_TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemID); AK_TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemVendorID); diff --git a/Kernel/Bus/USB/USBManagement.cpp b/Kernel/Bus/USB/USBManagement.cpp index 07e5822532..0dea349094 100644 --- a/Kernel/Bus/USB/USBManagement.cpp +++ b/Kernel/Bus/USB/USBManagement.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -29,9 +30,13 @@ UNMAP_AFTER_INIT void USBManagement::enumerate_controllers() return; MUST(PCI::enumerate([this](PCI::DeviceIdentifier const& device_identifier) { - if (!(device_identifier.class_code().value() == 0xc && device_identifier.subclass_code().value() == 0x3)) + if (device_identifier.class_code() != PCI::ClassID::SerialBus + || device_identifier.subclass_code() != PCI::SerialBus::SubclassID::USB) return; - if (device_identifier.prog_if().value() == 0x0) { + auto progif = static_cast(device_identifier.prog_if().value()); + using enum PCI::SerialBus::USBProgIf; + switch (progif) { + case UHCI: if (kernel_command_line().disable_uhci_controller()) return; @@ -39,23 +44,22 @@ UNMAP_AFTER_INIT void USBManagement::enumerate_controllers() m_controllers.append(uhci_controller_or_error.release_value()); return; - } - - if (device_identifier.prog_if().value() == 0x10) { + case OHCI: dmesgln("USBManagement: OHCI controller found at {} is not currently supported.", device_identifier.address()); return; - } - - if (device_identifier.prog_if().value() == 0x20) { + case EHCI: dmesgln("USBManagement: EHCI controller found at {} is not currently supported.", device_identifier.address()); return; - } - - if (device_identifier.prog_if().value() == 0x30) { + case xHCI: dmesgln("USBManagement: xHCI controller found at {} is not currently supported.", device_identifier.address()); return; + case None: + dmesgln("USBManagement: Non interface-able controller found at {} is not currently supported.", device_identifier.address()); + return; + case Device: + dmesgln("USBManagement: Direct attached device at {} is not currently supported.", device_identifier.address()); + return; } - dmesgln("USBManagement: Unknown/unsupported controller at {} with programming interface 0x{:02x}", device_identifier.address(), device_identifier.prog_if().value()); })); }