summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorb14ckcat <b14ckcat@protonmail.com>2022-10-24 19:28:27 -0400
committerAndrew Kaster <andrewdkaster@gmail.com>2022-11-12 09:08:02 -0700
commit9baa521b04258e7544c1848305156bfd9cbe3273 (patch)
treefe935d69bc5d719cf8a9b9e0b3324234569a8241 /Kernel
parent7400eb36406f1e26ae55751aaa4c175630969402 (diff)
downloadserenity-9baa521b04258e7544c1848305156bfd9cbe3273.zip
Kernel/USB: Use proper verbs for Pipe transfer methods
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Bus/USB/USBDevice.cpp10
-rw-r--r--Kernel/Bus/USB/USBHub.cpp10
-rw-r--r--Kernel/Bus/USB/USBPipe.cpp8
-rw-r--r--Kernel/Bus/USB/USBPipe.h8
4 files changed, 18 insertions, 18 deletions
diff --git a/Kernel/Bus/USB/USBDevice.cpp b/Kernel/Bus/USB/USBDevice.cpp
index 53a7f2a78e..a6e3531f8b 100644
--- a/Kernel/Bus/USB/USBDevice.cpp
+++ b/Kernel/Bus/USB/USBDevice.cpp
@@ -62,7 +62,7 @@ ErrorOr<void> Device::enumerate_device()
// Send 8-bytes to get at least the `max_packet_size` from the device
constexpr u8 short_device_descriptor_length = 8;
- auto transfer_length = TRY(m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST, USB_REQUEST_GET_DESCRIPTOR, (DESCRIPTOR_TYPE_DEVICE << 8), 0, short_device_descriptor_length, &dev_descriptor));
+ auto transfer_length = TRY(m_default_pipe->submit_control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST, USB_REQUEST_GET_DESCRIPTOR, (DESCRIPTOR_TYPE_DEVICE << 8), 0, short_device_descriptor_length, &dev_descriptor));
// FIXME: This be "not equal to" instead of "less than", but control transfers report a higher transfer length than expected.
if (transfer_length < short_device_descriptor_length) {
@@ -85,7 +85,7 @@ ErrorOr<void> Device::enumerate_device()
VERIFY(dev_descriptor.descriptor_header.descriptor_type == DESCRIPTOR_TYPE_DEVICE);
m_default_pipe->set_max_packet_size(dev_descriptor.max_packet_size);
- transfer_length = TRY(m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST, USB_REQUEST_GET_DESCRIPTOR, (DESCRIPTOR_TYPE_DEVICE << 8), 0, sizeof(USBDeviceDescriptor), &dev_descriptor));
+ transfer_length = TRY(m_default_pipe->submit_control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST, USB_REQUEST_GET_DESCRIPTOR, (DESCRIPTOR_TYPE_DEVICE << 8), 0, sizeof(USBDeviceDescriptor), &dev_descriptor));
// FIXME: This be "not equal to" instead of "less than", but control transfers report a higher transfer length than expected.
if (transfer_length < sizeof(USBDeviceDescriptor)) {
@@ -108,7 +108,7 @@ ErrorOr<void> Device::enumerate_device()
auto new_address = m_controller->allocate_address();
// Attempt to set devices address on the bus
- transfer_length = TRY(m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE, USB_REQUEST_SET_ADDRESS, new_address, 0, 0, nullptr));
+ transfer_length = TRY(m_default_pipe->submit_control_transfer(USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE, USB_REQUEST_SET_ADDRESS, new_address, 0, 0, nullptr));
// This has to be set after we send out the "Set Address" request because it might be sent to the root hub.
// The root hub uses the address to intercept requests to itself.
@@ -123,7 +123,7 @@ ErrorOr<void> Device::enumerate_device()
m_configurations.ensure_capacity(m_device_descriptor.num_configurations);
for (auto configuration = 0u; configuration < m_device_descriptor.num_configurations; configuration++) {
USBConfigurationDescriptor configuration_descriptor;
- transfer_length = TRY(m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST, USB_REQUEST_GET_DESCRIPTOR, (DESCRIPTOR_TYPE_CONFIGURATION << 8u) | configuration, 0, sizeof(USBConfigurationDescriptor), &configuration_descriptor));
+ transfer_length = TRY(m_default_pipe->submit_control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST, USB_REQUEST_GET_DESCRIPTOR, (DESCRIPTOR_TYPE_CONFIGURATION << 8u) | configuration, 0, sizeof(USBConfigurationDescriptor), &configuration_descriptor));
if constexpr (USB_DEBUG) {
dbgln("USB Configuration Descriptor {}", configuration);
@@ -144,7 +144,7 @@ ErrorOr<void> Device::enumerate_device()
ErrorOr<size_t> Device::control_transfer(u8 request_type, u8 request, u16 value, u16 index, u16 length, void* data)
{
- return TRY(m_default_pipe->control_transfer(request_type, request, value, index, length, data));
+ return TRY(m_default_pipe->submit_control_transfer(request_type, request, value, index, length, data));
}
}
diff --git a/Kernel/Bus/USB/USBHub.cpp b/Kernel/Bus/USB/USBHub.cpp
index 629c00f299..297c9752e4 100644
--- a/Kernel/Bus/USB/USBHub.cpp
+++ b/Kernel/Bus/USB/USBHub.cpp
@@ -58,7 +58,7 @@ ErrorOr<void> Hub::enumerate_and_power_on_hub()
USBHubDescriptor descriptor {};
// Get the first hub descriptor. All hubs are required to have a hub descriptor at index 0. USB 2.0 Specification Section 11.24.2.5.
- auto transfer_length = TRY(m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS, HubRequest::GET_DESCRIPTOR, (DESCRIPTOR_TYPE_HUB << 8), 0, sizeof(USBHubDescriptor), &descriptor));
+ auto transfer_length = TRY(m_default_pipe->submit_control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS, HubRequest::GET_DESCRIPTOR, (DESCRIPTOR_TYPE_HUB << 8), 0, sizeof(USBHubDescriptor), &descriptor));
// FIXME: This be "not equal to" instead of "less than", but control transfers report a higher transfer length than expected.
if (transfer_length < sizeof(USBHubDescriptor)) {
@@ -78,7 +78,7 @@ ErrorOr<void> Hub::enumerate_and_power_on_hub()
// Enable all the ports
for (u8 port_index = 0; port_index < descriptor.number_of_downstream_ports; ++port_index) {
- auto result = m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_REQUEST_RECIPIENT_OTHER, HubRequest::SET_FEATURE, HubFeatureSelector::PORT_POWER, port_index + 1, 0, nullptr);
+ auto result = m_default_pipe->submit_control_transfer(USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_REQUEST_RECIPIENT_OTHER, HubRequest::SET_FEATURE, HubFeatureSelector::PORT_POWER, port_index + 1, 0, nullptr);
if (result.is_error())
dbgln("USB: Failed to power on port {} on hub at address {}.", port_index + 1, m_address);
}
@@ -98,7 +98,7 @@ ErrorOr<void> Hub::get_port_status(u8 port, HubStatus& hub_status)
if (port == 0 || port > m_hub_descriptor.number_of_downstream_ports)
return EINVAL;
- auto transfer_length = TRY(m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS | USB_REQUEST_RECIPIENT_OTHER, HubRequest::GET_STATUS, 0, port, sizeof(HubStatus), &hub_status));
+ auto transfer_length = TRY(m_default_pipe->submit_control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS | USB_REQUEST_RECIPIENT_OTHER, HubRequest::GET_STATUS, 0, port, sizeof(HubStatus), &hub_status));
// FIXME: This be "not equal to" instead of "less than", but control transfers report a higher transfer length than expected.
if (transfer_length < sizeof(HubStatus)) {
@@ -116,7 +116,7 @@ ErrorOr<void> Hub::clear_port_feature(u8 port, HubFeatureSelector feature_select
if (port == 0 || port > m_hub_descriptor.number_of_downstream_ports)
return EINVAL;
- TRY(m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_REQUEST_RECIPIENT_OTHER, HubRequest::CLEAR_FEATURE, feature_selector, port, 0, nullptr));
+ TRY(m_default_pipe->submit_control_transfer(USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_REQUEST_RECIPIENT_OTHER, HubRequest::CLEAR_FEATURE, feature_selector, port, 0, nullptr));
return {};
}
@@ -127,7 +127,7 @@ ErrorOr<void> Hub::set_port_feature(u8 port, HubFeatureSelector feature_selector
if (port == 0 || port > m_hub_descriptor.number_of_downstream_ports)
return EINVAL;
- TRY(m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_REQUEST_RECIPIENT_OTHER, HubRequest::SET_FEATURE, feature_selector, port, 0, nullptr));
+ TRY(m_default_pipe->submit_control_transfer(USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_REQUEST_RECIPIENT_OTHER, HubRequest::SET_FEATURE, feature_selector, port, 0, nullptr));
return {};
}
diff --git a/Kernel/Bus/USB/USBPipe.cpp b/Kernel/Bus/USB/USBPipe.cpp
index 9a97b6e608..088e7c5105 100644
--- a/Kernel/Bus/USB/USBPipe.cpp
+++ b/Kernel/Bus/USB/USBPipe.cpp
@@ -36,7 +36,7 @@ ControlPipe::ControlPipe(USBController const& controller, u8 endpoint_address, u
{
}
-ErrorOr<size_t> ControlPipe::control_transfer(u8 request_type, u8 request, u16 value, u16 index, size_t length, void* data)
+ErrorOr<size_t> ControlPipe::submit_control_transfer(u8 request_type, u8 request, u16 value, u16 index, size_t length, void* data)
{
VERIFY(length <= m_dma_buffer->size());
@@ -76,7 +76,7 @@ BulkInPipe::BulkInPipe(USBController const& controller, u8 endpoint_address, u16
{
}
-ErrorOr<size_t> BulkInPipe::bulk_in_transfer(size_t length, void* data)
+ErrorOr<size_t> BulkInPipe::submit_bulk_in_transfer(size_t length, void* data)
{
VERIFY(length <= m_dma_buffer->size());
@@ -107,7 +107,7 @@ BulkOutPipe::BulkOutPipe(USBController const& controller, u8 endpoint_address, u
{
}
-ErrorOr<size_t> BulkOutPipe::bulk_out_transfer(size_t length, void* data)
+ErrorOr<size_t> BulkOutPipe::submit_bulk_out_transfer(size_t length, void* data)
{
VERIFY(length <= m_dma_buffer->size());
@@ -137,7 +137,7 @@ InterruptInPipe::InterruptInPipe(USBController const& controller, u8 endpoint_ad
{
}
-ErrorOr<NonnullLockRefPtr<Transfer>> InterruptInPipe::interrupt_in_transfer(size_t length, u16 ms_interval, USBAsyncCallback callback)
+ErrorOr<NonnullLockRefPtr<Transfer>> InterruptInPipe::submit_interrupt_in_transfer(size_t length, u16 ms_interval, USBAsyncCallback callback)
{
VERIFY(length <= m_dma_buffer->size());
diff --git a/Kernel/Bus/USB/USBPipe.h b/Kernel/Bus/USB/USBPipe.h
index 6ccb6a205b..644138be38 100644
--- a/Kernel/Bus/USB/USBPipe.h
+++ b/Kernel/Bus/USB/USBPipe.h
@@ -83,7 +83,7 @@ class ControlPipe : public Pipe {
public:
static ErrorOr<NonnullOwnPtr<ControlPipe>> create(USBController const& controller, u8 endpoint_address, u16 max_packet_size, i8 device_address, size_t buffer_size = PAGE_SIZE);
- ErrorOr<size_t> control_transfer(u8 request_type, u8 request, u16 value, u16 index, size_t length, void* data);
+ ErrorOr<size_t> submit_control_transfer(u8 request_type, u8 request, u16 value, u16 index, size_t length, void* data);
private:
ControlPipe(USBController const& controller, u8 endpoint_address, u16 max_packet_size, i8 device_address, NonnullOwnPtr<Memory::Region> dma_buffer);
@@ -93,7 +93,7 @@ class BulkInPipe : public Pipe {
public:
static ErrorOr<NonnullOwnPtr<BulkInPipe>> create(USBController const& controller, u8 endpoint_address, u16 max_packet_size, i8 device_address, size_t buffer_size = PAGE_SIZE);
- ErrorOr<size_t> bulk_in_transfer(size_t length, void* data);
+ ErrorOr<size_t> submit_bulk_in_transfer(size_t length, void* data);
private:
BulkInPipe(USBController const& controller, u8 endpoint_address, u16 max_packet_size, i8 device_address, NonnullOwnPtr<Memory::Region> dma_buffer);
@@ -103,7 +103,7 @@ class BulkOutPipe : public Pipe {
public:
static ErrorOr<NonnullOwnPtr<BulkOutPipe>> create(USBController const& controller, u8 endpoint_address, u16 max_packet_size, i8 device_address, size_t buffer_size = PAGE_SIZE);
- ErrorOr<size_t> bulk_out_transfer(size_t length, void* data);
+ ErrorOr<size_t> submit_bulk_out_transfer(size_t length, void* data);
private:
BulkOutPipe(USBController const& controller, u8 endpoint_address, u16 max_packet_size, i8 device_address, NonnullOwnPtr<Memory::Region> dma_buffer);
@@ -113,7 +113,7 @@ class InterruptInPipe : public Pipe {
public:
static ErrorOr<NonnullOwnPtr<InterruptInPipe>> create(USBController const& controller, u8 endpoint_address, u16 max_packet_size, i8 device_address, u16 poll_interval, size_t buffer_size = PAGE_SIZE);
- ErrorOr<NonnullLockRefPtr<Transfer>> interrupt_in_transfer(size_t length, u16 ms_interval, USBAsyncCallback callback);
+ ErrorOr<NonnullLockRefPtr<Transfer>> submit_interrupt_in_transfer(size_t length, u16 ms_interval, USBAsyncCallback callback);
u16 poll_interval() const { return m_poll_interval; }