1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 13:27:35 +00:00

Kernel: Use PCI/Definitions.h for PCI-USB controller magic numbers

This commit is contained in:
Hendiadyoin1 2023-09-11 18:22:05 +02:00 committed by Andrew Kaster
parent 693f3ad33e
commit e7012a9245
2 changed files with 27 additions and 12 deletions

View file

@ -199,6 +199,15 @@ enum class SubclassID {
USB = 0x03, USB = 0x03,
}; };
enum class USBProgIf {
UHCI = 0x00,
OHCI = 0x10,
EHCI = 0x20,
xHCI = 0x30,
None = 0x80,
Device = 0xFE
};
} }
AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, CapabilityID); 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_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, SerialBus::SubclassID);
AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, ProgrammingInterface); 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(u8, RevisionID);
AK_TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemID); AK_TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemID);
AK_TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemVendorID); AK_TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemVendorID);

View file

@ -8,6 +8,7 @@
#include <AK/Singleton.h> #include <AK/Singleton.h>
#include <Kernel/Boot/CommandLine.h> #include <Kernel/Boot/CommandLine.h>
#include <Kernel/Bus/PCI/API.h> #include <Kernel/Bus/PCI/API.h>
#include <Kernel/Bus/PCI/Definitions.h>
#include <Kernel/Bus/USB/UHCI/UHCIController.h> #include <Kernel/Bus/USB/UHCI/UHCIController.h>
#include <Kernel/Bus/USB/USBManagement.h> #include <Kernel/Bus/USB/USBManagement.h>
#include <Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.h> #include <Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.h>
@ -29,9 +30,13 @@ UNMAP_AFTER_INIT void USBManagement::enumerate_controllers()
return; return;
MUST(PCI::enumerate([this](PCI::DeviceIdentifier const& device_identifier) { 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; return;
if (device_identifier.prog_if().value() == 0x0) { auto progif = static_cast<PCI::SerialBus::USBProgIf>(device_identifier.prog_if().value());
using enum PCI::SerialBus::USBProgIf;
switch (progif) {
case UHCI:
if (kernel_command_line().disable_uhci_controller()) if (kernel_command_line().disable_uhci_controller())
return; return;
@ -39,23 +44,22 @@ UNMAP_AFTER_INIT void USBManagement::enumerate_controllers()
m_controllers.append(uhci_controller_or_error.release_value()); m_controllers.append(uhci_controller_or_error.release_value());
return; return;
} case OHCI:
if (device_identifier.prog_if().value() == 0x10) {
dmesgln("USBManagement: OHCI controller found at {} is not currently supported.", device_identifier.address()); dmesgln("USBManagement: OHCI controller found at {} is not currently supported.", device_identifier.address());
return; return;
} case EHCI:
if (device_identifier.prog_if().value() == 0x20) {
dmesgln("USBManagement: EHCI controller found at {} is not currently supported.", device_identifier.address()); dmesgln("USBManagement: EHCI controller found at {} is not currently supported.", device_identifier.address());
return; return;
} case xHCI:
if (device_identifier.prog_if().value() == 0x30) {
dmesgln("USBManagement: xHCI controller found at {} is not currently supported.", device_identifier.address()); dmesgln("USBManagement: xHCI controller found at {} is not currently supported.", device_identifier.address());
return; 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()); dmesgln("USBManagement: Unknown/unsupported controller at {} with programming interface 0x{:02x}", device_identifier.address(), device_identifier.prog_if().value());
})); }));
} }