Removed unnecessary structure packing.
[AROS.git] / compiler / include / devices / usbhardware.h
blob4408401298ab974843922985ac94353552375627
1 #ifndef DEVICES_USBHARDWARE_H
2 #define DEVICES_USBHARDWARE_H
3 /*
4 ** $VER: usbhardware.h 2.3 (22.12.2011)
5 **
6 ** standard usb hardware device include file
7 **
8 ** (C) Copyright 2002-2007 Chris Hodges
9 ** (C) Copyright 2011 AROS Development Team
10 ** All Rights Reserved
13 #ifndef EXEC_IO_H
14 #include "exec/io.h"
15 #endif
17 #ifndef EXEC_ERRORS_H
18 #include <exec/errors.h>
19 #endif
21 #ifndef DEVICES_USB_H
22 #include "devices/usb.h"
23 #endif
25 /* IO Request structure */
27 struct IOUsbHWReq
29 struct IORequest iouh_Req;
30 UWORD iouh_Flags; /* Transfer flags */
31 UWORD iouh_State; /* USB State Flags */
32 UWORD iouh_Dir; /* Direction of transfer */
33 UWORD iouh_DevAddr; /* USB Device Address (0-127) */
34 UWORD iouh_Endpoint; /* USB Device Endpoint (0-15) */
35 UWORD iouh_MaxPktSize; /* Maximum packet size for multiple packet transfers */
36 ULONG iouh_Actual; /* Actual bytes transferred */
37 ULONG iouh_Length; /* Size of buffer */
38 APTR iouh_Data; /* Pointer to in/out buffer */
39 UWORD iouh_Interval; /* Interrupt Interval (in ms or 125 µSec units) */
40 ULONG iouh_NakTimeout; /* Timeout in ms before request will be retired */
41 struct UsbSetupData iouh_SetupData; /* Setup fields for ctrl transfers */
42 APTR iouh_UserData; /* private data, may not be touched by hardware driver, do not make assumptions about its contents */
43 UWORD iouh_ExtError; /* Extended error code */
44 /* V2 structure extension */
45 UWORD iouh_Frame; /* current USB-Frame value and ISO start frame*/
46 UWORD iouh_SplitHubAddr; /* For Split-Transaction HUB address */
47 UWORD iouh_SplitHubPort; /* For Split-Transaction HUB downstream port */
48 APTR iouh_DriverPrivate1; /* private data for internal driver use */
49 APTR iouh_DriverPrivate2; /* private data for internal driver use */
52 /* Realtime ISO transfer structure as given in iouh_Data */
53 struct IOUsbHWRTIso
55 struct Node *urti_Node; /* Driver's linkage (private) */
56 struct Hook *urti_InReqHook; /* Called with struct IOUsbHWBufferReq whenever input data has arrived and is ready to be copied */
57 struct Hook *urti_OutReqHook; /* Called with struct IOUsbHWBufferReq to prepare output buffer copying */
58 struct Hook *urti_InDoneHook; /* Called with struct IOUsbHWBufferReq when input buffer has been copied */
59 struct Hook *urti_OutDoneHook; /* Called with struct IOUsbHWBufferReq when output buffer has been sent */
60 ULONG urti_OutPrefetch; /* Maximum prefetch in bytes allowed for output */
61 APTR urti_DriverPrivate1; /* private data for internal driver use */
62 APTR urti_DriverPrivate2; /* private data for internal driver use */
65 struct IOUsbHWBufferReq
67 UBYTE *ubr_Buffer; /* Pointer to buffer, filled by called function */
68 ULONG ubr_Length; /* Length of input received or output to be sent (may be adjusted by hook to force a partial copy) */
69 UWORD ubr_Frame; /* Frame number, filled by caller (may be adjusted by output hook) */
70 UWORD ubr_Flags; /* Flags, may be inspected and changed by hooks */
73 /* Definitions for ubr_Flags */
75 #define UBFB_CONTBUFFER 0 /* Set by InReqHook or OutReqHook to indicate that more buffer needs to be copied (scatter/gather) */
77 #define UBFF_CONTBUFFER (1<<UBFB_CONTBUFFER)
80 /* non-standard commands */
82 #define UHCMD_QUERYDEVICE (CMD_NONSTD+0)
83 #define UHCMD_USBRESET (CMD_NONSTD+1)
84 #define UHCMD_USBRESUME (CMD_NONSTD+2)
85 #define UHCMD_USBSUSPEND CMD_STOP
86 #define UHCMD_USBOPER CMD_START
87 #define UHCMD_CONTROLXFER (CMD_NONSTD+3)
88 #define UHCMD_ISOXFER (CMD_NONSTD+4)
89 #define UHCMD_INTXFER (CMD_NONSTD+5)
90 #define UHCMD_BULKXFER (CMD_NONSTD+6)
91 #define UHCMD_ADDISOHANDLER (CMD_NONSTD+7)
92 #define UHCMD_REMISOHANDLER (CMD_NONSTD+8)
93 #define UHCMD_STARTRTISO (CMD_NONSTD+9)
94 #define UHCMD_STOPRTISO (CMD_NONSTD+10)
96 /* Error codes for io_Error field */
98 #define UHIOERR_NO_ERROR 0 /* No error occured */
99 #define UHIOERR_USBOFFLINE 1 /* USB non-operational */
100 #define UHIOERR_NAK 2 /* NAK received */
101 #define UHIOERR_HOSTERROR 3 /* Unspecific host error */
102 #define UHIOERR_STALL 4 /* Endpoint stalled */
103 #define UHIOERR_PKTTOOLARGE 5 /* Packet is too large to be transferred */
104 #define UHIOERR_TIMEOUT 6 /* No acknoledge on packet */
105 #define UHIOERR_OVERFLOW 7 /* More data received than expected (babble condition) */
106 #define UHIOERR_CRCERROR 8 /* Incoming Packet corrupted */
107 #define UHIOERR_RUNTPACKET 9 /* Less data received than requested */
108 #define UHIOERR_NAKTIMEOUT 10 /* Timeout due to NAKs */
109 #define UHIOERR_BADPARAMS 11 /* Illegal parameters in request */
110 #define UHIOERR_OUTOFMEMORY 12 /* Out of auxiliary memory for the driver */
111 #define UHIOERR_BABBLE 13 /* Babble condition */
113 /* Values for iouh_Dir */
115 #define UHDIR_SETUP 0 /* This is a setup transfer (UHCMD_CTRLXFER) */
116 #define UHDIR_OUT 1 /* This is a host to device transfer */
117 #define UHDIR_IN 2 /* This is a device to host transfer */
119 /* Definitions for iouh_Flags */
120 #ifdef AROS_USB30_CODE
121 #define UHFB_LOWSPEED 0 /* Device operates at low speed */
122 #define UHFB_HIGHSPEED 1 /* Device operates at high speed (USB 2.0) */
123 #define UHFB_SUPERSPEED 2 /* Device operates at super speed (USB 3.0) */
124 #define UHFB_NOSHORTPKT 3 /* Inhibit sending of a short packet at the end of a transfer (if possible) */
125 #define UHFB_NAKTIMEOUT 4 /* Allow the request to time-out after the given timeout value */
126 #define UHFB_ALLOWRUNTPKTS 5 /* Receiving less data than expected will not cause an UHIOERR_RUNTPACKET */
127 #define UHFB_SPLITTRANS 6 /* new for V2.0: Split transaction for Lowspeed/Fullspeed devices at USB2.0 hubs */
128 #define UHFB_MULTI_1 7 /* new for V2.1: Number of transactions per microframe bit 0 */
129 #define UHFB_MULTI_2 8 /* new for V2.1: Number of transactions per microframe bit 1 */
130 #define UHFS_THINKTIME 9 /* new for V2.2: Bit times required at most for intertransaction gap on LS/FS */
132 #define UHFF_LOWSPEED (1<<UHFB_LOWSPEED)
133 #define UHFF_HIGHSPEED (1<<UHFB_HIGHSPEED)
134 #define UHFF_SUPERSPEED (1<<UHFB_SUPERSPEED)
135 #define UHFF_NOSHORTPKT (1<<UHFB_NOSHORTPKT)
136 #define UHFF_NAKTIMEOUT (1<<UHFB_NAKTIMEOUT)
137 #define UHFF_ALLOWRUNTPKTS (1<<UHFB_ALLOWRUNTPKTS)
138 #define UHFF_SPLITTRANS (1<<UHFB_SPLITTRANS)
139 #define UHFF_MULTI_1 (1<<UHFB_MULTI_1)
140 #define UHFF_MULTI_2 (1<<UHFB_MULTI_2)
141 #define UHFF_MULTI_3 ((1<<UHFB_MULTI_1)|(1<<UHFB_MULTI_2))
142 #define UHFF_THINKTIME_8 (0<<UHFS_THINKTIME)
143 #define UHFF_THINKTIME_16 (1<<UHFS_THINKTIME)
144 #define UHFF_THINKTIME_24 (2<<UHFS_THINKTIME)
145 #define UHFF_THINKTIME_32 (3<<UHFS_THINKTIME)
146 #else
147 #define UHFB_LOWSPEED 0 /* Device operates at low speed */
148 #define UHFB_HIGHSPEED 1 /* Device operates at high speed (USB 2.0) */
149 #define UHFB_NOSHORTPKT 2 /* Inhibit sending of a short packet at the end of a transfer (if possible) */
150 #define UHFB_NAKTIMEOUT 3 /* Allow the request to time-out after the given timeout value */
151 #define UHFB_ALLOWRUNTPKTS 4 /* Receiving less data than expected will not cause an UHIOERR_RUNTPACKET */
152 #define UHFB_SPLITTRANS 5 /* new for V2.0: Split transaction for Lowspeed/Fullspeed devices at USB2.0 hubs */
153 #define UHFB_MULTI_1 6 /* new for V2.1: Number of transactions per microframe bit 0 */
154 #define UHFB_MULTI_2 7 /* new for V2.1: Number of transactions per microframe bit 1 */
155 #define UHFS_THINKTIME 8 /* new for V2.2: Bit times required at most for intertransaction gap on LS/FS */
157 #define UHFF_LOWSPEED (1<<UHFB_LOWSPEED)
158 #define UHFF_HIGHSPEED (1<<UHFB_HIGHSPEED)
159 #define UHFF_NOSHORTPKT (1<<UHFB_NOSHORTPKT)
160 #define UHFF_NAKTIMEOUT (1<<UHFB_NAKTIMEOUT)
161 #define UHFF_ALLOWRUNTPKTS (1<<UHFB_ALLOWRUNTPKTS)
162 #define UHFF_SPLITTRANS (1<<UHFB_SPLITTRANS)
163 #define UHFF_MULTI_1 (1<<UHFB_MULTI_1)
164 #define UHFF_MULTI_2 (1<<UHFB_MULTI_2)
165 #define UHFF_MULTI_3 ((1<<UHFB_MULTI_1)|(1<<UHFB_MULTI_2))
166 #define UHFF_THINKTIME_8 (0<<UHFS_THINKTIME)
167 #define UHFF_THINKTIME_16 (1<<UHFS_THINKTIME)
168 #define UHFF_THINKTIME_24 (2<<UHFS_THINKTIME)
169 #define UHFF_THINKTIME_32 (3<<UHFS_THINKTIME)
170 #endif
172 /* Tags for UHCMD_QUERYDEVICE */
174 #define UHA_Dummy (TAG_USER + 0x4711)
175 #define UHA_State (UHA_Dummy + 0x01)
176 #define UHA_Manufacturer (UHA_Dummy + 0x10)
177 #define UHA_ProductName (UHA_Dummy + 0x11)
178 #define UHA_Version (UHA_Dummy + 0x12)
179 #define UHA_Revision (UHA_Dummy + 0x13)
180 #define UHA_Description (UHA_Dummy + 0x14)
181 #define UHA_Copyright (UHA_Dummy + 0x15)
182 #define UHA_DriverVersion (UHA_Dummy + 0x20)
183 #define UHA_Capabilities (UHA_Dummy + 0x21)
185 /* Capabilities as returned by UHA_Capabities */
186 #ifdef AROS_USB30_CODE
187 #define UHCB_USB20 0 /* Host controller supports USB 2.0 Highspeed */
188 #define UHCB_USB30 1 /* Host controller supports USB 3.0 SuperSpeed */
189 #define UHCB_ISO 2 /* Host controller driver supports ISO transfers (UHCMD_ISOXFER) */
190 #define UHCB_RT_ISO 3 /* Host controller driver supports real time ISO transfers (UHCMD_ADDISOHANDLER) */
191 #define UHCB_QUICKIO 4 /* BeginIO()/AbortIO() may be called from interrupts for less overhead */
193 #define UHCF_USB20 (1<<UHCB_USB20)
194 #define UHCF_USB30 (1<<UHCB_USB30)
195 #define UHCF_ISO (1<<UHCB_ISO)
196 #define UHCF_RT_ISO (1<<UHCB_RT_ISO)
197 #define UHCF_QUICKIO (1<<UHCB_QUICKIO)
198 #else
199 #define UHCB_USB20 0 /* Host controller supports USB 2.0 Highspeed */
200 #define UHCB_ISO 1 /* Host controller driver supports ISO transfers (UHCMD_ISOXFER) */
201 #define UHCB_RT_ISO 2 /* Host controller driver supports real time ISO transfers (UHCMD_ADDISOHANDLER) */
202 #define UHCB_QUICKIO 3 /* BeginIO()/AbortIO() may be called from interrupts for less overhead */
204 #define UHCF_USB20 (1<<UHCB_USB20)
205 #define UHCF_ISO (1<<UHCB_ISO)
206 #define UHCF_RT_ISO (1<<UHCB_RT_ISO)
207 #define UHCF_QUICKIO (1<<UHCB_QUICKIO)
208 #endif
210 /* Definitions for UHA_State/iouh_State */
212 #define UHSB_OPERATIONAL 0 /* USB can be used for transfers */
213 #define UHSB_RESUMING 1 /* USB is currently resuming */
214 #define UHSB_SUSPENDED 2 /* USB is in suspended state */
215 #define UHSB_RESET 3 /* USB is just inside a reset phase */
217 #define UHSF_OPERATIONAL (1<<UHSB_OPERATIONAL)
218 #define UHSF_RESUMING (1<<UHSB_RESUMING)
219 #define UHSF_SUSPENDED (1<<UHSB_SUSPENDED)
220 #define UHSF_RESET (1<<UHSB_RESET)
222 #endif /* DEVICES_USBHARDWARE_H */