mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +00:00
USB: Further Implement USB Structures
These are the actual structures that allow USB to work (i.e the ones actually defined in the specification). This should provide us enough of a baseline implementation that we can build on to support different types of USB device.
This commit is contained in:
parent
e044a3e428
commit
06f1edb516
16 changed files with 1037 additions and 89 deletions
58
Kernel/Devices/USB/USBDevice.h
Normal file
58
Kernel/Devices/USB/USBDevice.h
Normal file
|
@ -0,0 +1,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
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue