forked from Bananymous/banan-os
Kernel: Allow USB devices to handle STALL conditions
This commit is contained in:
@@ -328,6 +328,12 @@ namespace Kernel
|
||||
return BAN::move(configuration);
|
||||
}
|
||||
|
||||
void USBDevice::handle_stall(uint8_t endpoint_id)
|
||||
{
|
||||
for (auto& driver : m_class_drivers)
|
||||
driver->handle_stall(endpoint_id);
|
||||
}
|
||||
|
||||
void USBDevice::handle_input_data(size_t byte_count, uint8_t endpoint_id)
|
||||
{
|
||||
for (auto& driver : m_class_drivers)
|
||||
|
||||
@@ -272,6 +272,12 @@ namespace Kernel
|
||||
return BAN::move(result);
|
||||
}
|
||||
|
||||
void USBHIDDriver::handle_stall(uint8_t endpoint_id)
|
||||
{
|
||||
(void)endpoint_id;
|
||||
// FIXME: do something :)
|
||||
}
|
||||
|
||||
void USBHIDDriver::handle_input_data(size_t byte_count, uint8_t endpoint_id)
|
||||
{
|
||||
if (m_data_endpoint_id != endpoint_id)
|
||||
|
||||
@@ -169,6 +169,12 @@ namespace Kernel
|
||||
return static_cast<size_t>(bytes_recv);
|
||||
}
|
||||
|
||||
void USBMassStorageDriver::handle_stall(uint8_t endpoint_id)
|
||||
{
|
||||
(void)endpoint_id;
|
||||
// FIXME: do something :)
|
||||
}
|
||||
|
||||
void USBMassStorageDriver::handle_input_data(size_t byte_count, uint8_t endpoint_id)
|
||||
{
|
||||
if (endpoint_id != m_in_endpoint_id && endpoint_id != m_out_endpoint_id)
|
||||
|
||||
@@ -295,15 +295,19 @@ namespace Kernel
|
||||
void XHCIDevice::on_interrupt_or_bulk_endpoint_event(XHCI::TRB trb)
|
||||
{
|
||||
ASSERT(trb.trb_type == XHCI::TRBType::TransferEvent);
|
||||
|
||||
const uint32_t endpoint_id = trb.transfer_event.endpoint_id;
|
||||
auto& endpoint = m_endpoints[endpoint_id - 1];
|
||||
|
||||
if (trb.transfer_event.completion_code == 6)
|
||||
return handle_stall(endpoint_id);
|
||||
|
||||
if (trb.transfer_event.completion_code != 1 && trb.transfer_event.completion_code != 13)
|
||||
{
|
||||
dwarnln("Interrupt or bulk endpoint got transfer event with completion code {}", +trb.transfer_event.completion_code);
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t endpoint_id = trb.transfer_event.endpoint_id;
|
||||
auto& endpoint = m_endpoints[endpoint_id - 1];
|
||||
|
||||
const auto* transfer_trb_arr = reinterpret_cast<volatile XHCI::TRB*>(endpoint.transfer_ring->vaddr());
|
||||
const uint32_t transfer_trb_index = (trb.transfer_event.trb_pointer - endpoint.transfer_ring->paddr()) / sizeof(XHCI::TRB);
|
||||
const uint32_t original_len = transfer_trb_arr[transfer_trb_index].normal.trb_transfer_length;
|
||||
|
||||
Reference in New Issue
Block a user