PS2SDK
PS2 Homebrew Libraries
usbd.h File Reference
#include <types.h>
#include <irx.h>
+ Include dependency graph for usbd.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  UsbDeviceRequest
 
struct  UsbHubDescriptor
 
struct  _UsbDriver
 
struct  UsbDeviceDescriptor
 
struct  UsbConfigDescriptor
 
struct  UsbInterfaceDescriptor
 
struct  UsbEndpointDescriptor
 
struct  UsbStringDescriptor
 
struct  _usbHidDescriptorItem
 
struct  _usbHidDescriptor
 
struct  sceUsbdIsochronousPswLen
 
struct  sceUsbdMultiIsochronousRequest
 

Macros

#define USB_MAX_ISOCH_PACKETS   8
 
#define USB_CLASS_PER_INTERFACE   0 /* for DeviceClass */
 
#define USB_CLASS_AUDIO   1
 
#define USB_CLASS_COMM   2
 
#define USB_CLASS_HID   3
 
#define USB_CLASS_PHYSICAL   5
 
#define USB_CLASS_PRINTER   7
 
#define USB_CLASS_MASS_STORAGE   8
 
#define USB_CLASS_HUB   9
 
#define USB_CLASS_DATA   10
 
#define USB_CLASS_APP_SPEC   0xfe
 
#define USB_CLASS_VENDOR_SPEC   0xff
 
#define USB_TYPE_STANDARD   (0x00 << 5)
 
#define USB_TYPE_CLASS   (0x01 << 5)
 
#define USB_TYPE_VENDOR   (0x02 << 5)
 
#define USB_TYPE_RESERVED   (0x03 << 5)
 
#define USB_RECIP_DEVICE   0x00
 
#define USB_RECIP_INTERFACE   0x01
 
#define USB_RECIP_ENDPOINT   0x02
 
#define USB_RECIP_OTHER   0x03
 
#define USB_ENDPOINT_XFER_CONTROL   0
 
#define USB_ENDPOINT_XFER_ISOC   1
 
#define USB_ENDPOINT_XFER_BULK   2
 
#define USB_ENDPOINT_XFER_INT   3
 
#define USB_ENDPOINT_XFERTYPE_MASK   3
 
#define USB_REQ_GET_REPORT   0x01
 
#define USB_REQ_GET_IDLE   0x02
 
#define USB_REQ_GET_PROTOCOL   0x03
 
#define USB_REQ_SET_REPORT   0x09
 
#define USB_REQ_SET_IDLE   0x0A
 
#define USB_REQ_SET_PROTOCOL   0x0B
 
#define USB_DIR_OUT   0
 
#define USB_DIR_IN   0x80
 
#define USB_ENDPOINT_DIR_MASK   0x80
 
#define USB_DT_DEVICE   1
 
#define USB_DT_CONFIG   2
 
#define USB_DT_STRING   3
 
#define USB_DT_INTERFACE   4
 
#define USB_DT_ENDPOINT   5
 
#define USB_DT_HUB   0x29
 
#define USB_CLASS_HUB   9
 
#define USB_RT_HUB   (USB_TYPE_CLASS | USB_RECIP_DEVICE)
 
#define USB_RT_PORT   (USB_TYPE_CLASS | USB_RECIP_OTHER)
 
#define USB_REQ_GET_STATUS   0x00
 
#define USB_REQ_CLEAR_FEATURE   0x01
 
#define USB_REQ_SET_FEATURE   0x03
 
#define USB_REQ_SET_ADDRESS   0x05
 
#define USB_REQ_GET_DESCRIPTOR   0x06
 
#define USB_REQ_SET_DESCRIPTOR   0x07
 
#define USB_REQ_GET_CONFIGURATION   0x08
 
#define USB_REQ_SET_CONFIGURATION   0x09
 
#define USB_REQ_GET_INTERFACE   0x0A
 
#define USB_REQ_SET_INTERFACE   0x0B
 
#define USB_REQ_SYNCH_FRAME   0x0C
 
#define USB_RC_OK   0x000
 
#define USB_RC_CRC   0x001
 
#define USB_RC_BITSTUFF   0x002
 
