XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
usb.h File Reference
#include <stdint.h>
#include "xhci.h"
Include dependency graph for usb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _dev_desc_
 
struct  _interface_desc_
 
struct  _qualifier_desc_
 
struct  _config_desc_
 
struct  _string_desc_
 
struct  _endpoint_desc_
 
struct  _usb_desc_
 
struct  _usb_dev_
 

Macros

#define USB_BM_REQUEST_OUTPUT   0
 
#define USB_BM_REQUEST_INPUT   0x80
 
#define USB_BM_REQUEST_STANDARD   0
 
#define USB_BM_REQUEST_CLASS   0x20
 
#define USB_BM_REQUEST_VENDOR   0x40
 
#define USB_BM_REQUEST_DEVICE   0
 
#define USB_BM_REQUEST_INTERFACE   1
 
#define USB_BM_REQUEST_ENDPOINT   2
 
#define USB_BM_REQUEST_OTHER   3
 
#define USB_BM_REQUEST_VENDORSPEC   0x1F
 
#define USB_BREQUEST_GET_STATUS   0
 
#define USB_BREQUEST_CLEAR_FEATURE   1
 
#define USB_BREQUEST_SET_FEATURE   3
 
#define USB_BREQUEST_SET_ADDRESS   5
 
#define USB_BREQUEST_GET_DESCRIPTOR   6
 
#define USB_BREQUEST_SET_DESCRIPTOR   7
 
#define USB_BREQUEST_GET_CONFIGURATION   8
 
#define USB_BREQUEST_SET_CONFIGURATION   9
 
#define USB_BREQUEST_GET_INTERFACE   10
 
#define USB_BREQUEST_SET_INTERFACE   11
 
#define USB_DESCRIPTOR_DEVICE   1
 
#define USB_DESCRIPTOR_CONFIGURATION   2
 
#define USB_DESCRIPTOR_STRING   3
 
#define USB_DESCRIPTOR_INTERFACE   4
 
#define USB_DESCRIPTOR_ENDPOINT   5
 
#define USB_DESCRIPTOR_SUPERSPEED_ENDP_CMP   48
 
#define USB_DESCRIPTOR_WVALUE(type, index)   ((type << 8) | index)
 
#define USB_AUDIO_DEV_CLASS   0x01
 
#define USB_COMMUNICATION_CDC_CTRL_CLASS   0x02
 
#define USB_HID_DEV_CLASS   0x03
 
#define USB_PHYSICAL_DEV_CLASS   0x05
 
#define USB_IMAGE_DEV_CLASS   0x06
 
#define USB_PRINTER_DEV_CLASS   0x07
 
#define USB_MASS_STORAGE_DEV_CLASS   0x08
 
#define USB_HUB_DEV_CLASS   0x09
 
#define USB_CDC_DATA_DEV_CLASS   0x0A
 
#define USB_SMART_CARD_DEV_CLASS   0x0B
 
#define USB_CONTENT_SECURITY_DEV_CLASS   0x0D
 
#define USB_VIDEO_DEV_CLASS   0x0E
 
#define USB_PERSONAL_HEALTHCARE_DEV_CLASS   0x0F
 
#define USB_AUDIO_VIDEO_DEV_CLASS   0x10
 
#define USB_BILLBOARD_DEV_CLASS   0x11
 
#define USB_TYPE_C_BRIDGE_CLASS   0x12
 
#define USB_I3C_DEV_CLASS   0x3C
 
#define USB_DIAGNOSTIC_DEV_CLASS   0xDC
 
#define USB_WIRELESS_CONTROLLER_DEV_CLASS   0xE0
 
#define USB_MISCELLANEOUS_DEV_CLASS   0xEF
 
#define ENDPOINT_TRANSFER_TYPE_CONTROL   0
 
#define ENDPOINT_TRANSFER_TYPE_ISOCH   1
 
#define ENDPOINT_TRANSFER_TYPE_BULK   2
 
#define ENDPOINT_TRANSFER_TYPE_INT   3
 

Typedefs

typedef struct _dev_desc_ usb_dev_desc_t
 
typedef struct _interface_desc_ usb_if_desc_t
 
typedef struct _qualifier_desc_ usb_qualifier_desc_t
 
typedef struct _config_desc_ usb_config_desc_t
 
typedef struct _string_desc_ usb_string_desc_t
 
typedef struct _endpoint_desc_ usb_endpoint_desc_t
 
typedef struct _usb_desc_ usb_descriptor_t
 
typedef int(* usb_drv_entry) (_usb_dev_ *dev)
 
