blob: 8b08d9552df03d68728030f479a1ed196f1edf9d (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/OwnPtr.h>
#include <AK/Types.h>
#include <Kernel/Devices/USB/USBPipe.h>
namespace Kernel::USB {
//
// Some nice info from FTDI on device enumeration and how some of this
// glues together:
//
// https://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_113_Simplified%20Description%20of%20USB%20Device%20Enumeration.pdf
class Device {
public:
enum class PortNumber : u8 {
Port1 = 0,
Port2
};
enum class DeviceSpeed : u8 {
FullSpeed = 0,
LowSpeed
};
public:
static KResultOr<NonnullOwnPtr<Device>> try_create(PortNumber, DeviceSpeed);
static Device* get(PortNumber);
Device(PortNumber, DeviceSpeed, NonnullOwnPtr<Pipe> default_pipe);
~Device();
KResult enumerate();
PortNumber port() const { return m_device_port; }
DeviceSpeed speed() const { return m_device_speed; }
u8 address() const { return m_address; }
private:
private:
PortNumber m_device_port; // What port is this device attached to
DeviceSpeed m_device_speed; // What speed is this device running at
u8 m_address { 0 }; // USB address assigned to this device
// Device description
u16 m_vendor_id { 0 }; // This device's vendor ID assigned by the USB group
u16 m_product_id { 0 }; // This device's product ID assigned by the USB group
NonnullOwnPtr<Pipe> m_default_pipe; // Default communication pipe (endpoint0) used during enumeration
};
}
|