#define USB_RC_TOGGLE   0x003
 
#define USB_RC_STALL   0x004
 
#define USB_RC_NORESPONSE   0x005
 
#define USB_RC_BADPID   0x006
 
#define USB_RC_WRONGPID   0x007
 
#define USB_RC_DATAOVER   0x008
 
#define USB_RC_DATAUNDER   0x009
 
#define USB_RC_BUFFOVER   0x00C
 
#define USB_RC_BUFFUNDER   0x00D
 
#define USB_RC_NOTACCESSED   0x00E
 
#define USB_RC_NOTACCESSED2   0x00F
 
#define USB_RC_BADDEV   0x101
 
#define USB_RC_BADPIPE   0x102
 
#define USB_RC_BADLENGTH   0x103
 
#define USB_RC_BADDRIVER   0x104
 
#define USB_RC_BADCONTEXT   0x105
 
#define USB_RC_BADALIGN   0x106
 
#define USB_RC_BADHUBDEPTH   0x107
 
#define USB_RC_ED   0x111
 
#define USB_RC_IOREQ   0x112
 
#define USB_RC_BADOPTION   0x113
 
#define USB_RC_BUSY   0x121
 
#define USB_RC_ABORTED   0x122
 
#define USB_RC_NOSUPPORT   0x131
 
#define USB_RC_UNKNOWN   0x132
 
#define UsbCallbackProc   sceUsbdDoneCallback
 
#define UsbDriver   sceUsbdLddOps
 
#define UsbIsochronousPswLen   sceUsbdIsochronousPswLen
 
#define UsbMultiIsochronousRequest   sceUsbdMultiIsochronousRequest
 
#define UsbMultiIsochronousDoneCallback   sceUsbdMultiIsochronousDoneCallback
 
#define UsbRegisterDriver   sceUsbdRegisterLdd
 
#define UsbUnregisterDriver   sceUsbdUnregisterLdd
 
#define UsbGetDeviceStaticDescriptor   sceUsbdScanStaticDescriptor
 
#define UsbGetDeviceLocation   sceUsbdGetDeviceLocation
 
#define UsbSetDevicePrivateData   sceUsbdSetPrivateData
 
#define UsbGetDevicePrivateData   sceUsbdGetPrivateData
 
#define UsbOpenEndpoint   sceUsbdOpenPipe
 
#define UsbOpenEndpointAligned   sceUsbdOpenPipeAligned
 
#define UsbCloseEndpoint   sceUsbdClosePipe
 
#define UsbTransfer   sceUsbdTransferPipe
 
#define UsbRegisterAutoloader   sceUsbdRegisterAutoloader
 
#define UsbUnregisterAutoloader   sceUsbdUnregisterAutoloader
 
#define UsbChangeThreadPriority   sceUsbdChangeThreadPriority
 
#define UsbGetReportDescriptor   sceUsbdGetReportDescriptor
 
#define UsbMultiIsochronousTransfer   sceUsbdMultiIsochronousTransfer
 
#define usbd_IMPORTS_start   DECLARE_IMPORT_TABLE(usbd, 1, 2)
 
#define usbd_IMPORTS_end   END_IMPORT_TABLE
 
#define I_sceUsbdRegisterLdd   DECLARE_IMPORT(4, sceUsbdRegisterLdd)
 
#define I_sceUsbdUnregisterLdd   DECLARE_IMPORT(5, sceUsbdUnregisterLdd)
 
#define I_sceUsbdScanStaticDescriptor   DECLARE_IMPORT(6, sceUsbdScanStaticDescriptor)
 
#define I_sceUsbdSetPrivateData   DECLARE_IMPORT(7, sceUsbdSetPrivateData)
 
#define I_sceUsbdGetPrivateData   DECLARE_IMPORT(8, sceUsbdGetPrivateData)
 
#define I_sceUsbdOpenPipe   DECLARE_IMPORT(9, sceUsbdOpenPipe)
 
#define I_sceUsbdClosePipe   DECLARE_IMPORT(10, sceUsbdClosePipe)
 
#define I_sceUsbdTransferPipe   DECLARE_IMPORT(11, sceUsbdTransferPipe)
 
