LibXenon
Bare-metal Xbox 360 homebrew library
Loading...
Searching...
No Matches
usb.h
Go to the documentation of this file.
1#ifndef __USB_H__
2#define __USB_H__
3
4#define USB_MAXPATH IPC_MAXPATH_LEN
5
6#define USB_OK 0
7#define USB_FAILED 1
8
9/* Descriptor types */
10#define USB_DT_DEVICE 0x01
11#define USB_DT_CONFIG 0x02
12#define USB_DT_STRING 0x03
13#define USB_DT_INTERFACE 0x04
14#define USB_DT_ENDPOINT 0x05
15
16/* Standard requests */
17#define USB_REQ_GETSTATUS 0x00
18#define USB_REQ_CLEARFEATURE 0x01
19#define USB_REQ_SETFEATURE 0x03
20#define USB_REQ_SETADDRESS 0x05
21#define USB_REQ_GETDESCRIPTOR 0x06
22#define USB_REQ_SETDESCRIPTOR 0x07
23#define USB_REQ_GETCONFIG 0x08
24#define USB_REQ_SETCONFIG 0x09
25#define USB_REQ_GETINTERFACE 0x0a
26#define USB_REQ_SETINTERFACE 0x0b
27#define USB_REQ_SYNCFRAME 0x0c
28
29/* Descriptor sizes per descriptor type */
30#define USB_DT_DEVICE_SIZE 18
31#define USB_DT_CONFIG_SIZE 9
32#define USB_DT_INTERFACE_SIZE 9
33#define USB_DT_ENDPOINT_SIZE 7
34#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
35#define USB_DT_HUB_NONVAR_SIZE 7
36
37/* control message request type bitmask */
38#define USB_CTRLTYPE_DIR_HOST2DEVICE (0<<7)
39#define USB_CTRLTYPE_DIR_DEVICE2HOST (1<<7)
40#define USB_CTRLTYPE_TYPE_STANDARD (0<<5)
41#define USB_CTRLTYPE_TYPE_CLASS (1<<5)
42#define USB_CTRLTYPE_TYPE_VENDOR (2<<5)
43#define USB_CTRLTYPE_TYPE_RESERVED (3<<5)
44#define USB_CTRLTYPE_REC_DEVICE 0
45#define USB_CTRLTYPE_REC_INTERFACE 1
46#define USB_CTRLTYPE_REC_ENDPOINT 2
47#define USB_CTRLTYPE_REC_OTHER 3
48
49#define USB_FEATURE_ENDPOINT_HALT 0
50
51#define USB_ENDPOINT_IN 0x80
52#define USB_ENDPOINT_OUT 0x00
53
54
55#ifdef __cplusplus
56 extern "C" {
57#endif /* __cplusplus */
58# define ATTRIBUTE_PACKED __attribute__((packed))
59
60typedef struct _usbctrlrequest {
67
68typedef struct _usbendpointdesc
69{
77
78typedef struct _usbinterfacedesc
79{
93
94typedef struct _usbconfdesc
95{
106
107typedef struct _usbdevdesc
108{
125
126struct ehci_device;
127
128s32 USB_OpenDevice(const char *device,u16 vid,u16 pid,struct ehci_device **fd);
130
133
135
138
139s32 USB_ReadIntrMsg(struct ehci_device *fd,u8 bEndpoint,u16 wLength,void *rpData);
140
141s32 USB_ReadBlkMsg(struct ehci_device *fd,u8 bEndpoint,u16 wLength,void *rpData);
142
143s32 USB_ReadCtrlMsg(struct ehci_device *fd,u8 bmRequestType,u8 bmRequest,u16 wValue,u16 wIndex,u16 wLength,void *rpData);
144
145s32 USB_WriteIntrMsg(struct ehci_device *fd,u8 bEndpoint,u16 wLength,void *rpData);
146
147s32 USB_WriteBlkMsg(struct ehci_hcd * ehci,struct ehci_device *fd,u8 bEndpoint,u16 wLength,void *rpData);
148
149s32 USB_WriteCtrlMsg(struct ehci_hcd * ehci,struct ehci_device *fd,u8 bmRequestType,u8 bmRequest,u16 wValue,u16 wIndex,u16 wLength,void *rpData);
150
151s32 USB_GetConfiguration(struct ehci_hcd * ehci,struct ehci_device *fd, u8 *configuration);
152s32 USB_SetConfiguration(struct ehci_hcd * ehci,struct ehci_device *fd, u8 configuration);
153s32 USB_SetAlternativeInterface(struct ehci_hcd * ehci,struct ehci_device *fd, u8 interface, u8 alternateSetting);
154s32 USB_ClearHalt(struct ehci_hcd * ehci,struct ehci_device *fd, u8 endpointAddress);
155s32 USB_GetDeviceList(const char *devpath,void *descr_buffer,u8 num_descr,u8 b0,u8 *cnt_descr);
156
157/* alloc memory from the USB subsystem */
158void * USB_Alloc(int size);
159void USB_Free(void *ptr);
160
161#ifdef __cplusplus
162 }
163#endif /* __cplusplus */
164
165
166#endif
struct ehci_hcd * ehci
Definition: ehci.h:23
u32 ptr
Definition: iso9660.c:536
u32 size
Definition: iso9660.c:537
u8 bDescriptorType
Definition: usb.h:97
u8 bLength
Definition: usb.h:96
struct _usbinterfacedesc * interfaces
Definition: usb.h:104
u16 wTotalLength
Definition: usb.h:98
u8 bmAttributes
Definition: usb.h:102
u8 iConfiguration
Definition: usb.h:101
u8 bConfigurationValue
Definition: usb.h:100
u8 bMaxPower
Definition: usb.h:103
u8 bNumInterfaces
Definition: usb.h:99
u8 bRequest
Definition: usb.h:62
u8 bRequestType
Definition: usb.h:61
u16 wLength
Definition: usb.h:65
u16 wIndex
Definition: usb.h:64
u16 wValue
Definition: usb.h:63
u16 idProduct
Definition: usb.h:117
u8 bNumConfigurations
Definition: usb.h:122
u8 iProduct
Definition: usb.h:120
u8 bMaxPacketSize0
Definition: usb.h:115
struct _usbconfdesc * configurations
Definition: usb.h:123
u8 bDeviceProtocol
Definition: usb.h:114
u16 idVendor
Definition: usb.h:116
u16 bcdUSB
Definition: usb.h:111
u8 bDescriptorType
Definition: usb.h:110
u8 bDeviceSubClass
Definition: usb.h:113
u16 bcdDevice
Definition: usb.h:118
u8 bLength
Definition: usb.h:109
u8 iSerialNumber
Definition: usb.h:121
u8 bDeviceClass
Definition: usb.h:112
u8 iManufacturer
Definition: usb.h:119
u8 bDescriptorType
Definition: usb.h:71
u8 bLength
Definition: usb.h:70
u16 wMaxPacketSize
Definition: usb.h:74
u8 bInterval
Definition: usb.h:75
u8 bmAttributes
Definition: usb.h:73
u8 bEndpointAddress
Definition: usb.h:72
u8 extra_size
Definition: usb.h:90
u8 bInterfaceNumber
Definition: usb.h:82
u8 bNumEndpoints
Definition: usb.h:84
u8 iInterface
Definition: usb.h:88
u8 bInterfaceSubClass
Definition: usb.h:86
struct _usbendpointdesc * endpoints
Definition: usb.h:91
u8 * extra
Definition: usb.h:89
u8 bAlternateSetting
Definition: usb.h:83
u8 bInterfaceClass
Definition: usb.h:85
u8 bDescriptorType
Definition: usb.h:81
u8 bInterfaceProtocol
Definition: usb.h:87
int fd
Definition: ehci.h:53
Definition: ehci.h:75
void USB_FreeDescriptors(usb_devdesc *udd)
Definition: usb2.c:147
void USB_SuspendDevice(struct ehci_device *fd)
struct _usbendpointdesc usb_endpointdesc
s32 USB_GetDescriptors(struct ehci_hcd *ehci, struct ehci_device *fd, usb_devdesc *udd)
Definition: usb2.c:29
void USB_Free(void *ptr)
Definition: usb_os.c:121
void USB_ResumeDevice(struct ehci_device *fd)
s32 USB_GetDeviceList(const char *devpath, void *descr_buffer, u8 num_descr, u8 b0, u8 *cnt_descr)
s32 USB_ReadBlkMsg(struct ehci_device *fd, u8 bEndpoint, u16 wLength, void *rpData)
s32 USB_WriteIntrMsg(struct ehci_device *fd, u8 bEndpoint, u16 wLength, void *rpData)
s32 USB_ReadCtrlMsg(struct ehci_device *fd, u8 bmRequestType, u8 bmRequest, u16 wValue, u16 wIndex, u16 wLength, void *rpData)
void * USB_Alloc(int size)
Definition: usb_os.c:116
struct _usbinterfacedesc usb_interfacedesc
s32 USB_ReadIntrMsg(struct ehci_device *fd, u8 bEndpoint, u16 wLength, void *rpData)
struct _usbctrlrequest usbctrlrequest
struct _usbdevdesc usb_devdesc
s32 USB_CloseDevice(struct ehci_device **fd)
s32 USB_SetAlternativeInterface(struct ehci_hcd *ehci, struct ehci_device *fd, u8 interface, u8 alternateSetting)
Definition: usb2.c:205
s32 USB_ClearHalt(struct ehci_hcd *ehci, struct ehci_device *fd, u8 endpointAddress)
Definition: usb2.c:213
s32 USB_SetConfiguration(struct ehci_hcd *ehci, struct ehci_device *fd, u8 configuration)
Definition: usb2.c:201
s32 USB_WriteBlkMsg(struct ehci_hcd *ehci, struct ehci_device *fd, u8 bEndpoint, u16 wLength, void *rpData)
Definition: usb2.c:175
#define ATTRIBUTE_PACKED
Definition: usb.h:58
s32 USB_GetConfiguration(struct ehci_hcd *ehci, struct ehci_device *fd, u8 *configuration)
Definition: usb2.c:185
s32 USB_GetDeviceDescription(struct ehci_device *fd, usb_devdesc *devdesc)
s32 USB_OpenDevice(const char *device, u16 vid, u16 pid, struct ehci_device **fd)
s32 USB_WriteCtrlMsg(struct ehci_hcd *ehci, struct ehci_device *fd, u8 bmRequestType, u8 bmRequest, u16 wValue, u16 wIndex, u16 wLength, void *rpData)
Definition: usb2.c:180
struct _usbconfdesc usb_configurationdesc
#define pid
Definition: xenonsprs.h:6
uint8_t u8
8bit unsigned integer
Definition: xetypes.h:12
uint16_t u16
16bit unsigned integer
Definition: xetypes.h:13
int32_t s32
32bit signed integer
Definition: xetypes.h:19