sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
usbd.h
Go to the documentation of this file.
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7
# Licenced under Academic Free License version 2.0
8
# Review ps2sdk README & LICENSE files for further details.
9
*/
10
16
17
#ifndef __USBD_H__
18
#define __USBD_H__
19
20
#include <types.h>
21
#include <
irx.h
>
22
23
typedef
struct
24
{
25
u8 requesttype;
26
u8 request;
27
u16 value;
28
u16 index;
29
u16 length;
30
}
UsbDeviceRequest
;
31
32
typedef
void (*sceUsbdDoneCallback)(
int
result,
int
count
,
void
*arg);
33
34
typedef
struct
35
{
36
u8 bLength;
37
u8 bDescriptorType;
38
u8 bNbrPorts;
39
u8 wHubCharacteristicsLb;
40
u8 wHubCharacteristicsHb;
41
u8 bPwrOn2PwrGood;
42
u8 bHubContrCurrent;
43
u8 deviceRemovable[32];
// arbitrary number, depends on number of ports
44
}
UsbHubDescriptor
;
45
46
48
typedef
struct
_UsbDriver
49
{
50
struct
_UsbDriver
*next, *prev;
52
char
*
name
;
53
int (*probe)(
int
devID);
54
int (*connect)(
int
devID);
55
int (*disconnect)(
int
devID);
56
u32 reserved1;
57
u32 reserved2;
58
u32 reserved3;
59
u32 reserved4;
60
u32 reserved5;
61
void
*gp;
62
}
sceUsbdLddOps
;
63
64
typedef
struct
65
{
66
u8 bLength;
67
u8 bDescriptorType;
68
u16 bcdUSB;
69
u8 bDeviceClass;
70
u8 bDeviceSubClass;
71
u8 bDeviceProtocol;
72
u8 bMaxPacketSize0;
73
u16 idVendor;
74
u16 idProduct;
75
u16 bcdDevice;
76
u8 iManufacturer;
77
u8 iProduct;
78
u8 iSerialNumber;
79
u8 bNumConfigurations;
80
}
UsbDeviceDescriptor
;
81
82
typedef
struct
83
{
84
u8 bLength;
85
u8 bDescriptorType;
86
// u8 wTotalLengthLb;
87
// u8 wTotalLengthHb;
88
u16 wTotalLength;
// apparently we can expect this to be aligned, for some reason
89
u8 bNumInterfaces;
90
u8 bConfigurationValue;
91
u8 iConfiguration;
92
u8 bmAttributes;
93
u8 maxPower;
94
}
UsbConfigDescriptor
;
95
96
typedef
struct
97
{
98
u8 bLength;
99
u8 bDescriptorType;
100
u8 bInterfaceNumber;
101
u8 bAlternateSetting;
102
u8 bNumEndpoints;
103
u8 bInterfaceClass;
104
u8 bInterfaceSubClass;
105
u8 bInterfaceProtocol;
106
u8 iInterface;
107
}
UsbInterfaceDescriptor
;
108
109
typedef
struct
110
{
111
u8 bLength;
112
u8 bDescritorLength;
113
u8 bEndpointAddress;
114
u8 bmAttributes;
115
u8 wMaxPacketSizeLB;
116
u8 wMaxPacketSizeHB;
117
u8 bInterval;
118
}
UsbEndpointDescriptor
;
119
120
typedef
struct
121
{
122
u8 bLength;
123
u8 bDescriptorType;
124
u16 wData[1];
125
}
UsbStringDescriptor
;
126
127
typedef
struct
_usbHidDescriptorItem
128
{
129
u8 bDescriptorType;
130
u8 wDescriptorLengthLb;
131
u8 wDescriptorLengthHb;
132
} UsbHidDescriptorItem;
133
134
typedef
struct
_usbHidDescriptor
135
{
136
u8 bLength;
137
u8 bDescriptorType;
138
u16 bcdHID;
139
u8 bCountryCode;
140
u8 bNumDescriptors;
141
UsbHidDescriptorItem items[];
142
} UsbHidDescriptor;
143
144
typedef
struct
145
{
146
u16 bLength : 11;
147
u16 reserved : 1;
148
u16 PSW : 4;
149
}
sceUsbdIsochronousPswLen
;
150
151
#define USB_MAX_ISOCH_PACKETS 8
152
153
typedef
struct
154
{
155
void
*bBufStart;
156
u32 bRelStartFrame;
157
u32 bNumPackets;
158
sceUsbdIsochronousPswLen
Packets[USB_MAX_ISOCH_PACKETS];
159
}
sceUsbdMultiIsochronousRequest
;
160
161
typedef
void (*sceUsbdMultiIsochronousDoneCallback)(
int
result,
sceUsbdMultiIsochronousRequest
*req,
void
*arg);
162
163
/*
164
* Device and/or Interface Class codes
165
*/
166
#define USB_CLASS_PER_INTERFACE 0
/* for DeviceClass */
167
#define USB_CLASS_AUDIO 1
168
#define USB_CLASS_COMM 2
169
#define USB_CLASS_HID 3
170
#define USB_CLASS_PHYSICAL 5
171
#define USB_CLASS_PRINTER 7
172
#define USB_CLASS_MASS_STORAGE 8
173
#define USB_CLASS_HUB 9
174
#define USB_CLASS_DATA 10
175
#define USB_CLASS_APP_SPEC 0xfe
176
#define USB_CLASS_VENDOR_SPEC 0xff
177
178
/*
179
* USB types
180
*/
181
#define USB_TYPE_STANDARD (0x00 << 5)
182
#define USB_TYPE_CLASS (0x01 << 5)
183
#define USB_TYPE_VENDOR (0x02 << 5)
184
#define USB_TYPE_RESERVED (0x03 << 5)
185
186
/*
187
* USB recipients
188
*/
189
#define USB_RECIP_DEVICE 0x00
190
#define USB_RECIP_INTERFACE 0x01
191
#define USB_RECIP_ENDPOINT 0x02
192
#define USB_RECIP_OTHER 0x03
193
194
#define USB_ENDPOINT_XFER_CONTROL 0
195
#define USB_ENDPOINT_XFER_ISOC 1
196
#define USB_ENDPOINT_XFER_BULK 2
197
#define USB_ENDPOINT_XFER_INT 3
198
#define USB_ENDPOINT_XFERTYPE_MASK 3
199
200
#define USB_REQ_GET_REPORT 0x01
201
#define USB_REQ_GET_IDLE 0x02
202
#define USB_REQ_GET_PROTOCOL 0x03
203
#define USB_REQ_SET_REPORT 0x09
204
#define USB_REQ_SET_IDLE 0x0A
205
#define USB_REQ_SET_PROTOCOL 0x0B
206
207
/*
208
* USB directions
209
*/
210
#define USB_DIR_OUT 0
211
#define USB_DIR_IN 0x80
212
#define USB_ENDPOINT_DIR_MASK 0x80
213
214
#define USB_DT_DEVICE 1
215
#define USB_DT_CONFIG 2
216
#define USB_DT_STRING 3
217
#define USB_DT_INTERFACE 4
218
#define USB_DT_ENDPOINT 5
219
#define USB_DT_HUB 0x29
220
221
#define USB_CLASS_HUB 9
222
223
#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
224
#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
225
226
#define USB_REQ_GET_STATUS 0x00
227
#define USB_REQ_CLEAR_FEATURE 0x01
228
#define USB_REQ_SET_FEATURE 0x03
229
#define USB_REQ_SET_ADDRESS 0x05
230
#define USB_REQ_GET_DESCRIPTOR 0x06
231
#define USB_REQ_SET_DESCRIPTOR 0x07
232
#define USB_REQ_GET_CONFIGURATION 0x08
233
#define USB_REQ_SET_CONFIGURATION 0x09
234
#define USB_REQ_GET_INTERFACE 0x0A
235
#define USB_REQ_SET_INTERFACE 0x0B
236
#define USB_REQ_SYNCH_FRAME 0x0C
237
239
#define USB_RC_OK 0x000
241
#define USB_RC_CRC 0x001
243
#define USB_RC_BITSTUFF 0x002
245
#define USB_RC_TOGGLE 0x003
247
#define USB_RC_STALL 0x004
249
#define USB_RC_NORESPONSE 0x005
251
#define USB_RC_BADPID 0x006
253
#define USB_RC_WRONGPID 0x007
255
#define USB_RC_DATAOVER 0x008
257
#define USB_RC_DATAUNDER 0x009
259
#define USB_RC_BUFFOVER 0x00C
261
#define USB_RC_BUFFUNDER 0x00D
263
#define USB_RC_NOTACCESSED 0x00E
265
#define USB_RC_NOTACCESSED2 0x00F
266
268
#define USB_RC_BADDEV 0x101
270
#define USB_RC_BADPIPE 0x102
272
#define USB_RC_BADLENGTH 0x103
274
#define USB_RC_BADDRIVER 0x104
276
#define USB_RC_BADCONTEXT 0x105
277
#define USB_RC_BADALIGN 0x106
278
#define USB_RC_BADHUBDEPTH 0x107
279
281
#define USB_RC_ED 0x111
283
#define USB_RC_IOREQ 0x112
285
#define USB_RC_BADOPTION 0x113
286
288
#define USB_RC_BUSY 0x121
290
#define USB_RC_ABORTED 0x122
291
293
#define USB_RC_NOSUPPORT 0x131
295
#define USB_RC_UNKNOWN 0x132
296
297
extern
int
sceUsbdRegisterLdd(
sceUsbdLddOps
*driver);
298
extern
int
sceUsbdUnregisterLdd(
sceUsbdLddOps
*driver);
299
extern
void
*sceUsbdScanStaticDescriptor(
int
devId,
void
*data, u8 type);
300
extern
int
sceUsbdGetDeviceLocation(
int
devId, u8 *path);
301
extern
int
sceUsbdSetPrivateData(
int
devId,
void
*data);
302
extern
void
*sceUsbdGetPrivateData(
int
devId);
303
extern
int
sceUsbdOpenPipe(
int
devId,
UsbEndpointDescriptor
*desc);
304
extern
int
sceUsbdOpenPipeAligned(
int
devId,
UsbEndpointDescriptor
*desc);
305
extern
int
sceUsbdClosePipe(
int
id
);
306
extern
int
sceUsbdTransferPipe(
int
id
,
void
*data, u32 len,
void
*option, sceUsbdDoneCallback callback,
void
*cbArg);
307
308
extern
int
sceUsbdRegisterAutoloader(
sceUsbdLddOps
*drv);
// Arbitrarily named
309
extern
int
sceUsbdUnregisterAutoloader(
void
);
// Arbitrarily named
310
extern
int
sceUsbdChangeThreadPriority(
int
prio1,
int
prio2);
311
312
// These have been added in 1.2 export version
313
extern
int
sceUsbdGetReportDescriptor(
int
devId,
int
cfgNum,
int
ifNum,
void
**desc, u32 *len);
314
extern
int
sceUsbdMultiIsochronousTransfer(
int
pipeId,
sceUsbdMultiIsochronousRequest
*
request
, sceUsbdMultiIsochronousDoneCallback callback,
void
*cbArg);
315
316
// For backwards compatibility:
317
#define UsbCallbackProc sceUsbdDoneCallback
318
#define UsbDriver sceUsbdLddOps
319
#define UsbIsochronousPswLen sceUsbdIsochronousPswLen
320
#define UsbMultiIsochronousRequest sceUsbdMultiIsochronousRequest
321
#define UsbMultiIsochronousDoneCallback sceUsbdMultiIsochronousDoneCallback
322
#define UsbRegisterDriver sceUsbdRegisterLdd
323
#define UsbUnregisterDriver sceUsbdUnregisterLdd
324
#define UsbGetDeviceStaticDescriptor sceUsbdScanStaticDescriptor
325
#define UsbGetDeviceLocation sceUsbdGetDeviceLocation
326
#define UsbSetDevicePrivateData sceUsbdSetPrivateData
327
#define UsbGetDevicePrivateData sceUsbdGetPrivateData
328
#define UsbOpenEndpoint sceUsbdOpenPipe
329
#define UsbOpenEndpointAligned sceUsbdOpenPipeAligned
330
#define UsbCloseEndpoint sceUsbdClosePipe
331
#define UsbTransfer sceUsbdTransferPipe
332
#define UsbRegisterAutoloader sceUsbdRegisterAutoloader
333
#define UsbUnregisterAutoloader sceUsbdUnregisterAutoloader
334
#define UsbChangeThreadPriority sceUsbdChangeThreadPriority
335
#define UsbGetReportDescriptor sceUsbdGetReportDescriptor
336
#define UsbMultiIsochronousTransfer sceUsbdMultiIsochronousTransfer
337
338
#define usbd_IMPORTS_start DECLARE_IMPORT_TABLE(usbd, 1, 2)
339
#define usbd_IMPORTS_end END_IMPORT_TABLE
340
341
#define I_sceUsbdRegisterLdd DECLARE_IMPORT(4, sceUsbdRegisterLdd)
342
#define I_sceUsbdUnregisterLdd DECLARE_IMPORT(5, sceUsbdUnregisterLdd)
343
#define I_sceUsbdScanStaticDescriptor DECLARE_IMPORT(6, sceUsbdScanStaticDescriptor)
344
#define I_sceUsbdSetPrivateData DECLARE_IMPORT(7, sceUsbdSetPrivateData)
345
#define I_sceUsbdGetPrivateData DECLARE_IMPORT(8, sceUsbdGetPrivateData)
346
#define I_sceUsbdOpenPipe DECLARE_IMPORT(9, sceUsbdOpenPipe)
347
#define I_sceUsbdClosePipe DECLARE_IMPORT(10, sceUsbdClosePipe)
348
#define I_sceUsbdTransferPipe DECLARE_IMPORT(11, sceUsbdTransferPipe)
349
#define I_sceUsbdOpenPipeAligned DECLARE_IMPORT(12, sceUsbdOpenPipeAligned)
350
#define I_sceUsbdGetDeviceLocation DECLARE_IMPORT(13, sceUsbdGetDeviceLocation)
351
#define I_sceUsbdRegisterAutoloader DECLARE_IMPORT(14, sceUsbdRegisterAutoloader)
352
#define I_sceUsbdUnregisterAutoloader DECLARE_IMPORT(15, sceUsbdUnregisterAutoloader)
353
#define I_sceUsbdChangeThreadPriority DECLARE_IMPORT(16, sceUsbdChangeThreadPriority)
354
#define I_sceUsbdGetReportDescriptor DECLARE_IMPORT(17, sceUsbdGetReportDescriptor)
355
#define I_sceUsbdMultiIsochronousTransfer DECLARE_IMPORT(18, sceUsbdMultiIsochronousTransfer)
356
357
// For backwards compatibility:
358
#define I_UsbCallbackProc I_sceUsbdDoneCallback
359
#define I_UsbDriver I_sceUsbdLddOps
360
#define I_UsbIsochronousPswLen I_sceUsbdIsochronousPswLen
361
#define I_UsbMultiIsochronousRequest I_sceUsbdMultiIsochronousRequest
362
#define I_UsbMultiIsochronousDoneCallback I_sceUsbdMultiIsochronousDoneCallback
363
#define I_UsbRegisterDriver I_sceUsbdRegisterLdd
364
#define I_UsbUnregisterDriver I_sceUsbdUnregisterLdd
365
#define I_UsbGetDeviceStaticDescriptor I_sceUsbdScanStaticDescriptor
366
#define I_UsbGetDeviceLocation I_sceUsbdGetDeviceLocation
367
#define I_UsbSetDevicePrivateData I_sceUsbdSetPrivateData
368
#define I_UsbGetDevicePrivateData I_sceUsbdGetPrivateData
369
#define I_UsbOpenEndpoint I_sceUsbdOpenPipe
370
#define I_UsbOpenEndpointAligned I_sceUsbdOpenPipeAligned
371
#define I_UsbCloseEndpoint I_sceUsbdClosePipe
372
#define I_UsbTransfer I_sceUsbdTransferPipe
373
#define I_UsbRegisterAutoloader I_sceUsbdRegisterAutoloader
374
#define I_UsbUnregisterAutoloader I_sceUsbdUnregisterAutoloader
375
#define I_UsbChangeThreadPriority I_sceUsbdChangeThreadPriority
376
#define I_UsbGetReportDescriptor I_sceUsbdGetReportDescriptor
377
#define I_UsbMultiIsochronousTransfer I_sceUsbdMultiIsochronousTransfer
378
379
#endif
/* __USBD_H__ */
irx.h
UsbConfigDescriptor
Definition
usbd.h:83
UsbDeviceDescriptor
Definition
usbd.h:65
UsbDeviceRequest
Definition
usbd.h:24
UsbEndpointDescriptor
Definition
usbd.h:110
UsbHubDescriptor
Definition
usbd.h:35
UsbInterfaceDescriptor
Definition
usbd.h:97
UsbStringDescriptor
Definition
usbd.h:121
_UsbDriver
Definition
usbd.h:49
_UsbDriver::name
char * name
Definition
usbd.h:52
_usbHidDescriptorItem
Definition
usbd.h:128
_usbHidDescriptor
Definition
usbd.h:135
request
Definition
thread.c:18
sceUsbdIsochronousPswLen
Definition
usbd.h:145
sceUsbdMultiIsochronousRequest
Definition
usbd.h:154
sceUsbdLddOps
struct _UsbDriver sceUsbdLddOps
count
u32 count
start sector of fragmented bd/file
Definition
usbhdfsd-common.h:1
core
usbd
include
usbd.h
Generated by
1.18.0