typedef int(* usb_drv_unload) (_usb_dev_ *dev)
 
typedef struct _usb_dev_ AuUSBDevice
 

Functions

AuUSBDeviceUSBCreateDevice ()
 
void USBGetDeviceDesc (AuUSBDevice *usbdev, uint64_t buffer, uint16_t len)
 
void USBGetStringDesc (AuUSBDevice *usbdev, uint64_t buffer, uint16_t id)
 
void USBGetConfigDesc (AuUSBDevice *usbdev, uint64_t buffer, uint16_t len, uint8_t id)
 
void USBSetConfigDesc (AuUSBDevice *usbdev, uint8_t configval)
 
void USBScheduleInterrupt (AuUSBDevice *usbdev, void *ep, uint64_t physdata)
 
void USBDeviceSetFunctions (AuUSBDevice *dev)
 

Macro Definition Documentation

◆ ENDPOINT_TRANSFER_TYPE_BULK

#define ENDPOINT_TRANSFER_TYPE_BULK   2

◆ ENDPOINT_TRANSFER_TYPE_CONTROL

#define ENDPOINT_TRANSFER_TYPE_CONTROL   0

◆ ENDPOINT_TRANSFER_TYPE_INT

#define ENDPOINT_TRANSFER_TYPE_INT   3

◆ ENDPOINT_TRANSFER_TYPE_ISOCH

#define ENDPOINT_TRANSFER_TYPE_ISOCH   1

◆ USB_AUDIO_DEV_CLASS

#define USB_AUDIO_DEV_CLASS   0x01

◆ USB_AUDIO_VIDEO_DEV_CLASS

#define USB_AUDIO_VIDEO_DEV_CLASS   0x10

◆ USB_BILLBOARD_DEV_CLASS

#define USB_BILLBOARD_DEV_CLASS   0x11

◆ USB_BM_REQUEST_CLASS

#define USB_BM_REQUEST_CLASS   0x20

◆ USB_BM_REQUEST_DEVICE

#define USB_BM_REQUEST_DEVICE   0

◆ USB_BM_REQUEST_ENDPOINT

#define USB_BM_REQUEST_ENDPOINT   2

◆ USB_BM_REQUEST_INPUT

#define USB_BM_REQUEST_INPUT   0x80

◆ USB_BM_REQUEST_INTERFACE

#define USB_BM_REQUEST_INTERFACE   1

◆ USB_BM_REQUEST_OTHER

#define USB_BM_REQUEST_OTHER   3

◆ USB_BM_REQUEST_OUTPUT

#define USB_BM_REQUEST_OUTPUT   0

BSD 2-Clause License

Copyright (c) 2022-2025, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

◆ USB_BM_REQUEST_STANDARD

#define USB_BM_REQUEST_STANDARD   0

◆ USB_BM_REQUEST_VENDOR

#define USB_BM_REQUEST_VENDOR   0x40

◆ USB_BM_REQUEST_VENDORSPEC

#define USB_BM_REQUEST_VENDORSPEC   0x1F

◆ USB_BREQUEST_CLEAR_FEATURE

#define USB_BREQUEST_CLEAR_FEATURE   1

◆ USB_BREQUEST_GET_CONFIGURATION

#define USB_BREQUEST_GET_CONFIGURATION   8

◆ USB_BREQUEST_GET_DESCRIPTOR

#define USB_BREQUEST_GET_DESCRIPTOR   6

◆ USB_BREQUEST_GET_INTERFACE

#define USB_BREQUEST_GET_INTERFACE   10

◆ USB_BREQUEST_GET_STATUS

#define USB_BREQUEST_GET_STATUS   0

◆ USB_BREQUEST_SET_ADDRESS

#define USB_BREQUEST_SET_ADDRESS   5

◆ USB_BREQUEST_SET_CONFIGURATION

#define USB_BREQUEST_SET_CONFIGURATION   9

◆ USB_BREQUEST_SET_DESCRIPTOR

#define USB_BREQUEST_SET_DESCRIPTOR   7

◆ USB_BREQUEST_SET_FEATURE

#define USB_BREQUEST_SET_FEATURE   3

◆ USB_BREQUEST_SET_INTERFACE

#define USB_BREQUEST_SET_INTERFACE   11

◆ USB_CDC_DATA_DEV_CLASS

#define USB_CDC_DATA_DEV_CLASS   0x0A

◆ USB_COMMUNICATION_CDC_CTRL_CLASS

#define USB_COMMUNICATION_CDC_CTRL_CLASS   0x02

◆ USB_CONTENT_SECURITY_DEV_CLASS

