Kernel: Pass xHCI device information in structs

This makes code more readable and extendable
This commit is contained in:
2025-02-06 22:33:45 +02:00
parent 63b15a8855
commit 7de689055c
4 changed files with 69 additions and 53 deletions

View File

@@ -46,7 +46,7 @@ namespace Kernel
void port_updater_task();
BAN::ErrorOr<uint8_t> initialize_slot(int port_index);
BAN::ErrorOr<uint8_t> initialize_device(uint32_t route_string, USB::SpeedClass speed_class);
void deinitialize_slot(uint8_t slot_id);
BAN::ErrorOr<XHCI::TRB> send_command(const XHCI::TRB&);

View File

@@ -30,8 +30,15 @@ namespace Kernel
void(XHCIDevice::*callback)(XHCI::TRB);
};
struct Info
{
USB::SpeedClass speed_class;
uint8_t slot_id;
uint32_t route_string;
};
public:
static BAN::ErrorOr<BAN::UniqPtr<XHCIDevice>> create(XHCIController&, uint32_t port_id, uint32_t slot_id);
static BAN::ErrorOr<BAN::UniqPtr<XHCIDevice>> create(XHCIController&, const Info& info);
BAN::ErrorOr<void> configure_endpoint(const USBEndpointDescriptor&) override;
BAN::ErrorOr<size_t> send_request(const USBDeviceRequest&, paddr_t buffer) override;
@@ -43,8 +50,9 @@ namespace Kernel
BAN::ErrorOr<void> initialize_control_endpoint() override;
private:
XHCIDevice(XHCIController& controller, uint32_t port_id, uint32_t slot_id);
XHCIDevice(XHCIController& controller, const Info& info);
~XHCIDevice();
BAN::ErrorOr<void> update_actual_max_packet_size();
void on_interrupt_or_bulk_endpoint_event(XHCI::TRB);
@@ -55,8 +63,7 @@ namespace Kernel
static constexpr uint32_t m_transfer_ring_trb_count = PAGE_SIZE / sizeof(XHCI::TRB);
XHCIController& m_controller;
const uint32_t m_port_id;
const uint32_t m_slot_id;
Info m_info;
Mutex m_mutex;