#define I_sceUsbdOpenPipeAligned   DECLARE_IMPORT(12, sceUsbdOpenPipeAligned)
 
#define I_sceUsbdGetDeviceLocation   DECLARE_IMPORT(13, sceUsbdGetDeviceLocation)
 
#define I_sceUsbdRegisterAutoloader   DECLARE_IMPORT(14, sceUsbdRegisterAutoloader)
 
#define I_sceUsbdUnregisterAutoloader   DECLARE_IMPORT(15, sceUsbdUnregisterAutoloader)
 
#define I_sceUsbdChangeThreadPriority   DECLARE_IMPORT(16, sceUsbdChangeThreadPriority)
 
#define I_sceUsbdGetReportDescriptor   DECLARE_IMPORT(17, sceUsbdGetReportDescriptor)
 
#define I_sceUsbdMultiIsochronousTransfer   DECLARE_IMPORT(18, sceUsbdMultiIsochronousTransfer)
 
#define I_UsbCallbackProc   I_sceUsbdDoneCallback
 
#define I_UsbDriver   I_sceUsbdLddOps
 
#define I_UsbIsochronousPswLen   I_sceUsbdIsochronousPswLen
 
#define I_UsbMultiIsochronousRequest   I_sceUsbdMultiIsochronousRequest
 
#define I_UsbMultiIsochronousDoneCallback   I_sceUsbdMultiIsochronousDoneCallback
 
#define I_UsbRegisterDriver   I_sceUsbdRegisterLdd
 
#define I_UsbUnregisterDriver   I_sceUsbdUnregisterLdd
 
#define I_UsbGetDeviceStaticDescriptor   I_sceUsbdScanStaticDescriptor
 
#define I_UsbGetDeviceLocation   I_sceUsbdGetDeviceLocation
 
#define I_UsbSetDevicePrivateData   I_sceUsbdSetPrivateData
 
#define I_UsbGetDevicePrivateData   I_sceUsbdGetPrivateData
 
#define I_UsbOpenEndpoint   I_sceUsbdOpenPipe
 
#define I_UsbOpenEndpointAligned   I_sceUsbdOpenPipeAligned
 
#define I_UsbCloseEndpoint   I_sceUsbdClosePipe
 
#define I_UsbTransfer   I_sceUsbdTransferPipe
 
#define I_UsbRegisterAutoloader   I_sceUsbdRegisterAutoloader
 
#define I_UsbUnregisterAutoloader   I_sceUsbdUnregisterAutoloader
 
#define I_UsbChangeThreadPriority   I_sceUsbdChangeThreadPriority
 
#define I_UsbGetReportDescriptor   I_sceUsbdGetReportDescriptor
 
#define I_UsbMultiIsochronousTransfer   I_sceUsbdMultiIsochronousTransfer
 

Typedefs

typedef void(* sceUsbdDoneCallback) (int result, int count, void *arg)
 
typedef struct _UsbDriver sceUsbdLddOps
 
typedef struct _usbHidDescriptorItem UsbHidDescriptorItem
 
typedef struct _usbHidDescriptor UsbHidDescriptor
 
typedef void(* sceUsbdMultiIsochronousDoneCallback) (int result, sceUsbdMultiIsochronousRequest *req, void *arg)
 

Functions

int sceUsbdRegisterLdd (sceUsbdLddOps *driver)
 
int sceUsbdUnregisterLdd (sceUsbdLddOps *driver)
 
void * sceUsbdScanStaticDescriptor (int devId, void *data, u8 type)
 
int sceUsbdGetDeviceLocation (int devId, u8 *path)
 
int sceUsbdSetPrivateData (int devId, void *data)
 
void * sceUsbdGetPrivateData (int devId)
 
int sceUsbdOpenPipe (int devId, UsbEndpointDescriptor *desc)
 
int sceUsbdOpenPipeAligned (int devId, UsbEndpointDescriptor *desc)
 
int sceUsbdClosePipe (int id)
 
int sceUsbdTransferPipe (int id, void *data, u32 len, void *option, sceUsbdDoneCallback callback, void *cbArg)
 
int sceUsbdRegisterAutoloader (sceUsbdLddOps *drv)
 