#define USB_CONTENT_SECURITY_DEV_CLASS   0x0D

◆ USB_DESCRIPTOR_CONFIGURATION

#define USB_DESCRIPTOR_CONFIGURATION   2

◆ USB_DESCRIPTOR_DEVICE

#define USB_DESCRIPTOR_DEVICE   1

◆ USB_DESCRIPTOR_ENDPOINT

#define USB_DESCRIPTOR_ENDPOINT   5

◆ USB_DESCRIPTOR_INTERFACE

#define USB_DESCRIPTOR_INTERFACE   4

◆ USB_DESCRIPTOR_STRING

#define USB_DESCRIPTOR_STRING   3

◆ USB_DESCRIPTOR_SUPERSPEED_ENDP_CMP

#define USB_DESCRIPTOR_SUPERSPEED_ENDP_CMP   48

◆ USB_DESCRIPTOR_WVALUE

#define USB_DESCRIPTOR_WVALUE (   type,
  index 
)    ((type << 8) | index)

◆ USB_DIAGNOSTIC_DEV_CLASS

#define USB_DIAGNOSTIC_DEV_CLASS   0xDC

◆ USB_HID_DEV_CLASS

#define USB_HID_DEV_CLASS   0x03

◆ USB_HUB_DEV_CLASS

#define USB_HUB_DEV_CLASS   0x09

◆ USB_I3C_DEV_CLASS

#define USB_I3C_DEV_CLASS   0x3C

◆ USB_IMAGE_DEV_CLASS

#define USB_IMAGE_DEV_CLASS   0x06

◆ USB_MASS_STORAGE_DEV_CLASS

#define USB_MASS_STORAGE_DEV_CLASS   0x08

◆ USB_MISCELLANEOUS_DEV_CLASS

#define USB_MISCELLANEOUS_DEV_CLASS   0xEF

◆ USB_PERSONAL_HEALTHCARE_DEV_CLASS

#define USB_PERSONAL_HEALTHCARE_DEV_CLASS   0x0F

◆ USB_PHYSICAL_DEV_CLASS

#define USB_PHYSICAL_DEV_CLASS   0x05

◆ USB_PRINTER_DEV_CLASS

#define USB_PRINTER_DEV_CLASS   0x07

◆ USB_SMART_CARD_DEV_CLASS

#define USB_SMART_CARD_DEV_CLASS   0x0B

◆ USB_TYPE_C_BRIDGE_CLASS

#define USB_TYPE_C_BRIDGE_CLASS   0x12

◆ USB_VIDEO_DEV_CLASS

#define USB_VIDEO_DEV_CLASS   0x0E

◆ USB_WIRELESS_CONTROLLER_DEV_CLASS

#define USB_WIRELESS_CONTROLLER_DEV_CLASS   0xE0

Typedef Documentation

◆ AuUSBDevice

typedef struct _usb_dev_ AuUSBDevice

◆ usb_config_desc_t

◆ usb_descriptor_t

typedef struct _usb_desc_ usb_descriptor_t

◆ usb_dev_desc_t

typedef struct _dev_desc_ usb_dev_desc_t

◆ usb_drv_entry

typedef int(* usb_drv_entry) (_usb_dev_ *dev)

◆ usb_drv_unload

typedef int(* usb_drv_unload) (_usb_dev_ *dev)

◆ usb_endpoint_desc_t

◆ usb_if_desc_t

◆ usb_qualifier_desc_t

◆ usb_string_desc_t

Function Documentation

◆ USBCreateDevice()

AuUSBDevice * USBCreateDevice ( )
extern

BSD 2-Clause License

Copyright (c) 2022-2025, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

◆ USBDeviceSetFunctions()

void USBDeviceSetFunctions ( AuUSBDevice dev)
extern

◆ USBGetConfigDesc()

void USBGetConfigDesc ( AuUSBDevice usbdev,
uint64_t  buffer,
uint16_t  len,
uint8_t  id 
)
extern

◆ USBGetDeviceDesc()

void USBGetDeviceDesc ( AuUSBDevice usbdev,
uint64_t  buffer,
uint16_t  len 
)
extern

◆ USBGetStringDesc()

void USBGetStringDesc ( AuUSBDevice usbdev,
uint64_t  buffer,
uint16_t  id 
)
extern

◆ USBScheduleInterrupt()

void USBScheduleInterrupt ( AuUSBDevice usbdev,
void *  ep,
uint64_t  physdata 
)
extern

◆ USBSetConfigDesc()

void USBSetConfigDesc ( AuUSBDevice usbdev,
uint8_t  configval 
)
extern