1 /****************************************************************************
5 | | | | (o o)W () || ||
6 |__|_|_"| | / |Mw || ||//
9 _____ ___ ______ _____ __ _____ ___ __ __/~~__ ~~\ _||
10 |"(" \()/\" \ ()/"_ )|"(___) ) )|"(" \ ()/\" \(__)/" ) /" ) " \ /_)O
11 | ) )/" \ \ (_/"\__/ | )_ ( ( | )_ ) /" \ \ / /|/ / ·\ \/ ,|O
12 | (___/( (_\__) _\ \_ | (__) ) )| (__) |( (_\__)/ /"/ / |\ '_|O
13 | | _ \ / / /" \_/ ) | ")__ ( ( | )" ) \ / // /|/ / . .|/\__/ ||
14 |__| (_) \/__/ (______/ |_(___) )_)|_(___/ . \/__/(__/ (__/ .:.:| ||
16 |" __ \ Poseidon -- The divine USB stack for Amiga computers
17 | (__) ) Version: 4.3 (30.05.09)
18 | __ ( Designed and written by
19 |"(__) ) Chris Hodges <chrisly@platon42.de>
20 |_____/ Copyright ©2002-2009 Chris Hodges. All rights reserved.
22 ****************************************************************************/
25 *----------------------------------------------------------------------------
26 * Includes for poseidon.library
27 *----------------------------------------------------------------------------
28 * By Chris Hodges <chrisly@platon42.de>
32 #ifndef LIBRARIES_POSEIDON_H
33 #define LIBRARIES_POSEIDON_H
35 #include <devices/usbhardware.h>
36 #include <devices/timer.h>
37 #include <exec/types.h>
38 #include <exec/libraries.h>
39 #include <exec/semaphores.h>
40 #include <exec/errors.h>
42 #include <utility/tagitem.h>
43 #include <utility/pack.h>
44 #include <libraries/iffparse.h>
46 /* Types for psdGetAttrs() and psdSetAttrs() */
47 #define PGA_STACK 0x01
48 #define PGA_USBCLASS 0x02
49 #define PGA_HARDWARE 0x03
50 #define PGA_DEVICE 0x04
51 #define PGA_CONFIG 0x05
52 #define PGA_INTERFACE 0x06
53 #define PGA_ENDPOINT 0x07
54 #define PGA_ERRORMSG 0x08
56 #define PGA_APPBINDING 0x0a
57 #define PGA_EVENTNOTE 0x0b
58 #define PGA_STACKCFG 0x0c
59 #define PGA_PIPESTREAM 0x0d
60 #define PGA_DESCRIPTOR 0x0e
61 #define PGA_RTISO 0x0f
64 /* Tags for psdGetAttrs(PGA_STACK,...) */
65 #define PA_Dummy (TAG_USER + 2612)
66 #define PA_ConfigRead (PA_Dummy + 0x01)
67 #define PA_HardwareList (PA_Dummy + 0x20)
68 #define PA_ClassList (PA_Dummy + 0x21)
69 #define PA_ErrorMsgList (PA_Dummy + 0x22)
70 #define PA_GlobalConfig (PA_Dummy + 0x44)
71 #define PA_CurrConfigHash (PA_Dummy + 0x45)
72 #define PA_SavedConfigHash (PA_Dummy + 0x46)
73 #define PA_MemPoolUsage (PA_Dummy + 0x50)
74 #define PA_ReleaseVersion (PA_Dummy + 0x60)
75 #define PA_OSVersion (PA_Dummy + 0x61)
77 /* Tags for psdGetAttrs(PGA_ERRORMSG,...) */
78 #define EMA_Dummy (TAG_USER + 103)
79 #define EMA_Level (EMA_Dummy + 0x10)
80 #define EMA_Origin (EMA_Dummy + 0x11)
81 #define EMA_Msg (EMA_Dummy + 0x12)
82 #define EMA_DateStamp (EMA_Dummy + 0x13)
84 /* Tags for psdGetAttrs(PGA_USBCLASS,...) */
86 #define UCA_Dummy (TAG_USER + 4489)
87 #define UCA_ClassBase (UCA_Dummy + 0x10)
88 #define UCA_ClassName (UCA_Dummy + 0x11)
89 #define UCA_UseCount (UCA_Dummy + 0x12)
90 #define UCA_FullPath (UCA_Dummy + 0x13)
92 /* Tags for psdGetAttrs(PGA_HARDWARE,...) */
93 #define HA_Dummy (TAG_USER + 0x2612)
94 #define HA_DeviceName (HA_Dummy + 0x10)
95 #define HA_DeviceUnit (HA_Dummy + 0x11)
96 #define HA_ProductName (HA_Dummy + 0x12)
97 #define HA_Manufacturer (HA_Dummy + 0x13)
98 #define HA_Version (HA_Dummy + 0x14)
99 #define HA_Revision (HA_Dummy + 0x15)
100 #define HA_Description (HA_Dummy + 0x16)
101 #define HA_Copyright (HA_Dummy + 0x17)
102 #define HA_DriverVersion (HA_Dummy + 0x18)
103 #define HA_DeviceList (HA_Dummy + 0x20)
105 /* Tags for psdGetAttrs(PGA_DEVICE,...) */
106 #define DA_Dummy (TAG_USER + 42)
107 #define DA_IsLowspeed (DA_Dummy + 0x01)
108 #define DA_IsConnected (DA_Dummy + 0x02)
109 #define DA_HasAddress (DA_Dummy + 0x03)
110 #define DA_HasDevDesc (DA_Dummy + 0x04)
111 #define DA_IsConfigured (DA_Dummy + 0x05)
112 #define DA_HasAppBinding (DA_Dummy + 0x06)
113 #define DA_IsHighspeed (DA_Dummy + 0x07)
114 #define DA_IsDead (DA_Dummy + 0x08)
115 #define DA_Config (DA_Dummy + 0x09)
116 #define DA_IsSuspended (DA_Dummy + 0x0a)
117 #define DA_Address (DA_Dummy + 0x10)
118 #define DA_NumConfigs (DA_Dummy + 0x11)
119 #define DA_CurrConfig (DA_Dummy + 0x12)
120 #define DA_HubDevice (DA_Dummy + 0x13)
121 #define DA_UsbVersion (DA_Dummy + 0x14)
122 #define DA_Class (DA_Dummy + 0x15)
123 #define DA_SubClass (DA_Dummy + 0x16)
124 #define DA_Protocol (DA_Dummy + 0x17)
125 #define DA_Version (DA_Dummy + 0x18)
126 #define DA_VendorID (DA_Dummy + 0x19)
127 #define DA_ProductID (DA_Dummy + 0x1a)
128 #define DA_Manufacturer (DA_Dummy + 0x1b)
129 #define DA_ProductName (DA_Dummy + 0x1c)
130 #define DA_SerialNumber (DA_Dummy + 0x1d)
131 #define DA_Hardware (DA_Dummy + 0x1e)
132 #define DA_Binding (DA_Dummy + 0x1f)
133 #define DA_ConfigList (DA_Dummy + 0x20)
134 #define DA_LangIDArray (DA_Dummy + 0x21)
135 #define DA_CurrLangID (DA_Dummy + 0x22)
136 #define DA_BindingClass (DA_Dummy + 0x23)
137 #define DA_IDString (DA_Dummy + 0x24)
138 #define DA_CloneCount (DA_Dummy + 0x25)
139 #define DA_AtHubPortNumber (DA_Dummy + 0x26)
140 #define DA_NeedsSplitTrans (DA_Dummy + 0x27)
141 #define DA_OrigProductName (DA_Dummy + 0x28)
142 #define DA_DescriptorList (DA_Dummy + 0x29)
143 #define DA_MaxPktSize0 (DA_Dummy + 0x2a)
144 #define DA_HubThinkTime (DA_Dummy + 0x2b)
145 #define DA_PowerSupply (DA_Dummy + 0x30)
146 #define DA_PowerDrained (DA_Dummy + 0x31)
147 #define DA_LowPower (DA_Dummy + 0x32)
148 #define DA_InhibitPopup (DA_Dummy + 0x40)
149 #define DA_IsNewToMe (DA_Dummy + 0x41)
150 #define DA_InhibitClassBind (DA_Dummy + 0x42)
151 #define DA_OverridePowerInfo (DA_Dummy + 0x43)
152 #ifdef AROS_USB30_CODE
153 #define DA_IsSuperspeed (DA_Dummy + 0x44)
156 /* Tags for psdGetAttrs(PGA_CONFIG,...) */
157 #define CA_Dummy (TAG_USER + 23)
158 #define CA_Attrs (CA_Dummy + 0x01)
159 #define CA_SelfPowered (CA_Dummy + 0x02)
160 #define CA_RemoteWakeup (CA_Dummy + 0x03)
161 #define CA_ConfigNum (CA_Dummy + 0x10)
162 #define CA_MaxPower (CA_Dummy + 0x11)
163 #define CA_ConfigName (CA_Dummy + 0x12)
164 #define CA_NumInterfaces (CA_Dummy + 0x13)
165 #define CA_Device (CA_Dummy + 0x14)
166 #define CA_InterfaceList (CA_Dummy + 0x20)
168 /* Tags for psdGetAttrs(PGA_DESCRIPTOR,...) */
169 #define DDA_Dummy (TAG_USER + 888)
170 #define DDA_Device (DDA_Dummy + 0x01)
171 #define DDA_Config (DDA_Dummy + 0x02)
172 #define DDA_Interface (DDA_Dummy + 0x03)
173 #define DDA_Endpoint (DDA_Dummy + 0x04)
174 #define DDA_Name (DDA_Dummy + 0x08)
175 #define DDA_DescriptorType (DDA_Dummy + 0x10)
176 #define DDA_DescriptorData (DDA_Dummy + 0x11)
177 #define DDA_DescriptorLength (DDA_Dummy + 0x12)
178 #define DDA_CS_SubType (DDA_Dummy + 0x20)
180 /* Tags for psdGetAttrs(PGA_INTERFACE,...) */
181 #define IFA_Dummy (TAG_USER + 4711)
182 #define IFA_InterfaceNum (IFA_Dummy + 0x10)
183 #define IFA_AlternateNum (IFA_Dummy + 0x11)
184 #define IFA_Class (IFA_Dummy + 0x12)
185 #define IFA_SubClass (IFA_Dummy + 0x13)
186 #define IFA_Protocol (IFA_Dummy + 0x14)
187 #define IFA_InterfaceName (IFA_Dummy + 0x15)
188 #define IFA_Config (IFA_Dummy + 0x16)
189 #define IFA_Binding (IFA_Dummy + 0x17)
190 #define IFA_NumEndpoints (IFA_Dummy + 0x18)
191 #define IFA_BindingClass (IFA_Dummy + 0x19)
192 #define IFA_IDString (IFA_Dummy + 0x1a)
193 #define IFA_EndpointList (IFA_Dummy + 0x20)
194 #define IFA_AlternateIfList (IFA_Dummy + 0x21)
196 /* Tags for psdGetAttrs(PGA_ENDPOINT,...) */
197 #define EA_Dummy (TAG_USER + 1138)
198 #define EA_IsIn (EA_Dummy + 0x01)
199 #define EA_EndpointNum (EA_Dummy + 0x10)
200 #define EA_TransferType (EA_Dummy + 0x11)
201 #define EA_MaxPktSize (EA_Dummy + 0x12)
202 #define EA_Interval (EA_Dummy + 0x13)
203 #define EA_Interface (EA_Dummy + 0x14)
204 #define EA_NumTransMuFrame (EA_Dummy + 0x15)
205 #define EA_SyncType (EA_Dummy + 0x16)
206 #define EA_UsageType (EA_Dummy + 0x17)
208 /* Tags for psdGetAttrs(PGA_PIPE,...) */
209 #define PPA_Dummy (TAG_USER + 1234)
210 #define PPA_Endpoint (PPA_Dummy + 0x01)
211 #define PPA_Error (PPA_Dummy + 0x02)
212 #define PPA_Actual (PPA_Dummy + 0x03)
213 #define PPA_EndpointNum (PPA_Dummy + 0x04)
214 #define PPA_DeviceAddress (PPA_Dummy + 0x05)
215 #define PPA_IORequest (PPA_Dummy + 0x06)
216 #define PPA_NoZeroPktTerm (PPA_Dummy + 0x07)
217 #define PPA_NoShortPackets PPA_NoZeroPktTerm /* obsolete, bad naming */
218 #define PPA_NakTimeout (PPA_Dummy + 0x08)
219 #define PPA_NakTimeoutTime (PPA_Dummy + 0x09)
220 #define PPA_AllowRuntPackets (PPA_Dummy + 0x0a)
221 #define PPA_MaxPktSize (PPA_Dummy + 0x0b)
222 #define PPA_Interval (PPA_Dummy + 0x0c)
224 /* Tags for application binding and psdGetAttrs(PGA_APPBINDING,...)*/
225 #define ABA_Dummy (TAG_USER + 666)
226 #define ABA_ReleaseHook (ABA_Dummy + 0x01)
227 #define ABA_Device (ABA_Dummy + 0x02)
228 #define ABA_UserData (ABA_Dummy + 0x03)
229 #define ABA_Task (ABA_Dummy + 0x04)
230 #define ABA_ForceRelease (ABA_Dummy + 0x10)
232 /* Tags for psdGetAttrs(PGA_EVENTNOTE,...)*/
233 #define ENA_Dummy (TAG_USER + 777)
234 #define ENA_EventID (ENA_Dummy + 0x01)
235 #define ENA_Param1 (ENA_Dummy + 0x02)
236 #define ENA_Param2 (ENA_Dummy + 0x03)
238 /* Tags for psdGetAttrs(PGA_GLOBALCFG,...) */
239 #define GCA_Dummy (TAG_USER + 0x1138)
240 #define GCA_LogInfo (GCA_Dummy + 0x01)
241 #define GCA_LogWarning (GCA_Dummy + 0x02)
242 #define GCA_LogError (GCA_Dummy + 0x03)
243 #define GCA_LogFailure (GCA_Dummy + 0x04)
244 #define GCA_SubTaskPri (GCA_Dummy + 0x10)
245 #define GCA_BootDelay (GCA_Dummy + 0x11)
246 #define GCA_PopupDeviceNew (GCA_Dummy + 0x20)
247 #define GCA_PopupDeviceGone (GCA_Dummy + 0x21)
248 #define GCA_PopupDeviceDeath (GCA_Dummy + 0x22)
249 #define GCA_PopupCloseDelay (GCA_Dummy + 0x23)
250 #define GCA_PopupActivateWin (GCA_Dummy + 0x30)
251 #define GCA_PopupWinToFront (GCA_Dummy + 0x31)
252 #define GCA_InsertionSound (GCA_Dummy + 0x40)
253 #define GCA_RemovalSound (GCA_Dummy + 0x41)
254 #define GCA_AutoDisableLP (GCA_Dummy + 0x60)
255 #define GCA_AutoDisableDead (GCA_Dummy + 0x61)
256 #define GCA_AutoRestartDead (GCA_Dummy + 0x63)
257 #define GCA_PowerSaving (GCA_Dummy + 0x64)
258 #define GCA_ForceSuspend (GCA_Dummy + 0x65)
259 #define GCA_SuspendTimeout (GCA_Dummy + 0x66)
260 #define GCA_PrefsVersion (GCA_Dummy + 0x70)
262 /* Tags for psdGetAttrs(PGA_PIPESTREAM,...) */
263 #define PSA_Dummy (TAG_USER + 0x0409)
264 #define PSA_MessagePort (PSA_Dummy + 0x01)
265 #define PSA_AsyncIO (PSA_Dummy + 0x02)
266 #define PSA_NumPipes (PSA_Dummy + 0x03)
267 #define PSA_BufferSize (PSA_Dummy + 0x04)
268 #define PSA_ShortPktTerm (PSA_Dummy + 0x05)
269 #define PSA_ReadAhead (PSA_Dummy + 0x06)
270 #define PSA_BufferedRead (PSA_Dummy + 0x07)
271 #define PSA_BufferedWrite (PSA_Dummy + 0x08)
272 #define PSA_NoZeroPktTerm (PSA_Dummy + 0x09)
273 #define PSA_NakTimeout (PSA_Dummy + 0x0a)
274 #define PSA_NakTimeoutTime (PSA_Dummy + 0x0b)
275 #define PSA_AllowRuntPackets (PSA_Dummy + 0x0c)
276 #define PSA_TermArray (PSA_Dummy + 0x0d)
277 #define PSA_DoNotWait (PSA_Dummy + 0x0e)
278 #define PSA_AbortSigMask (PSA_Dummy + 0x0f)
279 #define PSA_BytesPending (PSA_Dummy + 0x10)
280 #define PSA_Error (PSA_Dummy + 0x11)
281 #define PSA_ActivePipe (PSA_Dummy + 0x12)
283 /* Tags for psdGetAttrs(PGA_RTISO,...) */
284 #define RTA_Dummy (TAG_USER + 999)
285 #define RTA_InRequestHook (RTA_Dummy + 0x01)
286 #define RTA_OutRequestHook (RTA_Dummy + 0x02)
287 #define RTA_InDoneHook (RTA_Dummy + 0x03)
288 #define RTA_OutDoneHook (RTA_Dummy + 0x04)
289 #define RTA_ReleaseHook (RTA_Dummy + 0x05)
290 #define RTA_OutPrefetchSize (RTA_Dummy + 0x10)
295 #define NTS_TRANSTYPE 3
296 #define NTS_VENDORID 4
297 #define NTS_CLASSCODE 5
298 #define NTS_DESCRIPTOR 6
299 #define NTS_SYNCTYPE 7
300 #define NTS_USAGETYPE 8
301 #define NTS_COMBOCLASS 9
303 /* NTS_COMBOCLASS flags */
304 #define NTSCCS_CLASS 0 /* Class field is bits 0-7 */
305 #define NTSCCS_SUBCLASS 8 /* Subclass field is bits 8-15 */
306 #define NTSCCS_PROTO 16 /* Protocol field is bits 16-24 */
307 #define NTSCCF_CLASS (1<<24) /* Class field is valid */
308 #define NTSCCF_SUBCLASS (1<<25) /* Subclass field is valid */
309 #define NTSCCF_PROTO (1<<26) /* Protocol field is valid */
311 /* Event Handler stuff */
312 #define EHMB_ADDHARDWARE 0x01 /* Param1 = phw */
313 #define EHMB_REMHARDWARE 0x02 /* Param1 = phw */
314 #define EHMB_ADDDEVICE 0x03 /* Param1 = pd */
315 #define EHMB_REMDEVICE 0x04 /* Param1 = pd */
316 #define EHMB_ADDCLASS 0x05 /* Param1 = puc */
317 #define EHMB_REMCLASS 0x06 /* Param1 = puc */
318 #define EHMB_ADDBINDING 0x07 /* Param1 = pd */
319 #define EHMB_REMBINDING 0x08 /* Param1 = pd */
320 #define EHMB_ADDERRORMSG 0x09 /* Param1 = pem */
321 #define EHMB_REMERRORMSG 0x0a /* Param1 = pem */
322 #define EHMB_CONFIGCHG 0x0b /* Param1 = void */
323 #define EHMB_DEVICEDEAD 0x0c /* Param1 = pd */
324 #define EHMB_DEVICELOWPW 0x0d /* Param1 = pd */
325 #define EHMB_DEVSUSPENDED 0x0e /* Param1 = pd */
326 #define EHMB_DEVRESUMED 0x0f /* Param1 = pd */
328 #define EHMF_ADDHARDWARE (1L<<EHMB_ADDHARDWARE)
329 #define EHMF_REMHARDWARE (1L<<EHMB_REMHARDWARE)
330 #define EHMF_ADDDEVICE (1L<<EHMB_ADDDEVICE)
331 #define EHMF_REMDEVICE (1L<<EHMB_REMDEVICE)
332 #define EHMF_ADDCLASS (1L<<EHMB_ADDCLASS)
333 #define EHMF_REMCLASS (1L<<EHMB_REMCLASS)
334 #define EHMF_ADDBINDING (1L<<EHMB_ADDBINDING)
335 #define EHMF_REMBINDING (1L<<EHMB_REMBINDING)
336 #define EHMF_ADDERRORMSG (1L<<EHMB_ADDERRORMSG)
337 #define EHMF_REMERRORMSG (1L<<EHMB_REMERRORMSG)
338 #define EHMF_CONFIGCHG (1L<<EHMB_CONFIGCHG)
339 #define EHMF_DEVICEDEAD (1L<<EHMB_DEVICEDEAD)
340 #define EHMF_DEVICELOWPW (1L<<EHMB_DEVICELOWPW)
341 #define EHMF_DEVSUSPENDED (1L<<EHMB_DEVSUSPENDED)
342 #define EHMF_DEVRESUMED (1L<<EHMB_DEVRESUMED)
344 /* Configuration stuff */
347 Configurations are stored in an IFF structure. It is managed by Trident
348 and the stack itself. Class drivers may only inject, delete or read out
349 certain sections of the configuration data. They either get pointer to the
350 FORM sections or return pointers to this FORM. The form data has to be
351 copied in each case (the length is given in the form).
353 The configuration normally looks like this:
354 FORM PSDC (Poseidon Config file)
356 [1*] FORM STKC (Stack config)
357 [n*] FORM UDEV (USB hardware device)
358 CHNK NAME [varlen] (device name)
361 [n*] FORM UCLS (USB class driver)
362 CHNK NAME [varlen] (library name)
364 [Chunks/Forms] (chunks containing some more data for the main stack file)
366 [n*] FORM CLSC (Class config)
367 CHNK OWNR [varlen] name of class which stores this data
368 FORM GCPD (global class private data) <- that's the form the class can modify
371 [n*] FORM DEVC (Device configurations)
372 CHNK DVID [varlen] DeviceID-String
373 CHNK FBND [varlen] <classname> (forced binding)
374 CHNK NAME [varlen] Custom name
375 [n*] FORM DCFG (Device configuration data)
376 CHNK OWNR [varlen] name of class for binding (AppName?)
377 FORM DCPD (device config private data) <- that's the form the class can modify
379 [n*] FORM ICFG (Interface configuration data)
380 CHNK OWNR [varlen] name of class for binding
381 CHNK IFID [varlen] InterfaceID-String
382 CHNK FBND [varlen] <classname> (forced binding)
383 FORM ICPD (interface config private data) <- that's the form the class can modify
385 psdReadCfg(pic, formdata):
386 pic == NULL; replace (!) root form with given formdata
387 pic != NULL; replace given pic with new form data.
389 pic == NULL; generate the whole configuration buffer to save
390 pic != NULL; generate the form buffer of the pic and its subform.
391 psdFindCfgForm(pic, formid)
392 pic == NULL -> pic = root form;
393 find and return pic with given form ID or NULL if no such form exists.
395 get next form pic with same ID or return NULL if this was the only form with this ID.
398 pic == NULL -> pic = root form;
399 delete form pic (effectly calls pFreeForm()).
401 psdAddCfgChunk(pic, formdata)
402 pic == NULL -> pic = root form;
403 add the form OR CHUNK to the pic context form. Do not replace existing forms.
404 Replaces existing chunks.
406 psdRemCfgChunk(pic, chnkid)
407 pic == NULL -> pic = root form;
408 delete the chunk from the pic context form.
413 /* While Poseidon writes a correct big endian IFF structure on both big and little endian
414 * the contents are *not* endian agnostic. Therefore we will avoid loading prefs of
415 * different endianess by defining the outmost FORM ID endian specific. Also notice that
416 * compatibility of the config files with 68k and MorphOS versions is not given. */
417 #define IFFFORM_PSDCFG MAKE_ID('P','S','B','C')
419 #define IFFFORM_PSDCFG MAKE_ID('P','S','L','C')
421 #define IFFFORM_STACKCFG MAKE_ID('S','T','K','C')
422 #define IFFFORM_DEVICECFG MAKE_ID('D','E','V','C')
423 #define IFFFORM_CLASSCFG MAKE_ID('C','L','S','C')
424 #define IFFFORM_UHWDEVICE MAKE_ID('U','H','W','D')
425 #define IFFFORM_USBCLASS MAKE_ID('U','C','L','S')
426 #define IFFFORM_CLASSDATA MAKE_ID('G','C','P','D')
427 #define IFFFORM_DEVCFGDATA MAKE_ID('D','C','F','G')
428 #define IFFFORM_DEVCLSDATA MAKE_ID('D','C','P','D')
429 #define IFFFORM_IFCFGDATA MAKE_ID('I','C','F','G')
430 #define IFFFORM_IFCLSDATA MAKE_ID('I','C','P','D')
432 #define IFFCHNK_OWNER MAKE_ID('O','W','N','R')
433 #define IFFCHNK_NAME MAKE_ID('N','A','M','E')
434 #define IFFCHNK_UNIT MAKE_ID('U','N','I','T')
435 #define IFFCHNK_OFFLINE MAKE_ID('O','F','F','L')
436 #define IFFCHNK_GLOBALCFG MAKE_ID('G','C','F','G')
437 #define IFFCHNK_DEVID MAKE_ID('D','V','I','D')
438 #define IFFCHNK_IFID MAKE_ID('I','F','I','D')
439 #define IFFCHNK_FORCEDBIND MAKE_ID('F','B','N','D')
440 #define IFFCHNK_POPUP MAKE_ID('P','O','P','O')
441 #define IFFCHNK_INSERTSND MAKE_ID('I','N','S','F')
442 #define IFFCHNK_REMOVESND MAKE_ID('R','M','S','F')
444 /* Private stuff starts here */
446 #if defined(__GNUC__)
450 /* GCA_PopupDeviceNew definitions */
452 #define PGCP_NEVER 0 /* never open a pop-up window */
453 #define PGCP_ERROR 1 /* popup, on error condition (e.g. low power) */
454 #define PGCP_ISNEW 2 /* popup, if this is the first time the device is connected */
455 #define PGCP_NOBINDING 3 /* popup, if there is no binding */
456 #define PGCP_ASKCONFIG 4 /* popup and ask to configure, if not existent */
457 #define PGCP_CANCONFIG 5 /* popup and ask to configure, if possible */
458 #define PGCP_HASBINDING 6 /* popup, if there is a binding to a class */
459 #define PGCP_ALWAYS 7 /* popup always */
463 ULONG pgc_ChunkID
; /* ChunkID=IFFCHNK_GLOBALCFG */
464 ULONG pgc_Length
; /* sizeof(struct PsdGlobalCfg)-8 */
465 BOOL pgc_LogInfo
; /* Log normal messages */
466 BOOL pgc_LogWarning
; /* Log warnings */
467 BOOL pgc_LogError
; /* Log errors */
468 BOOL pgc_LogFailure
; /* Log failures */
469 ULONG pgc_BootDelay
; /* boot delay */
470 WORD pgc_SubTaskPri
; /* Subtask priority */
471 UWORD pgc_PopupDeviceNew
; /* New device popup */
472 BOOL pgc_PopupDeviceGone
; /* Device removed popup */
473 BOOL pgc_PopupDeviceDeath
; /* Device dead popup */
474 ULONG pgc_PopupCloseDelay
; /* Delay in seconds before closing */
475 BOOL pgc_PopupActivateWin
; /* Activate window on opening */
476 BOOL pgc_PopupWinToFront
; /* Pop window to front on content change */
477 BOOL pgc_AutoDisableLP
; /* Automatically disable on LowPower */
478 BOOL pgc_AutoDisableDead
; /* Automatically disable on Dead */
479 BOOL pgc_AutoRestartDead
; /* Automatically restart on Dead */
480 ULONG pgc_PrefsVersion
; /* Reference version of prefs saved */
481 BOOL pgc_PowerSaving
; /* Enable power saving features */
482 BOOL pgc_ForceSuspend
; /* Force Suspend on classes not supporting it, but with remote wakeup */
483 ULONG pgc_SuspendTimeout
; /* Timeout when to suspend a device after inactivity */
486 /* DA_OverridePowerInfo definitions */
487 #define POCP_TRUST_DEVICE 0
488 #define POCP_BUS_POWERED 1
489 #define POCP_SELF_POWERED 2
493 ULONG poc_ChunkID
; /* ChunkID=IFFCHNK_POPO */
494 ULONG poc_Length
; /* sizeof(struct PsdPopoCfg)-8 */
495 BOOL poc_InhibitPopup
; /* Inhibit opening of popup window */
496 BOOL poc_NoClassBind
; /* Inhibit class scan */
497 UWORD poc_OverridePowerInfo
; /* 0=keep, 1=buspowered, 2=selfpowered */
500 #if defined(__GNUC__)
506 struct Node pls_Node
; /* Linkage */
507 BOOL pls_Dead
; /* Has Semaphore been deactivated? */
508 struct List pls_WaitQueue
; /* List of waiting tasks (ReadLock structs) */
509 struct List pls_ReadLocks
; /* List of obtained shared locks */
510 struct Task
*pls_Owner
; /* Current owner of exclusive lock */
511 UWORD pls_ExclLockCount
; /* Exclusive lock count */
512 UWORD pls_SharedLockCount
; /* Count of *different* shared lock owners */
517 struct Node prl_Node
; /* Linkage */
518 BOOL prl_IsExcl
; /* Is this lock exclusive? */
519 struct Task
*prl_Task
; /* Task waiting for or obtaining this lock */
520 UWORD prl_Count
; /* Shared lock count */
525 struct Node psi_Node
; /* Linkage */
526 struct PsdLockSem
*psi_LockSem
; /* Pointer to semaphore */
531 struct Node pbl_Node
; /* Linkage */
532 UWORD pbl_ExclLockCount
; /* Was exclusive before */
533 UWORD pbl_Count
; /* Shared lock count */
534 struct PsdLockSem
*pbl_LockSem
; /* Pointer to semaphore */
535 struct PsdReadLock
*pbl_ReadLock
; /* Readlock that was changed */
540 struct Task
*po_Task
; /* PoPo Task */
541 struct MsgPort
*po_MsgPort
; /* Port for EventNote messages */
542 LONG po_ReadySignal
; /* Signal to respond to task changes */
543 struct Task
*po_ReadySigTask
; /* task to signal */
544 struct Library
*po_IntBase
; /* Intuition base for PoPo Task */
545 struct Library
*po_MUIBase
; /* MUI base for PoPo Task */
546 struct Library
*po_DTBase
; /* DataTypes base for PoPo Task */
547 struct MsgPort
*po_TimerMsgPort
; /* Standard timer MsgPort */
548 struct timerequest
*po_TimerIOReq
; /* Standard timer request */
549 struct MUI_CustomClass
*po_PoPoClass
; /* PoPo Action Class */
550 ULONG
*po_PoPoObj
; /* PoPo Action Object */
551 ULONG
*po_AppObj
; /* App Object */
552 ULONG
*po_WindowObj
; /* Window Object */
553 ULONG
*po_GroupObj
; /* Group Object */
554 ULONG
*po_SaveObj
; /* Save Button Object */
555 ULONG
*po_CloseObj
; /* Close Button Object */
556 ULONG
*po_StickyObj
; /* Sticky Object */
557 ULONG
*po_AboutMI
; /* About MenuItem */
558 ULONG
*po_CloseMI
; /* Close MenuItem */
559 ULONG
*po_TridentMI
; /* Trident MenuItem */
560 ULONG
*po_MUIPrefsMI
; /* MUI Prefs MenuItem */
561 struct PsdEventHook
*po_EventHandler
; /* Event handler */
562 struct List po_GadgetList
; /* List of gadgets for a device */
563 BOOL po_OpenRequest
; /* open window requested */
564 BOOL po_Sticky
; /* sticky entries */
565 STRPTR po_InsertSndFile
; /* Path to insertion sound file */
566 STRPTR po_RemoveSndFile
; /* Path to removal sound file */
567 struct List po_Sounds
; /* List of loaded soundfiles */
570 struct PsdHandlerTask
572 struct Task
*ph_Task
; /* Event Handler Task */
573 struct MsgPort
*ph_MsgPort
; /* Port for EventNote messages */
574 LONG ph_ReadySignal
; /* Signal to respond to task changes */
575 struct Task
*ph_ReadySigTask
; /* task to signal */
576 struct PsdEventHook
*ph_EventHandler
; /* Event handler */
577 struct MsgPort
*ph_TimerMsgPort
; /* Port for timer requests */
578 struct timerequest
*ph_TimerIOReq
; /* Standard timer request */
587 struct PsdUWStringMap
593 struct PsdULStringMap
599 /* The library node - private
603 struct Library ps_Library
; /* standard */
604 UWORD ps_Flags
; /* various flags */
605 struct UtilityBase
*ps_UtilityBase
; /* for tags etc */
606 struct Library
*ps_DosBase
; /* for dos stuff */
607 BOOL ps_StackInit
; /* Did we initialize the stack yet? */
608 APTR ps_MemPool
; /* Public Memory Pool */
609 APTR ps_SemaMemPool
; /* Memory Pool exclusively for Semaphore ReadLocks */
610 struct List ps_DeadlockDebug
; /* linked list of semaphore allocations */
611 struct PsdLockSem ps_Lock
; /* PBase lock */
612 struct PsdLockSem ps_ConfigLock
; /* Config semaphore */
613 struct timerequest ps_TimerIOReq
; /* Standard timer request */
614 struct List ps_Hardware
; /* List of Hardware Interfaces in use */
615 struct List ps_Classes
; /* List of Classes loaded */
616 struct List ps_ErrorMsgs
; /* List of Error Msgs */
617 struct List ps_EventHooks
; /* List of EventHandlers */
618 struct MsgPort ps_EventReplyPort
; /* Replyport for Events */
619 struct List ps_ConfigRoot
; /* Configuration FORMs */
620 struct List ps_AlienConfigs
; /* Configuration FORM from outer space */
621 BOOL ps_CfgChangeMute
; /* Don't generate config changed events */
622 struct SignalSemaphore ps_ReentrantLock
; /* Lock for non-reentrant stuff */
623 struct SignalSemaphore ps_PoPoLock
; /* Lock for non-reentrant stuff */
624 ULONG ps_MemAllocated
; /* Bytes of memory allocated by stack */
625 UWORD ps_FunnyCount
; /* Funny Message Counter */
626 BOOL ps_ConfigRead
; /* Has a config been loaded? */
627 BOOL ps_CheckConfigReq
; /* Set to true, to check if config changed */
628 ULONG ps_ConfigHash
; /* Last config hash value */
629 ULONG ps_SavedConfigHash
; /* Hash sum of last saved config */
630 struct PsdGlobalCfg
*ps_GlobalCfg
; /* Global Config structure */
631 struct PsdPoPo ps_PoPo
;
632 ULONG ps_ReleaseVersion
; /* Release Version for update info */
633 ULONG ps_OSVersion
; /* Internal OS Version descriptor */
634 BOOL ps_StartedAsTask
; /* Did we start in Task Mode before DOS was available? */
635 struct PsdHandlerTask ps_EventHandler
; /* Event handler */
639 #define PSF_KLOG 0x0001
643 struct Node peh_Node
; /* Node linkage */
644 struct MsgPort
*peh_MsgPort
; /* Target message port */
645 ULONG peh_MsgMask
; /* Mask of messages to send */
650 struct Message pen_Msg
; /* Intertask communication message */
651 UWORD pen_Event
; /* Event number as specified above */
652 APTR pen_Param1
; /* Parameter 1 for event */
653 APTR pen_Param2
; /* Parameter 2 */
656 struct PsdEventNoteInternal
658 struct Node peni_Node
; /* Node linkage */
659 struct PsdEventNote peni_EventNote
; /* Encapsulated PsdEventNote */
664 struct Node pem_Node
; /* Node linkage */
665 struct PsdBase
*pem_Base
; /* Uplinking */
666 UWORD pem_Level
; /* RC: 0=Note, 5=Warn, 10=Error, 20=Fail */
667 STRPTR pem_Origin
; /* From whom? */
668 STRPTR pem_Msg
; /* Actual error message */
669 struct DateStamp pem_DateStamp
; /* Date Stamp (if DOS available) */
674 struct Node pic_Node
; /* Node linkage */
675 //struct PsdIFFContext *pic_Parent; /* Uplinking */
676 struct List pic_SubForms
; /* All sub forms */
677 ULONG pic_FormID
; /* 4 bytes FORM ID */
678 ULONG pic_FormLength
; /* Length of form */
679 ULONG
*pic_Chunks
; /* Chunks (no forms) */
680 ULONG pic_ChunksLen
; /* Total length of chunks */
681 ULONG pic_BufferLen
; /* size of buffer allocated */
686 struct Node puc_Node
; /* Node linkage */
687 struct PsdBase
*puc_Base
; /* Uplinking */
688 struct Library
*puc_ClassBase
; /* Library pointer */
689 STRPTR puc_ClassName
; /* Name of class */
690 STRPTR puc_FullPath
; /* Full path and class name */
691 UWORD puc_UseCnt
; /* Number of bindings in use */
692 BOOL puc_RemoveMe
; /* Class scheduled for removal */
697 struct Node pab_Node
; /* Node linkage */
698 struct PsdDevice
*pab_Device
; /* Uplinking */
699 struct Hook
*pab_ReleaseHook
; /* CallBackHook for releasing binding */
700 IPTR pab_UserData
; /* User Data */
701 struct Task
*pab_Task
; /* Task bound to */
702 BOOL pab_ForceRelease
; /* Force release of other app or class bindings */
707 struct Node phw_Node
; /* Node linkage */
708 struct PsdBase
*phw_Base
; /* Uplinking */
709 struct Task
*phw_ReadySigTask
; /* Task to send ready signal to */
710 LONG phw_ReadySignal
; /* Signal to send when ready */
711 struct Task
*phw_Task
; /* Device task */
712 STRPTR phw_DevName
; /* Device name */
713 ULONG phw_Unit
; /* Unit number */
715 STRPTR phw_ProductName
; /* Product name */
716 STRPTR phw_Manufacturer
; /* Manufacturer name */
717 STRPTR phw_Description
; /* Description string */
718 STRPTR phw_Copyright
; /* Copyright string */
719 UWORD phw_Version
; /* Version of device */
720 UWORD phw_Revision
; /* Device revision */
721 UWORD phw_DriverVers
; /* Driver version */
722 ULONG phw_Capabilities
; /* Driver/HW capabilities */
724 struct IOUsbHWReq
*phw_RootIOReq
; /* First IO Request */
726 struct PsdDevice
*phw_RootDevice
; /* Link to root hub of this hardware */
727 struct PsdDevice
*phw_DevArray
[128]; /* DevAddress->Device mapping */
728 struct List phw_Devices
; /* List of devices */
729 struct List phw_DeadDevices
; /* List of disconnected devices */
730 BOOL phw_RemoveMe
; /* Hardware scheduled for removal */
731 struct MsgPort phw_DevMsgPort
; /* Quick device message port */
732 struct MsgPort phw_TaskMsgPort
; /* Quick task message port */
733 volatile ULONG phw_MsgCount
; /* Number of Messages pending */
736 /* Flags for pd_Flags */
738 #define PDFF_LOWSPEED 0x0001
739 #define PDFF_CONNECTED 0x0002
740 #define PDFF_HASDEVADDR 0x0004
741 #define PDFF_HASDEVDESC 0x0008
742 #define PDFF_CONFIGURED 0x0010
743 #define PDFF_HIGHSPEED 0x0020
744 #define PDFF_NEEDSSPLIT 0x0040
745 #define PDFF_LOWPOWER 0x0080
746 #define PDFF_DEAD 0x0100
747 #define PDFF_SUSPENDED 0x0200
748 #ifdef AROS_USB30_CODE
749 #define PDFF_SUPERSPEED 0x0400
751 #define PDFF_APPBINDING 0x4000
752 #define PDFF_DELEXPUNGE 0x8000
756 struct Node pd_Node
; /* Node linkage */
757 struct PsdHardware
*pd_Hardware
; /* Interfacing hardware */
758 struct PsdLockSem pd_Lock
; /* Access locking */
759 struct PsdDevice
*pd_Hub
; /* Hub for device */
760 APTR pd_DevBinding
; /* Device binding */
761 struct PsdUsbClass
*pd_ClsBinding
; /* Which class has the bond? */
762 struct PsdConfig
*pd_CurrentConfig
; /* Direct pointer to currently set config */
763 UWORD pd_UseCnt
; /* Usage counter */
764 UWORD pd_DevAddr
; /* Device address */
765 UWORD pd_CurrCfg
; /* Current Configuration Number */
766 UWORD pd_NumCfgs
; /* Number of configurations available */
767 UWORD pd_PowerDrain
; /* Current power usage */
768 UWORD pd_PowerSupply
; /* Power provided from parent */
769 UWORD pd_CurrLangID
; /* Current Language ID */
770 UWORD
*pd_LangIDArray
; /* Array of supported languages */
771 UWORD pd_Flags
; /* Lowspeed? */
772 UWORD pd_HubPort
; /* Port number at parent hub */
773 UWORD pd_HubThinkTime
; /* Think time for TT inter-transaction gap */
774 UWORD pd_USBVers
; /* USB Version */
775 UWORD pd_DevClass
; /* Class code */
776 UWORD pd_DevSubClass
; /* Subclass code */
777 UWORD pd_DevProto
; /* Device protocol code */
778 UWORD pd_MaxPktSize0
; /* Packet size for EP0 */
779 UWORD pd_VendorID
; /* Vendor ID */
780 UWORD pd_ProductID
; /* Product ID */
781 UWORD pd_DevVers
; /* Device release version */
782 UWORD pd_CloneCount
; /* Running Number to distinguish same devices */
783 UWORD pd_DeadCount
; /* Number of timeouts on the device */
784 UWORD pd_IOBusyCount
; /* Number of busy IOs (not including interrupt transfers) */
785 struct timeval pd_LastActivity
; /* Timestamp of last IO access (start or end) */
786 STRPTR pd_MnfctrStr
; /* Manufacturer string */
787 STRPTR pd_ProductStr
; /* Product string (custom?) */
788 STRPTR pd_OldProductStr
; /* Original product string */
789 STRPTR pd_SerNumStr
; /* Serial number string */
790 STRPTR pd_IDString
; /* Whole Device ID string */
791 struct List pd_Configs
; /* List of configurations */
792 BOOL pd_IsNewToMe
; /* Whether the device is connected the first time */
793 struct PsdPoPoCfg pd_PoPoCfg
; /* Inhibit PopUp and Class scan Config */
794 struct List pd_Descriptors
; /* Descriptors collected */
795 struct List pd_RTIsoHandlers
; /* List of RTIsoHandlers */
800 struct Node pdd_Node
; /* Node linkage */
801 struct PsdDevice
*pdd_Device
; /* Up linkage */
802 struct PsdConfig
*pdd_Config
; /* Up linkage (optional, depending on type of desc) */
803 struct PsdInterface
*pdd_Interface
; /* Up linkage (optional, depending on type of desc) */
804 struct PsdEndpoint
*pdd_Endpoint
; /* Up linkage (optional, depending on type of desc) */
805 STRPTR pdd_Name
; /* Supposed Descriptor Type Name */
806 UWORD pdd_Type
; /* Descriptor Type */
807 UWORD pdd_Length
; /* Number of bytes in descriptor */
808 UWORD pdd_CSSubType
; /* Subtype of ClassSpecific Descriptor */
809 UBYTE
*pdd_Data
; /* Pointer to data */
814 struct Node pc_Node
; /* Node linkage */
815 struct PsdDevice
*pc_Device
; /* Up linkage */
816 UWORD pc_CfgNum
; /* Config number */
817 UWORD pc_Attr
; /* Attributes */
818 UWORD pc_MaxPower
; /* MaxPower (in mA) */
819 UWORD pc_NumIfs
; /* Number of interfaces */
820 STRPTR pc_CfgStr
; /* Name of config */
821 struct List pc_Interfaces
; /* List of interfaces */
826 struct Node pif_Node
; /* Node linkage */
827 struct PsdConfig
*pif_Config
; /* Up linkage */
828 APTR pif_IfBinding
; /* Interface Binding */
829 struct PsdUsbClass
*pif_ClsBinding
; /* Which class has the bond? */
830 UWORD pif_IfNum
; /* Interface number */
831 UWORD pif_Alternate
; /* Alternate setting */
832 UWORD pif_NumEPs
; /* Number of Endpoints */
833 UWORD pif_IfClass
; /* Interface Class */
834 UWORD pif_IfSubClass
; /* Interface Subclass */
835 UWORD pif_IfProto
; /* Interface Protocol */
836 STRPTR pif_IfStr
; /* Interface String */
837 STRPTR pif_IDString
; /* Interface ID String */
838 struct PsdInterface
*pif_ParentIf
; /* If interface is an alternate, uplink */
839 struct List pif_AlterIfs
; /* List of alternate interface not in use */
840 struct List pif_EPs
; /* List of endpoints */
845 struct Node pep_Node
; /* Node linkage */
846 struct PsdInterface
*pep_Interface
; /* Up linkage */
847 UWORD pep_EPNum
; /* Endpoint address */
848 UWORD pep_Direction
; /* Direction (0=OUT, 1=IN) */
849 UWORD pep_TransType
; /* TransferType, see USEA-Flags */
850 UWORD pep_MaxPktSize
; /* Maximum packet size for EP */
851 UWORD pep_NumTransMuFr
; /* Number of transactions per µFrame */
852 UWORD pep_Interval
; /* Interval for polling in ms */
853 UWORD pep_SyncType
; /* Iso Synchronization Type */
854 UWORD pep_UsageType
; /* Iso Usage Type */
857 /* Flags for pp_Flags */
858 #define PFF_INPLACE 0x0001 /* streams: buffer is in place, needs no copying */
862 struct Message pp_Msg
; /* Intertask communication message */
863 struct PsdDevice
*pp_Device
; /* Up linkage */
864 struct PsdEndpoint
*pp_Endpoint
; /* Endpoint linkage or NULL for default pipe */
865 struct MsgPort
*pp_MsgPort
; /* Msg Port of task allocated pipe */
866 struct PsdPipe
*pp_AbortPipe
; /* Pipe to abort */
867 ULONG pp_Num
; /* internal pipe number (used for streams) */
868 UWORD pp_Flags
; /* internal flags (used for streams) */
869 struct IOUsbHWReq pp_IOReq
; /* IO Request allocated for this pipe */
872 /* Flags for pps_Flags */
873 #define PSFF_ASYNCIO 0x0001 /* async task (r/w) */
874 #define PSFF_SHORTTERM 0x0002 /* terminate read on short packet (r) */
875 #define PSFF_READAHEAD 0x0004 /* read from usb device until buffer full (r) */
876 #define PSFF_BUFFERREAD 0x0008 /* reads smaller than maxpktsize are buffered (r) */
877 #define PSFF_BUFFERWRITE 0x0010 /* writes smaller than maxpktsize are buffered -- flush required (w) */
878 #define PSFF_NOSHORTPKT 0x0020 /* don't terminate writes with a short packet (w) */
879 #define PSFF_NAKTIMEOUT 0x0040 /* enable nak timeout (r/w) */
880 #define PSFF_ALLOWRUNT 0x0080 /* allow reading of runt packets (r) */
881 #define PSFF_DONOTWAIT 0x0100 /* non blocking IO (r) */
882 #define PSFF_OWNMSGPORT 0x8000 /* internal flag */
886 struct Node pps_Node
; /* Node linkage */
887 struct PsdDevice
*pps_Device
; /* Up linkage */
888 struct PsdEndpoint
*pps_Endpoint
; /* Endpoint linkage */
889 struct MsgPort
*pps_MsgPort
; /* Msg Port of task allocated pipe */
890 struct PsdPipe
**pps_Pipes
; /* Array of pipes */
891 struct List pps_FreePipes
; /* Inactive pipes */
892 struct List pps_ReadyPipes
; /* Ready pipes */
893 struct Task
*pps_AsyncTask
; /* Task used for asynchroneous transfers */
894 struct SignalSemaphore pps_AccessLock
; /* Semaphore for reading & writing */
895 struct PsdPipe
*pps_ActivePipe
; /* Pipe currently active (w) */
896 ULONG pps_NumPipes
; /* Number of pipes */
897 ULONG pps_NakTimeoutTime
; /* Nak Timeout time for pipe */
898 ULONG pps_AbortSigMask
; /* Signal mask for waking up read or write */
899 UWORD pps_Flags
; /* transfer flags */
901 UBYTE
*pps_Buffer
; /* globally allocated buffer for all pipes */
902 ULONG pps_BufferSize
; /* Size of each pipe buffer */
903 ULONG pps_Offset
; /* read or write offset into the first returned buffer */
904 ULONG pps_BytesPending
; /* bytes in read or write buffer */
905 ULONG pps_ReqBytes
; /* number of bytes currently requested */
906 LONG pps_Error
; /* last error occurred */
907 UBYTE
*pps_TermArray
; /* termination char array */
910 struct PsdRTIsoHandler
912 struct Node prt_Node
; /* Node linkage */
913 struct PsdDevice
*prt_Device
; /* Up linkage */
914 struct PsdEndpoint
*prt_Endpoint
; /* Endpoint linkage */
915 struct PsdPipe
*prt_Pipe
; /* Pipe */
916 struct Hook
*prt_ReleaseHook
; /* Hook to be called when device gets removed */
917 struct IOUsbHWRTIso prt_RTIso
; /* RT Iso structure */
920 #endif /* LIBRARIES_POSEIDON_H */