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