/* * Copyright (c) 2021, Luke Wilde * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Kernel::USB { class USBController : public AtomicRefCounted { public: virtual ~USBController() = default; virtual ErrorOr initialize() = 0; virtual ErrorOr reset() = 0; virtual ErrorOr stop() = 0; virtual ErrorOr start() = 0; virtual void cancel_async_transfer(NonnullLockRefPtr transfer) = 0; virtual ErrorOr submit_control_transfer(Transfer&) = 0; virtual ErrorOr submit_bulk_transfer(Transfer& transfer) = 0; virtual ErrorOr submit_async_interrupt_transfer(NonnullLockRefPtr transfer, u16 ms_interval) = 0; u32 storage_controller_id() const { return m_storage_controller_id; } u8 allocate_address(); protected: USBController(); private: // Note: We are pseudo storage controller for the sake of generating LUNs // And do not follow a hardware_relative_controller_id for the controller class "USB", // as we also have to follow the device id and its internal LUN, leaving no room for that u32 m_storage_controller_id { 0 }; u8 m_next_device_index { 1 }; IntrusiveListNode> m_controller_list_node; public: using List = IntrusiveList<&USBController::m_controller_list_node>; }; }