int sceUsbdUnregisterAutoloader (void)
 
int sceUsbdChangeThreadPriority (int prio1, int prio2)
 
int sceUsbdGetReportDescriptor (int devId, int cfgNum, int ifNum, void **desc, u32 *len)
 
int sceUsbdMultiIsochronousTransfer (int pipeId, sceUsbdMultiIsochronousRequest *request, sceUsbdMultiIsochronousDoneCallback callback, void *cbArg)
 

Detailed Description

USB Driver function prototypes and constants.

Definition in file usbd.h.


Data Structure Documentation

◆ UsbDeviceRequest

struct UsbDeviceRequest

Definition at line 22 of file usbd.h.

Data Fields
u8 requesttype
u8 request
u16 value
u16 index
u16 length

◆ UsbHubDescriptor

struct UsbHubDescriptor

Definition at line 33 of file usbd.h.

Data Fields
u8 bLength
u8 bDescriptorType
u8 bNbrPorts
u8 wHubCharacteristicsLb
u8 wHubCharacteristicsHb
u8 bPwrOn2PwrGood
u8 bHubContrCurrent
u8 deviceRemovable[32]

◆ UsbDeviceDescriptor

struct UsbDeviceDescriptor

Definition at line 63 of file usbd.h.

Data Fields
u8 bLength
u8 bDescriptorType
u16 bcdUSB
u8 bDeviceClass
u8 bDeviceSubClass
u8 bDeviceProtocol
u8 bMaxPacketSize0
u16 idVendor
u16 idProduct
u16 bcdDevice
u8 iManufacturer
u8 iProduct
u8 iSerialNumber
u8 bNumConfigurations

◆ UsbConfigDescriptor

struct UsbConfigDescriptor

Definition at line 81 of file usbd.h.

Data Fields
u8 bLength
u8 bDescriptorType
u16 wTotalLength
u8 bNumInterfaces
u8 bConfigurationValue
u8 iConfiguration
u8 bmAttributes
u8 maxPower

◆ UsbInterfaceDescriptor

struct UsbInterfaceDescriptor

Definition at line 95 of file usbd.h.

Data Fields
u8 bLength
u8 bDescriptorType
u8 bInterfaceNumber
u8 bAlternateSetting
u8 bNumEndpoints
u8 bInterfaceClass
u8 bInterfaceSubClass
u8 bInterfaceProtocol
u8 iInterface

◆ UsbEndpointDescriptor

struct UsbEndpointDescriptor

Definition at line 108 of file usbd.h.

Data Fields
u8 bLength
u8 bDescritorLength
u8 bEndpointAddress
u8 bmAttributes
u8 wMaxPacketSizeLB
u8 wMaxPacketSizeHB
u8 bInterval

◆ UsbStringDescriptor

struct UsbStringDescriptor

Definition at line 119 of file usbd.h.

Data Fields
u8 bLength
u8 bDescriptorType
u16 wData[1]

◆ _usbHidDescriptorItem

struct _usbHidDescriptorItem

Definition at line 126 of file usbd.h.

Data Fields
u8 bDescriptorType
u8 wDescriptorLengthLb
u8 wDescriptorLengthHb

◆ _usbHidDescriptor

struct _usbHidDescriptor

Definition at line 133 of file usbd.h.

+ Collaboration diagram for _usbHidDescriptor:
Data Fields
u8 bLength
u8 bDescriptorType
u16 bcdHID
u8 bCountryCode
u8 bNumDescriptors
UsbHidDescriptorItem items[]

◆ sceUsbdIsochronousPswLen

struct sceUsbdIsochronousPswLen

Definition at line 143 of file usbd.h.

Data Fields
u16 bLength: 11
u16 reserved: 1
u16 PSW: 4

◆ sceUsbdMultiIsochronousRequest

struct sceUsbdMultiIsochronousRequest

Definition at line 152 of file usbd.h.

+ Collaboration diagram for sceUsbdMultiIsochronousRequest:
Data Fields
void * bBufStart
u32 bRelStartFrame
u32 bNumPackets
sceUsbdIsochronousPswLen Packets[USB_MAX_ISOCH_PACKETS]

Macro Definition Documentation

