forked from Bananymous/banan-os
Kernel: Remove support for custom xHCI speed_ids
This gets really weird with hubs and I don't think even linux handles them.
This commit is contained in:
@@ -340,15 +340,4 @@ namespace Kernel
|
||||
driver->handle_input_data(byte_count, endpoint_id);
|
||||
}
|
||||
|
||||
USB::SpeedClass USBDevice::determine_speed_class(uint64_t bits_per_second)
|
||||
{
|
||||
if (bits_per_second <= 1'500'000)
|
||||
return USB::SpeedClass::LowSpeed;
|
||||
if (bits_per_second <= 12'000'000)
|
||||
return USB::SpeedClass::FullSpeed;
|
||||
else if (bits_per_second <= 480'000'000)
|
||||
return USB::SpeedClass::HighSpeed;
|
||||
return USB::SpeedClass::SuperSpeed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -148,6 +148,8 @@ namespace Kernel
|
||||
|
||||
ASSERT(m_ports.size() == max_ports);
|
||||
|
||||
bool overrides_speed_ids = false;
|
||||
|
||||
{
|
||||
uint16_t ext_offset = capabilities.hccparams1.xhci_extended_capabilities_pointer;
|
||||
if (ext_offset == 0)
|
||||
@@ -159,11 +161,11 @@ namespace Kernel
|
||||
vaddr_t ext_addr = m_configuration_bar->vaddr() + ext_offset * 4;
|
||||
while (true)
|
||||
{
|
||||
auto& ext_cap = *reinterpret_cast<volatile XHCI::ExtendedCap*>(ext_addr);
|
||||
const auto& ext_cap = *reinterpret_cast<volatile XHCI::ExtendedCap*>(ext_addr);
|
||||
|
||||
if (ext_cap.capability_id == XHCI::ExtendedCapabilityID::SupportedProtocol)
|
||||
{
|
||||
auto& protocol = reinterpret_cast<volatile XHCI::SupportedPrococolCap&>(ext_cap);
|
||||
const auto& protocol = reinterpret_cast<const volatile XHCI::SupportedPrococolCap&>(ext_cap);
|
||||
|
||||
const uint32_t target_name_string {
|
||||
('U' << 0) |
|
||||
@@ -183,21 +185,15 @@ namespace Kernel
|
||||
return BAN::Error::from_errno(EFAULT);
|
||||
}
|
||||
|
||||
if (protocol.protocol_speed_id_count != 0)
|
||||
overrides_speed_ids = true;
|
||||
|
||||
for (size_t i = 0; i < protocol.compatible_port_count; i++)
|
||||
{
|
||||
auto& port = m_ports[protocol.compatible_port_offset + i - 1];
|
||||
port.revision_major = protocol.major_revision;
|
||||
port.revision_minor = protocol.minor_revision;
|
||||
port.slot_type = protocol.protocol_slot_type;
|
||||
|
||||
for (size_t j = 0; j < protocol.protocol_speed_id_count; j++)
|
||||
{
|
||||
uint32_t speed_info = reinterpret_cast<const volatile uint32_t*>(ext_addr + sizeof(XHCI::SupportedPrococolCap))[j];
|
||||
uint32_t port_speed = speed_info >> 16;
|
||||
for (size_t exp = 0; exp < ((speed_info >> 4) & 0x03); exp++)
|
||||
port_speed *= 1000;
|
||||
port.speed_id_to_speed[speed_info & 0x0F] = port_speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,6 +203,9 @@ namespace Kernel
|
||||
}
|
||||
}
|
||||
|
||||
if (overrides_speed_ids)
|
||||
dwarnln("xHCI overrides default speed ids, USB may not work");
|
||||
|
||||
// set max slots enabled
|
||||
auto& operational = operational_regs();
|
||||
operational.config.max_device_slots_enabled = capabilities.hcsparams1.max_slots;
|
||||
@@ -214,6 +213,30 @@ namespace Kernel
|
||||
return {};
|
||||
}
|
||||
|
||||
uint8_t XHCIController::speed_class_to_id(USB::SpeedClass speed_class) const
|
||||
{
|
||||
switch (speed_class)
|
||||
{
|
||||
case USB::SpeedClass::LowSpeed: return 2;
|
||||
case USB::SpeedClass::FullSpeed: return 1;
|
||||
case USB::SpeedClass::HighSpeed: return 3;
|
||||
case USB::SpeedClass::SuperSpeed: return 4;
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
USB::SpeedClass XHCIController::speed_id_to_class(uint8_t speed_id) const
|
||||
{
|
||||
switch (speed_id)
|
||||
{
|
||||
case 2: return USB::SpeedClass::LowSpeed;
|
||||
case 1: return USB::SpeedClass::FullSpeed;
|
||||
case 3: return USB::SpeedClass::HighSpeed;
|
||||
case 4: return USB::SpeedClass::SuperSpeed;
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> XHCIController::initialize_primary_interrupter()
|
||||
{
|
||||
TRY(m_pci_device.reserve_interrupts(1));
|
||||
|
||||
@@ -13,15 +13,8 @@ namespace Kernel
|
||||
return TRY(BAN::UniqPtr<XHCIDevice>::create(controller, port_id, slot_id));
|
||||
}
|
||||
|
||||
uint64_t XHCIDevice::calculate_port_bits_per_second(XHCIController& controller, uint32_t port_id)
|
||||
{
|
||||
const uint32_t portsc = controller.operational_regs().ports[port_id - 1].portsc;
|
||||
const uint32_t speed_id = (portsc >> XHCI::PORTSC::PORT_SPEED_SHIFT) & XHCI::PORTSC::PORT_SPEED_MASK;
|
||||
return controller.port(port_id).speed_id_to_speed[speed_id];
|
||||
}
|
||||
|
||||
XHCIDevice::XHCIDevice(XHCIController& controller, uint32_t port_id, uint32_t slot_id)
|
||||
: USBDevice(determine_speed_class(calculate_port_bits_per_second(controller, port_id)))
|
||||
: USBDevice(controller.speed_id_to_class((controller.operational_regs().ports[port_id - 1].portsc >> XHCI::PORTSC::PORT_SPEED_SHIFT) & XHCI::PORTSC::PORT_SPEED_MASK))
|
||||
, m_controller(controller)
|
||||
, m_port_id(port_id)
|
||||
, m_slot_id(slot_id)
|
||||
|
||||
Reference in New Issue
Block a user