summaryrefslogtreecommitdiff
path: root/Kernel/Bus/USB/USBController.h
blob: f5f8d561f8bee66cdb997460d01dbdee029b73e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Error.h>
#include <AK/RefCounted.h>
#include <Kernel/Bus/USB/USBDevice.h>
#include <Kernel/Bus/USB/USBTransfer.h>

namespace Kernel::USB {

class USBController : public RefCounted<USBController> {
public:
    virtual ~USBController() = default;

    virtual ErrorOr<void> initialize() = 0;

    virtual ErrorOr<void> reset() = 0;
    virtual ErrorOr<void> stop() = 0;
    virtual ErrorOr<void> start() = 0;

    virtual ErrorOr<size_t> submit_control_transfer(Transfer&) = 0;

    u8 allocate_address();

private:
    u8 m_next_device_index { 1 };

    IntrusiveListNode<USBController, NonnullRefPtr<USBController>> m_controller_list_node;

public:
    using List = IntrusiveList<&USBController::m_controller_list_node>;
};

}