◆ USB_RC_OK

#define USB_RC_OK   0x000

No Error

Definition at line 238 of file usbd.h.

◆ USB_RC_CRC

#define USB_RC_CRC   0x001

Bad CRC

Definition at line 240 of file usbd.h.

◆ USB_RC_BITSTUFF

#define USB_RC_BITSTUFF   0x002

Bit Stuffing

Definition at line 242 of file usbd.h.

◆ USB_RC_TOGGLE

#define USB_RC_TOGGLE   0x003

Bad Direction Toggle

Definition at line 244 of file usbd.h.

◆ USB_RC_STALL

#define USB_RC_STALL   0x004

Endpoint Stalled

Definition at line 246 of file usbd.h.

◆ USB_RC_NORESPONSE

#define USB_RC_NORESPONSE   0x005

Device Is Not Responding

Definition at line 248 of file usbd.h.

◆ USB_RC_BADPID

#define USB_RC_BADPID   0x006

PID Check Failed

Definition at line 250 of file usbd.h.

◆ USB_RC_WRONGPID

#define USB_RC_WRONGPID   0x007

Unexpected PID

Definition at line 252 of file usbd.h.

◆ USB_RC_DATAOVER

#define USB_RC_DATAOVER   0x008

Data Overrun

Definition at line 254 of file usbd.h.

◆ USB_RC_DATAUNDER

#define USB_RC_DATAUNDER   0x009

Data Underrun

Definition at line 256 of file usbd.h.

◆ USB_RC_BUFFOVER

#define USB_RC_BUFFOVER   0x00C

Buffer Overrun

Definition at line 258 of file usbd.h.

◆ USB_RC_BUFFUNDER

#define USB_RC_BUFFUNDER   0x00D

Buffer Underrun

Definition at line 260 of file usbd.h.

◆ USB_RC_NOTACCESSED

#define USB_RC_NOTACCESSED   0x00E

Not Accessed

Definition at line 262 of file usbd.h.

◆ USB_RC_NOTACCESSED2

#define USB_RC_NOTACCESSED2   0x00F

Not Accessed

Definition at line 264 of file usbd.h.

◆ USB_RC_BADDEV

#define USB_RC_BADDEV   0x101

Invalid device ID

Definition at line 267 of file usbd.h.

◆ USB_RC_BADPIPE

#define USB_RC_BADPIPE   0x102

Invalid pipe ID

Definition at line 269 of file usbd.h.

◆ USB_RC_BADLENGTH

#define USB_RC_BADLENGTH   0x103

Invalid length

Definition at line 271 of file usbd.h.

◆ USB_RC_BADDRIVER

#define USB_RC_BADDRIVER   0x104

Invalid driver

Definition at line 273 of file usbd.h.

◆ USB_RC_BADCONTEXT

#define USB_RC_BADCONTEXT   0x105

Invalid context

Definition at line 275 of file usbd.h.

◆ USB_RC_ED

#define USB_RC_ED   0x111

No space for Endpoint Descriptor

Definition at line 280 of file usbd.h.

◆ USB_RC_IOREQ

#define USB_RC_IOREQ   0x112

No space for Input/Output Request

Definition at line 282 of file usbd.h.

◆ USB_RC_BADOPTION

#define USB_RC_BADOPTION   0x113

Bad Option

Definition at line 284 of file usbd.h.

◆ USB_RC_BUSY

#define USB_RC_BUSY   0x121

Device or Bus Busy

Definition at line 287 of file usbd.h.

◆ USB_RC_ABORTED

#define USB_RC_ABORTED   0x122

Operation Aborted

Definition at line 289 of file usbd.h.

◆ USB_RC_NOSUPPORT

#define USB_RC_NOSUPPORT   0x131

Unsupported Operation (not implemented)

Definition at line 292 of file usbd.h.

◆ USB_RC_UNKNOWN

#define USB_RC_UNKNOWN   0x132

Unknown Error (USBD.IRX doesn't know what went wrong)

Definition at line 294 of file usbd.h.

Typedef Documentation

◆ sceUsbdLddOps

typedef struct _UsbDriver sceUsbdLddOps

USB driver bus event listener structure