Files
serenity/Kernel/Bus/USB/USBController.cpp
Sönke Holz 878d149ec9 Kernel/USB: Add a function to clear the endpoint halt condition
This is done by issuing a ClearFeature(ENDPOINT_HALT) request.
On xHCI, some extra steps are needed.
2024-09-25 14:41:23 -04:00

30 lines
777 B
C++

/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Bus/USB/USBController.h>
#include <Kernel/Bus/USB/USBRequest.h>
#include <Kernel/Devices/Storage/StorageManagement.h>
namespace Kernel::USB {
USBController::USBController()
: m_storage_controller_id(StorageManagement::generate_controller_id())
{
}
ErrorOr<void> USBController::reset_pipe(Device& device, Pipe& pipe)
{
if (pipe.type() == Pipe::Type::Control)
return {};
TRY(device.control_transfer(USB_REQUEST_TYPE_STANDARD | USB_REQUEST_RECIPIENT_ENDPOINT | USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE,
USB_REQUEST_CLEAR_FEATURE, USB_FEATURE_ENDPOINT_HALT, pipe.endpoint_address(), 0, nullptr));
return {};
}
}