Kernel/USB: Refactor USB Pipe

Decompose the current monolithic USBD Pipe interface into several
subclasses, one for each pair of endpoint type & direction. This is to
make it more clear what data and functionality belongs to which Pipe
type, and prevent nonsensical things like trying to execute a control
transfer on a non-control pipe. This is important, because the Pipe
class is the interface by which USB device drivers will interact with
the HCD, so the clearer and more explicit this interface is the better.
This commit is contained in:
b14ckcat 2022-10-15 20:34:49 -04:00 committed by Andreas Kling
parent 1304575190
commit bf3c99ef23
Notes: sideshowbarker 2024-07-17 05:23:31 +09:00
6 changed files with 179 additions and 69 deletions

View file

@ -18,7 +18,7 @@ namespace Kernel::USB {
ErrorOr<NonnullLockRefPtr<Device>> Device::try_create(USBController const& controller, u8 port, DeviceSpeed speed)
{
auto pipe = TRY(Pipe::try_create_pipe(controller, Pipe::Type::Control, Pipe::Direction::Bidirectional, 0, 8, 0));
auto pipe = TRY(ControlPipe::create(controller, 0, 8, 0));
auto device = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Device(controller, port, speed, move(pipe))));
auto sysfs_node = TRY(SysFSUSBDeviceInformation::create(*device));
device->m_sysfs_device_info_node = move(sysfs_node);
@ -26,7 +26,7 @@ ErrorOr<NonnullLockRefPtr<Device>> Device::try_create(USBController const& contr
return device;
}
Device::Device(USBController const& controller, u8 port, DeviceSpeed speed, NonnullOwnPtr<Pipe> default_pipe)
Device::Device(USBController const& controller, u8 port, DeviceSpeed speed, NonnullOwnPtr<ControlPipe> default_pipe)
: m_device_port(port)
, m_device_speed(speed)
, m_address(0)
@ -35,7 +35,7 @@ Device::Device(USBController const& controller, u8 port, DeviceSpeed speed, Nonn
{
}
Device::Device(NonnullLockRefPtr<USBController> controller, u8 address, u8 port, DeviceSpeed speed, NonnullOwnPtr<Pipe> default_pipe)
Device::Device(NonnullLockRefPtr<USBController> controller, u8 address, u8 port, DeviceSpeed speed, NonnullOwnPtr<ControlPipe> default_pipe)
: m_device_port(port)
, m_device_speed(speed)
, m_address(address)
@ -44,7 +44,7 @@ Device::Device(NonnullLockRefPtr<USBController> controller, u8 address, u8 port,
{
}
Device::Device(Device const& device, NonnullOwnPtr<Pipe> default_pipe)
Device::Device(Device const& device, NonnullOwnPtr<ControlPipe> default_pipe)
: m_device_port(device.port())
, m_device_speed(device.speed())
, m_address(device.address())