Minor fixes to comments.
[AROS.git] / rom / usb / docs / poseidon.doc
blob67e045d9bec1544a5b29c0f8a643db91af7f3b94
1 TABLE OF CONTENTS
3 poseidon.library/--background--
4 poseidon.library/psdAbortPipe
5 poseidon.library/psdAddClass
6 poseidon.library/psdAddErrorMsg
7 poseidon.library/psdAddHardware
8 poseidon.library/psdAllocDevice
9 poseidon.library/psdAllocPipe
10 poseidon.library/psdAllocVec
11 poseidon.library/psdClaimAppBinding
12 poseidon.library/psdClassScan
13 poseidon.library/psdCopyStr
14 poseidon.library/psdDelayMS
15 poseidon.library/psdDoPipe
16 poseidon.library/psdEnumerateDevice
17 poseidon.library/psdEnumerateHardware
18 poseidon.library/psdFindDevice
19 poseidon.library/psdFreeDevice
20 poseidon.library/psdFreePipe
21 poseidon.library/psdFreeVec
22 poseidon.library/psdGetAttrs
23 poseidon.library/psdGetNextDevice
24 poseidon.library/psdGetPipeActual
25 poseidon.library/psdGetPipeError
26 poseidon.library/psdGetStringDescriptor
27 poseidon.library/psdLockReadDevice
28 poseidon.library/psdLockReadPBase
29 poseidon.library/psdLockWriteDevice
30 poseidon.library/psdLockWritePBase
31 poseidon.library/psdNumToStr
32 poseidon.library/psdPipeSetup
33 poseidon.library/psdReleaseAppBinding
34 poseidon.library/psdRemClass
35 poseidon.library/psdRemErrorMsg
36 poseidon.library/psdRemHardware
37 poseidon.library/psdSafeRawDoFmt
38 poseidon.library/psdSendPipe
39 poseidon.library/psdSetAltInterface
40 poseidon.library/psdSetAttrs
41 poseidon.library/psdSetDeviceConfig
42 poseidon.library/psdSpawnSubTask
43 poseidon.library/psdUnlockDevice
44 poseidon.library/psdUnlockPBase
45 poseidon.library/psdWaitPipe
47 Need to be added:
48 psdAddEventHandler
49 psdRemEventHandler
50 psdSendEvent
52 psdReleaseDevBinding
53 psdReleaseIfBinding
55 psdReadCfg
56 psdWriteCfg
57 psdFindCfgForm
58 psdNextCfgForm
59 psdRemCfgForm
61 psdAddCfgEntry
62 psdRemCfgChunk
63 psdGetCfgChunk
64 psdParseCfg
65 psdUnbindAll
67 psdSetClsCfg
68 psdGetClsCfg
69 psdSetUsbDevCfg
70 psdGetUsbDevCfg
72 psdFindInterface
73 psdFindEndpoint
74 psdCopyStrFmt
75 psdSetForcedBinding
76 psdGetForcedBinding
78 psdCheckPipe
80 /* V3 */
82 psdOpenStreamA
83 psdCloseStream
84 psdStreamRead
85 psdStreamWrite
86 psdStreamFlush
87 psdGetStreamError
89 psdCalculatePower
90 psdLoadCfgFromDisk
91 psdSaveCfgToDisk
94 \fposeidon.library/psdReadCfg                       poseidon.library/psdReadCfg
96    NAME
97         psdReadCfg -- read in a given form into an existing IFF context
99    SYNOPSIS
100         success = psdReadCfg(pic, form);
101         D0                   A0   A1
103         BOOL psdReadCfg(APTR, APTR);
105    FUNCTION
106         Stores the given IFF form in the internal prefs structure at the
107         given Poseidon IFF context.
109         The data given in the form must be of the same type (same ID) as the
110         IFF context, otherwise this function will fail.
112         It will replace the previous contents of the form completely with
113         the new one.
115         The pic parameter points to an internal Poseidon IFF context
116         structure. If pic is set to NULL, the root context is used.
118         This function is considered to be semi-private, use with care.
120    INPUTS
121         pic - pointer to a Poseidon IFF context structure or NULL for the
122               root context. This structure is private.
123         form - pointer to a valid IFF FORM. May not be NULL.
125    RESULT
126         success - TRUE, if everything went okay, or FALSE, if there was
127                   something wrong with the form.
129    SEE ALSO
130         psdWriteCfg(), psdFindCfgForm(), psdRemCfgForm(), psdAddCfgEntry()
133 \fposeidon.library/psdWriteCfg                     poseidon.library/psdWriteCfg
135    NAME
136         psdWriteCfg -- convert an IFF context into a serialized IFF form
138    SYNOPSIS
139         form = psdWriteCfg(pic);
140         D0                 A0
142         APTR psdWriteCfg(APTR);
144    FUNCTION
145         psdWriteCfg() takes the given Poseidon IFF context and generates a
146         serialized IFF form out of it. The returned pointer is a buffer to
147         the IFF form data of the contexted given (including all subforms and
148         chunks).
150         If the context is NULL, a complete configuration memory dump is
151         created, starting from the root context. The returned pointer then
152         contains the complete Poseidon prefs data.
154         The buffer is allocated automatically and has to be freed using the
155         psdFreeVec() call after it is no longer required.
157         The size of the buffer can be calculated by adding 8 to the second
158         longword (as it's a normal IFF structure).
160         To read out a single chunk instead, use the psdGetCfgChunk()
161         function.
163    INPUTS
164         pic - pointer to a Poseidon IFF context structure or NULL for the
165               root context. This structure is private.
167    RESULT
168         form - pointer to the IFF FORM generated from the context or NULL,
169                if the function failed (e.g. out of memory).
171    SEE ALSO
172         psdReadCfg(), psdFindCfgForm(), psdRemCfgForm(), psdAddCfgEntry(),
173         psdGetCfgChunk()
176 \fposeidon.library/psdFindCfgForm               poseidon.library/psdFindCfgForm
178    NAME
179         psdFindCfgForm -- search for a specific config form
181    SYNOPSIS
182         subpic = psdFindCfgForm(pic, formid);
183         D0                      A0   D0
185         APTR psdFindCfgForm(APTR, ULONG);
187    FUNCTION
188         This function searches the internal configuration space given by the
189         Poseidon IFF context for a certain IFF FORM as given by the form ID.
191         The result is a pointer to Poseidon IFF context representing the
192         form found, or NULL, if no such IFF FORM could be discovered.
194         As there may be any number of IFF forms with the same ID, the
195         function psdNextCfgForm() can be used obtain any further forms with
196         the same ID.
198    INPUTS
199         pic - pointer to a Poseidon IFF context structure or NULL for the
200               root context. This structure is private.
201         formid - longword containing the ID of the form to search.
203    RESULT
204         subpic - pointer to the first Poseidon IFF context structure found,
205                  or NULL, if no such form was found.
207    SEE ALSO
208         psdNextCfgForm(), psdRemCfgForm(), psdGetCfgChunk()
211 \fposeidon.library/psdNextCfgForm               poseidon.library/psdNextCfgForm
213    NAME
214         psdNextCfgForm -- continue search for a specific config form
216    SYNOPSIS
217         nextpic = psdNextCfgForm(pic);
218         D0                       A0
220         APTR psdNextCfgForm(APTR);
222    FUNCTION
223         psdNextCfgForm() searches for addition IFF FORMs within the same
224         parent Poseidon IFF context.
226         The parameter pic given to psdNextCfgForm() should be the one
227         returned by psdFindCfgForm(). There is no need to supply the form ID
228         anymore, because the context already contains this.
230         If another IFF form with the same ID is found, the Poseidon IFF
231         context pointer for it will be returned. Otherwise, nextpic will
232         contain NULL.
234    INPUTS
235         pic - pointer to a Poseidon IFF context structure.
237    RESULT
238         nextpic - pointer to the next Poseidon IFF context structure found,
239                  or NULL, if no additional form could be retrieved.
241    SEE ALSO
242         psdNextCfgForm(), psdRemCfgForm(), psdGetCfgChunk()
245 \fposeidon.library/psdRemCfgForm                 poseidon.library/psdRemCfgForm
247    NAME
248         psdRemCfgForm -- remove a configuration form
250    SYNOPSIS
251         psdRemCfgForm(pic);
252                       A0
254         VOID psdRemCfgForm(APTR);
256    FUNCTION
257         Removes the given Poseidon IFF context, including all its chunks and
258         subforms.
260         To remove single chunks, use the psdRemCfgChunk() instead.
262    INPUTS
263         pic - pointer to a Poseidon IFF context structure, or NULL for the
264               root context (for normal applications, DO NOT USE the NULL
265               pointer).
267    SEE ALSO
268         psdFindCfgForm(), psdNextCfgForm(), psdRemCfgChunk()
271 \fposeidon.library/psdAddCfgEntry               poseidon.library/psdAddCfgEntry
273    NAME
274         psdAddCfgEntry -- add a chunk or a whole form to an IFF context
276    SYNOPSIS
277         subpic = psdAddCfgEntry(pic, form);
278         D0                      A0   A1
280         APTR psdAddCfgEntry(APTR, APTR);
282    FUNCTION
283         Using this function you can add an IFF chunk or a complete FORM to
284         the given Poseidon IFF context.
286         If the form parameter points to an IFF form buffer (NOT context), the
287         function performs the following:
288             - Adds the given form to the context. If such an form already
289               existed, it will still be added behind the existing one.
290             - Returns a pointer to the newly created Poseidon IFF context.
292         If the form parameter points to an IFF chunk only, psdAddCfgEntry
293         does the following:
294             - If no chunk with the same ID exists, it adds it to the given
295               context. Otherwise, the existing chunk will be replaced by the
296               new one.
297             - Returns the previously given context pointer.
299         subpic is set to NULL, if an error occurred during adding (e.g.
300         corrupt IFF FORM).
302    INPUTS
303         pic - pointer to a Poseidon IFF context structure or NULL for the
304               root context. This structure is private.
305         form - a pointer to a buffer containing the IFF FORM or chunk data.
307    RESULT
308         subpic - pointer to the Poseidon IFF context structure (see above)
309                  or NULL, if the form or chunk could not be added.
311    SEE ALSO
312         psdAddCfgForm(), psdRemCfgForm(), psdGetCfgChunk(), psdRemCfgChunk()
315 \fposeidon.library/psdRemCfgChunk               poseidon.library/psdRemCfgChunk
317    NAME
318         psdRemCfgChunk -- remove a chunk for a given context
320    SYNOPSIS
321         success = psdRemCfgChunk(pic, chunkid);
322         D0                       A0   D0
324         BOOL psdRemCfgChunk(APTR, ULONG);
326    FUNCTION
327         psdRemCfgChunk() tries to remove a chunk from the given Poseidon IFF
328         context, which has the ID stored in parameter chunkid.
330         If no chunk with that ID existed, it will return FALSE, otherwise the
331         return value will be TRUE to show the success of the removal.
333         A special case is implemented by using a special chunkid of 0. This
334         will completely empty out the IFF context, by deleting every chunk
335         and form. This is not quite the same as psdRemCfgForm(), as it will
336         not delete the context itself.
338    INPUTS
339         pic - pointer to a Poseidon IFF context structure or NULL for the
340               root context. This structure is private.
341         chunkid - the longword containing the ID of the chunk to remove,
342                   or 0, to remove all chunks AND subforms.
344    RESULT
345         success - TRUE, if the chunk was found and removed, FALSE otherwise.
347    SEE ALSO
348         psdAddCfgForm(), psdRemCfgForm(), psdGetCfgChunk()
351 \fposeidon.library/psdGetCfgChunk               poseidon.library/psdGetCfgChunk
353    NAME
354         psdGetCfgChunk -- convert an IFF context into a serialized IFF form
356    SYNOPSIS
357         chunk = psdGetCfgChunk(pic, chunkid);
358         D0                     A0   D0
360         APTR psdGetCfgChunk(APTR, ULONG);
362    FUNCTION
363         psdGetCfgChunk() searches and returns the chunk with the given ID
364         in chunkid inside the Poseidon IFF context pic. The returned pointer
365         is a buffer to the IFF chunk data.
367         If the context is NULL, the root context is used.
369         The buffer is allocated automatically and has to be freed using the
370         psdFreeVec() call after it is no longer required.
372         The size of the buffer can be calculated by adding 8 to the second
373         longword (as it's a normal IFF structure). The actual data stored in
374         the chunk starts at the third longword (offset 8).
376         To obtain a serialized version of an IFF context instead of a single
377         chunk, use the psdWriteCfg() function.
379    INPUTS
380         pic - pointer to a Poseidon IFF context structure or NULL for the
381               root context. This structure is private.
382         chunkid - IFF id of the chunk to search.
384    RESULT
385         chunk - pointer to the IFF chunk generated from the context or NULL,
386                 if the function failed (e.g. out of memory).
388    SEE ALSO
389         psdWriteCfg(), psdFindCfgForm(), psdRemCfgForm(), psdAddCfgEntry(),
390         psdGetCfgChunk()
393 \fposeidon.library/psdSetClsCfg                   poseidon.library/psdSetClsCfg
395    NAME
396         psdSetClsCfg -- store the class configuration in the prefs
398    SYNOPSIS
399         success = psdSetClsCfg(owner, form);
400         D0                     A0     A1
402         BOOL psdSetClsCfg(STRPTR, APTR);
404    FUNCTION
405         Stores the class configuration IFF form in the internal prefs
406         structure. This is normally USB device independent preference
407         information, or the default settings for a class.
409         The owner parameter is usually the name of the class (but not limited
410         to it). The form parameter has to be a pointer to a valid IFF-FORM
411         with FORM-ID IFFFORM_CLASSDATA (see poseidon.h).
413         If the form pointer is NULL, an existing configuration form will be
414         deleted. In any other case, any previously existing data will be
415         overwritten by the given form.
417         After successfully calling psdSetClsCfg(), psdGetClsCfg() will return
418         a pointer to the IFF structure for you to parse (or return as a
419         whole). This can be used to incrementally add/replace chunks or whole
420         forms to the existing prefs container using the psdAddCfgEntry() or
421         psdReadCfg() functions.
423         psdSetClsCfg() does not store the config to disk. User interaction is
424         normally required for this (Trident, PoPo, or a call to
425         psdSaveCfgToDisk()).
427    INPUTS
428         owner - unique name string of the owner, usually the class name.
429         form - pointer to a valid IFF CLASSDATA FORM. If a NULL pointer is
430                given, a minimal config form will be created and previous data
431                will be overwritten.
433    RESULT
434         success - TRUE, if everything went okay, or FALSE, if there was
435                   something wrong with the form.
437    SEE ALSO
438         psdGetClsCfg(), psdSetUsbDevCfg(), psdGetUsbDevCfg(), psdAddCfgEntry()
441 \fposeidon.library/psdGetClsCfg                   poseidon.library/psdGetClsCfg
443    NAME
444         psdGetClsCfg -- obtain the class configuration from the prefs
446    SYNOPSIS
447         pic = psdGetClsCfg(owner);
448         D0                 A0
450         APTR psdGetClsCfg(STRPTR);
452    FUNCTION
453         This call tries to obtain the previously stored class configuration
454         data. Class prefs can be saved in the internal configuration system
455         using the psdSetClsCfg() function.
457         The owner parameter usually corresponds to the name of the class.
459         If no configuration has been stored yet, a NULL pointer will be
460         returned. If there is at least a minimal configuration structure,
461         a pointer to this internal IFF context will be returned (this is not
462         a pointer to a FORM memory region!). This minimal configuration can
463         be generated using psdSetClsCfg(owner, NULL);
465    INPUTS
466         owner - unique name string of the owner, usually the class name.
468    RESULT
469         pic - pointer to a Poseidon IFF context structure. This structure is
470               private. Use the Poseidon configuration management functions to
471               access the data behind it.
473    SEE ALSO
474         psdSetClsCfg(), psdSetUsbDevCfg(), psdGetUsbDevCfg(),
475         psdAddCfgEntry(), psdGetCfgChunk(), psdFindCfgForm(), psdWriteCfg()
478 \fposeidon.library/psdSetUsbDevCfg             poseidon.library/psdSetUsbDevCfg
480    NAME
481         psdSetUsbDevCfg -- store usb device specific settings in the prefs
483    SYNOPSIS
484         success = psdSetUsbDevCfg(owner, devid, ifid, form);
485         D0                        A0     A2     A3    A1
487         BOOL psdSetUsbDevCfg(STRPTR, STRPTR, STRPTR, APTR);
489    FUNCTION
490         Stores the USB device specific configuration IFF form in the internal
491         prefs structure. This is normally device or interface specific
492         information, stored indivdually for each device attached.
494         The usage is very similar to the psdSetClsCfg() function, hence only
495         the additional parameter devid and ifid are explained here.
497         The devid parameter normally contains the DA_IDString identification
498         string as returned by psdGetAttrs(), which is unique to every USB
499         device connected to the stack. devid may NOT be NULL.
501         If the class is bound to USB devices as a whole, and not to particular
502         interfaces, it can usually leave the ifid parameter to NULL.
503         Otherwise, ifid should point to the string returned by psdGetAttrs()
504         on the specific interface using IFA_IDString tag.
506         The owner parameter is usually the name of the class (but not limited
507         to it). The form data must have ID IFFFORM_DEVCLSDATA, if the ifid is
508         NULL or IFFFORM_IFCLSDATA, if ifid is not NULL. Otherwise, the call
509         to this function will fail.
511         If the form pointer is NULL, an existing configuration form will be
512         deleted. In any other case, any previously existing data will be
513         overwritten by the given form.
515         After successfully calling psdSetUsbDevCfg(), psdGetUsbDevCfg() will
516         return a pointer to the IFF structure for you to parse (or return as
517         a whole). This can be used to incrementally add/replace chunks or
518         whole forms to the existing prefs container using the
519         psdAddCfgEntry() or psdReadCfg() functions.
521         psdSetUsbDevCfg() does not store the config to disk. User interaction
522         is normally required for this (Trident, PoPo, or a call to
523         psdSaveCfgToDisk()).
525    INPUTS
526         owner - unique name string of the owner, usually the class name.
527         devid - pointer to unique device ID string
528         ifid - pointer to unique interface ID string or NULL, if config is
529                to be stored for the whole device.
530         form - pointer to a valid IFF FORM. If a NULL pointer is given, a
531                minimal config form will be created and previous data will be
532                overwritten.
534    RESULT
535         success - TRUE, if everything went okay, or FALSE, if there was
536                   something wrong with the form.
538    SEE ALSO
539         psdSetClsCfg(), psdGetClsCfg(), psdGetUsbDevCfg(), psdAddCfgEntry()
542 \fposeidon.library/psdGetUsbDevCfg             poseidon.library/psdGetUsbDevCfg
544    NAME
545         psdGetUsbDevCfg -- obtain the device specific settings from the prefs
547    SYNOPSIS
548         pic = psdGetUsbDevCfg(owner, devid, ifid);
549         D0                    A0     A2     A3
551         APTR psdGetUsbDevCfg(STRPTR, STRPTR, STRPTR);
553    FUNCTION
554         This call tries to obtain the previously stored USB device specific
555         configuration data. This kind of prefs can be saved in the internal
556         configuration system using the psdSetUsbDevCfg() function.
558         This call is very similar to psdGetClsCfg(), except for the devid and
559         ifid parameters, which are explained in detail for psdSetUsbDevCfg().
561         The owner parameter usually corresponds to the name of the class.
563         If no configuration has been stored yet, a NULL pointer will be
564         returned. If there is at least a minimal configuration structure,
565         a pointer to this internal IFF context will be returned (this is not
566         a pointer to a FORM memory region!). This minimal configuration can
567         be generated using psdSetClsCfg(owner, NULL);
569    INPUTS
570         owner - unique name string of the owner, usually the class name.
571         devid - pointer to unique device ID string
572         ifid - pointer to unique interface ID string or NULL, if config is
573                to be obtained for the whole device.
575    RESULT
576         pic - pointer to a Poseidon IFF context structure. This structure is
577               private. Use the Poseidon configuration management functions to
578               access the data behind it.
580    SEE ALSO
581         psdGetClsCfg(), psdSetClsCfg(), psdGetUsbDevCfg(), psdAddCfgEntry(),
582         psdGetCfgChunk(), psdFindCfgForm(), psdWriteCfg()
586 \fposeidon.library/--background--               poseidon.library/--background--
588    PURPOSE
589         Poseidon is a USB protocol stack for the Amiga. It serves as a
590         manager and interface between the USB host controller drivers
591         (usbhardware.device) and the class drivers.
593         This document is dated 28-Mar-02 19:53:03
595    OVERVIEW
596         Poseidon itself is a library. It has no own tasks except for the
597         tasks spawned for each hardware device mounted. The library functions
598         are fully re-entrant and all important structures are protected (or
599         can be protected), when access is to be shared.
601         Poseidon uses the following levels of abstraction:
603         PsdHardware   - The usb hardware interface the devices are physically
604         (phw)           connected to. There is no limit to the amount and
605                         type of host controller hardware that can be added to
606                         the stack.
607                         A PsdHardware can have up to 127 PsdDevices.
609         PsdDevice     - A device mounted to a PsdHardware. Normally, this is
610         (pd)            at least the root hub.
612                         A device can have multiple configurations, and a
613                         maximum of one Device<->Class binding.
615         PsdConfig     - One or multiple configurations that the usb device
616         (pc)            supports. USB allows only one configuration to be
617                         active at a time. Each configuration must have at
618                         least one interface.
620         PsdInterface  - Description of the interfaces the device supports in
621         (pif)           the chosen configuration. Each interface can have
622                         0 to 15 endpoints (endpoint 0 is always available).
624                         Each interface can have an Interface<->Class binding,
625                         if no Device<->Class binding already exists.
627         PsdEndpoint   - An endpoint defines the destination port for a
628         (pep)           transfer pipe. Endpoint 0, the default control
629                         endpoint, is not explicitly defined.
631         PsdPipe       - A data transfer control pipe. You can allocate as
632         (pp)            many pipes to an endpoint as you like, but each pipe
633                         may be used for only one transfer at a time.
635         PsdUsbClass   - A usb class driver. There is hopefully no limitation
636         (puc)           to what a class driver wants to do with an interface
637                         or an device.
639         PsdAppBinding - An application binding node. Whenever using a class
640         (pab)           driver is not appropriate, application programmers
641                         can use the AppBinding interface to claim a USB
642                         device.
644         PsdErrorMsg   - Supportive structure for postponing an error message.
645         (pem)
647         As all these structures are private (except for the information that
648         they all have a Node structure for linking) and subject to change,
649         the information can only be read (and in some cases written as well)
650         by a call to psdGetAttrs() (and changed using psdSetAttrs()) which
651         uses TagLists. This ensures future compatibilty with all extensions
652         and changes made.
654         Class drivers are libraries as well. Whenever a new device is detected
655         by the stack, all classes will be asked whether they want to
656         establish an interface or even the whole binding (that is, if they
657         know the interface protocol and therefore can add its features to the
658         system). In case they want to establish a binding, they normally
659         spawn a subtask with an instance of this binding.
661         Device<->Class bindings allow full control over a device, all its
662         configurations and interfaces whereas Interface<->Class bindings are
663         limited to the interface they work on. They may, however, change the
664         interfaces' alternative setting.
666         To support application programs, which need to talk to certain USB
667         devices with a vendor specific protocol, and which don't want to
668         through writing a class driver for just one protocol, there is also
669         the possibility to establish application bindings. This allows normal
670         programs to bypass the class interface to claim device bindings. Note
671         that his is not the preferred way to add functionality and should be
672         avoided, if you also could go through the class library interface
673         as well.
675    FILES
676         The poseidon.library itself resides in LIBS:, the USB hardware
677         devices should be in DEVS:USBHardware, and all class drivers should
678         be stored in SYS:Classes/USB.
680    BUGS
681         The stack is not finished yet. Some features never have been tested.
682         There will be a lot of bugs hiding in all places. An event handler
683         (mainly for use by the GUI) is going to be added, as well as some
684         configuration and GUI hooks for the classes.
686         This version is meant to be a working frame for developers to test
687         and add their hardware or for application programmers to add class
688         drivers. Be sure that some things WILL change, be sure to keep
689         contact to me, Chris Hodges <chrisly@platon42.de>.
691         Also, bug reports, errors, feature requests are welcome and REQUIRED
692         for Poseidon to be a good product.
695 \fposeidon.library/psdAbortPipe                   poseidon.library/psdAbortPipe
697    NAME
698         psdAbortPipe -- attempt to abort a pipe transaction
700    SYNOPSIS
701         psdAbortPipe(pp);
702                      A1
704         void psdAbortPipe(APTR);
706    FUNCTION
707         Asks the hardware to abort the pipe request. The hardware may or may
708         not grant this and will return the request to you earlier than it
709         might have done. The ioerror code normally will be IOERR_ABORTED in
710         this case.
712    NOTE
713         psdAbortPipe() does not Remove() the request from your message reply
714         port or even wait for it to complete. After psdAbortPipe() you must
715         normally wait for the reply message before actually reusing or
716         freeing the pipe using psdWaitPipe().
718         If a request is already completed, no action will be taken.
720    INPUTS
721         pp - pointer to pipe to abort.
723    SEE ALSO
724         psdSendPipe(), psdWaitPipe(), psdGetPipeError(), psdGetPipeActual()
727 \fposeidon.library/psdAddClass                     poseidon.library/psdAddClass
729    NAME
730         psdAddClass -- add a usb class library to the stack
732    SYNOPSIS
733         puc = psdAddClass(name, version);
734         D0                A1    D0
736         APTR psdAddClass(STRPTR, ULONG);
738    FUNCTION
740         psdAddClass() tries to open and add a usb class driver to the stack.
741         Be sure only to add libraries to the stack which are really Poseidon
742         compatible usb classes, else a crash is very probable.
744         If opening the library succeeds, the class will be added to the
745         class list.
747         Usually class libraries will be stored in SYS:Classes/USB.
749    INPUTS
750         name - (file)name of the class to add.
751         version - version of library to request.
753    RESULT
754         puc - pointer to the library base, or NULL if opening failed.
756    SEE ALSO
757         psdRemClass(), psdClassScan()
760 \fposeidon.library/psdAddErrorMsg               poseidon.library/psdAddErrorMsg
762    NAME
763         psdAddErrorMsgA -- add an error or information message for the user
764         psdAddErrorMsg -- varargs stub for psdAddErrorMsgA
766    SYNOPSIS
767         pem = psdAddErrorMsgA(level, origin, fmtstr, fmtdata);
768         D0                    D0     A0      A1      A2
770         APTR psdAddErrorMsgA(UWORD, STRPTR, STRPTR, APTR);
772         pem = psdAddErrorMsg(level, origin, fmtstr, ...);
774         APTR psdAddErrorMsg(UWORD, STRPTR, STRPTR, ...);
776    FUNCTION
777         Adds an error message for the user. This message will can be read in
778         the GUI or other logging tools. There are four different levels of
779         severity.
781    NOTE
782         psdAddErrorMsg() uses a Forbid()/Permit() arbitration. The strings
783         can safely be of any length, but will be truncated at 256 characters.
785    INPUTS
786         level - error level, either RETURN_OK (0) for information messages,
787                 RETURN_WARN (5) for warnings, RETURN_ERROR (10) for error
788                 messages and RETURN_FAIL (20) for fatal failure alerts.
789         origin - string of the module caused the error.
790         fmtstr - formatted string like in printf() or RawDoFmt()
791         fmtdata - format parameters
793    RESULT
794         pem - pointer to an error message structure (private) or NULL on
795               failure.
797    SEE ALSO
798         psdRemErrorMsg(), psdSafeRawDoFmt(), RawDoFmt()
801 \fposeidon.library/psdAddHardware               poseidon.library/psdAddHardware
803    NAME
804         psdAddHardware -- open and link a new usb hardware into the stack
806    SYNOPSIS
807         phw = psdAddHardware(devname, unit);
808         D0                   A0       D0
810         APTR psdAddHardware(STRPTR, ULONG);
812    FUNCTION
813         psdAddHardware() is used for the stack manager to add a new hardware
814         device to the Poseidon USB stack. The hardware is initialized, but no
815         devices attached to the root hub are enumerated. To do this, just
816         call psdEnumerateHardware().
818         As a result a pointer to the internal hardware structure is returned.
819         The data of this structure is private! Do not touch!
821         Moreover, the hardware is linked to the list of known hardware
822         devices and will be closed on the expunge of the library.
824         This function returns NULL, if the hardware device could not be
825         opened or some other error occured. The user will find the reason in
826         the list of error messages.
828    INPUTS
829         devname - pointer to usb hardware device name string
830         unit - unit number of usb hardware device
832    RESULT
833         phw - internal hardware pointer. Do not touch (except for node
834               traversal).
836    SEE ALSO
837         psdRemHardware(), psdEnumerateHardware()
840 \fposeidon.library/psdAllocDevice               poseidon.library/psdAllocDevice
842    NAME
843         psdAllocDevice -- allocate a device structure
845    SYNOPSIS
846         pd = psdAllocDevice(phw);
847         D0                  A0
849         APTR psdAllocDevice(APTR);
851    FUNCTION
852         Creates a fresh device structure to be filled by the stack during
853         enumeration.
855         The device will be linked into stack device list. psdLockWritePBase()
856         will be called to ensure that the list is protected from other tasks
857         during that phase.
859         The hub class is probably the only class that will use this call and
860         then psdEnumerateDevice() to fill in the data.
862    INPUTS
863         phw - pointer to a hardware structure.
865    RESULT
866         pd - pointer to a device structure (private),
867              or NULL if the allocation failed.
869    SEE ALSO
870         psdFreeDevice(), psdEnumerateDevice()
873 \fposeidon.library/psdAllocPipe                   poseidon.library/psdAllocPipe
875    NAME
876         psdAllocPipe -- allocate a pipe for transfer requests
878    SYNOPSIS
879         pp = psdAllocPipe(pd, mp, ep);
880         D0                A0  A1  A2
882         APTR psdAllocPipe(APTR, struct MsgPort *, APTR);
884    FUNCTION
885         psdAllocPipe() is the main function to establish a transport pipe to
886         a device endpoint.
888         After you have allocated a pipe, you can start sending or receiving
889         packets using psdDoPipe() or psdSendPipe(). If you do not need a pipe
890         anymore, use psdFreePipe() to get rid of it.
892         Pipes allocated with this function are automatically assigned to the
893         given endpoint. If you want to establish a pipe to the default
894         control pipe, use a NULL pointer for ep. The settings of the pipe
895         will be read from the endpoint configuration. Additional flags like
896         PPA_NakTimeout can be changed using psdSetAttrs().
898         Note that there is no limit to the amount of pipes you can allocate
899         for an endpoint. This can be used to create asynchronous double
900         buffered transfers.
902    INPUTS
903         pd - pointer to the device structure you want to allocate the pipe
904              at.
905         mp - pointer to a MsgPort that is used for sending the pipe messages.
906              Must not be NULL.
907         ep - pointer to an endpoint structure or NULL if you want to use the
908              default endpoint.
910    RESULT
911         pp - pipe structure allocated or NULL if something failed.
913    SEE ALSO
914         psdFreePipe(), psdDoPipe(), psdSendPipe()
917 \fposeidon.library/psdAllocVec                     poseidon.library/psdAllocVec
919    NAME
920         psdAllocVec -- allocate memory for Poseidon system structures.
922    SYNOPSIS
923         memptr = psdAllocVec(size);
924         D0                   D0
926         APTR psdAllocVec(ULONG);
928    FUNCTION
929         Allocates memory from the internal memory pool for Poseidon system
930         structures. The memory is of MEMF_PUBLIC|MEMF_CLEAR type. The memory
931         will be freed automatically on exit of Poseidon (or if linked to a
932         system structure, when the structure gets freed), so be sure that
933         this memory will not be needed somewhere else. Especially this memory
934         is NOT for internal use in your task! Use your own calls to the exec
935         memory functions instead.
937         Memory allocated by this function MUST be freed using psdFreeVec() or
938         linked to a system structure that is known to free this memory on
939         removal.
941    INPUTS
942         size - size in number of bytes for the to be allocated memory block.
944    RESULT
945         memptr - pointer to the requested memory block or NULL on failure.
947    SEE ALSO
948         psdFreeVec()
951 \fposeidon.library/psdClaimAppBinding       poseidon.library/psdClaimAppBinding
953    NAME
954         psdClaimAppBindingA -- try to establish a binding to a usb device
955         psdClaimAppBinding -- varargs stub for psdClaimAppBinding()
957    SYNOPSIS
958         pab = psdClaimAppBindingA(taglist);
959         D0                        A1
961         APTR psdClaimAppBindingA(struct TagList *);
963         pab = psdClaimAppBinding(tag1, ...);              
965         APTR psdClaimAppBinding(Tag, ...);
967    FUNCTION
968         This function tries to claim a device binding to a given device.
969         psdClaimAppBinding() is normally only used by applications, which
970         want to bypass the class model for the bindings.
972         The call will return a pointer to an internal AppBinding structure.
973         This chunk of data will be available only as long as the binding
974         exists. As soon as the device is unplugged, the structure will be
975         deallocated. To provide a simple notification mechanism, you MUST
976         pass a Hook structure using the TagList, which will be called just
977         BEFORE the structure gets freed. Normally your function should then
978         abort all running pipe transfers of your main program and shut down
979         further access to the device.
981         As this abortion operation sometimes may be difficult to control with
982         the asynchronous hook call, the device structure will not be freed to
983         avoid crashes, IF AND ONLY IF there are still some pipes allocated
984         for this device. However, all further transactions will be denied
985         with an IOERR_ABORTED error code. A call to psdFreePipe(), closing
986         the last pipe will finally free the device data. Even if the device
987         is plugged in again, it will not be re-enabled (as there is no
988         reliable operation to return the device to its previous state and
989         ensure, that this is really the same one unplugged earlier).
991         If you wish to terminate the binding yourself, just call
992         psdReleaseAppBinding() with the AppBinding context yourself. Be SURE
993         that the application binding still exists. This will also call your
994         hook.
996         The whole acquiration process should be protected with
997         psdLockReadPBase() and psdUnlockPBase().
999    NOTE
1000         You may not use devices directly, without adding an application
1001         binding with psdClaimAppBinding(). This will provide you with a good
1002         mechanism to find out if the device you are using gets unplugged and
1003         will also ensure exclusive usage.
1005    INPUTS
1006         taglist - pointer to TagItem list, terminated by TAG_END.
1008    TAGS
1009         ABA_ReleaseHook (struct Hook *) - pointer to a function hook that
1010             will be called if the binding must be terminated (e.g. when the
1011             device has been unplugged). After this call the application
1012             binding structure will be gone. The device will also be freed, if
1013             there are no open pipes anymore. This hook also will be called
1014             from psdReleaseAppBinding(). THIS TAG IS MANDATORY!
1015         ABA_Device (APTR) - pointer to the device that should be bound.
1016             THIS TAG IS MANDATORY!
1017         ABA_UserData (ULONG) - pointer to auxillary data for your private
1018             use.
1020    RESULT
1021         pab - pointer to the internal AppBinding structure, if the binding
1022               could be established, or NULL, if it failed. This pointer is
1023               also available via the DA_Binding field of the device.
1025    SEE ALSO
1026         psdReleaseAppBinding(), psdLockReadPBase(), psdUnlockPBase(),
1027         psdFindDevice()
1030 \fposeidon.library/psdClassScan                   poseidon.library/psdClassScan
1032    NAME
1033         psdClassScan -- bind devices and interface to available classes
1035    SYNOPSIS
1036         psdClassScan();
1038         void psdClassScan();
1040    FUNCTION
1041         Traverses all devices currently available in the stack and tries to
1042         establish bindings between those devices and its interfaces with usb
1043         class drivers available, each at a time.
1045    SEE ALSO
1046         psdAddClass(), psdRemClass()
1049 \fposeidon.library/psdCopyStr                       poseidon.library/psdCopyStr
1051    NAME
1052         psdCopyStr -- allocate memory for and copy a given string
1054    SYNOPSIS
1055         newstrptr = psdCopyStr(strptr);
1056         D0                     A0
1058         STRPTR psdCopyStr(STRPTR);
1060    FUNCTION
1061         psdCopyStr() takes a NULL-terminated string and copies its contents
1062         to a newly allocated buffer. The pointer to this buffer is returned
1063         as result.
1065         The memory will be allocated from the internal memory pool and must
1066         be freed using psdFreeVec(). DO NOT allocate memory this way if
1067         you're not going to free the memory while you've got the
1068         poseidon.library open. This memory CAN and WILL go away whenever the
1069         library is expunged.
1071         This function returns NULL, if something went wrong.
1073    INPUTS
1074         strptr - pointer to the string to be copied.
1076    RESULT
1077         newstrptr - pointer to the copied string buffer or NULL on
1078                     failure.
1080    SEE ALSO
1081         psdFreeVec()
1084 \fposeidon.library/psdDelayMS                       poseidon.library/psdDelayMS
1086    NAME
1087         psdDelayMS -- wait for a given amount of milliseconds
1089    SYNOPSIS
1090         psdDelayMS(milli);
1091                    D0
1093         void psdDelayMS(ULONG);
1095    FUNCTION
1096         Delays the execution of the current task by the given amount of
1097         milliseconds. The call is guaranteed to wait at least that amount of
1098         milliseconds, but as usually in a multitasking environment, the call
1099         could also take longer to return.
1101    INPUTS
1102         milli - number of milliseconds to wait.
1105 \fposeidon.library/psdDoPipe                         poseidon.library/psdDoPipe
1107    NAME
1108         psdDoPipe -- synchronous transfer to endpoint
1110    SYNOPSIS
1111         ioerr = psdDoPipe(pp, data, length);
1112         D0                A1  A0    D0
1114         LONG psdDoPipe(APTR, APTR, ULONG);
1116    FUNCTION
1117         Start a transfer to an endpoint. Waits until the request is done and
1118         then returns zero, if everything went okay, or an error code
1119         otherwise. See devices/usbhardware.h for a list of errors.
1121    NOTE
1122         The direction of the transfer is determined by the type of the
1123         endpoint for bulk, interrupt and isochronous transfers. For control
1124         transfers, however, this is given by the URTF_IN/URTF_OUT flags in
1125         the bmRequestType field of the setup packet, which can be set by
1126         psdPipeSetup(). For control transfers without data phase, using a
1127         NULL pointer for data and zero for the length is permitted. Also,
1128         the wLength field of the setup packet is filled automatically with
1129         the correct length of your data transfer request.
1131         Note well that this call will hang until the request is answered. In
1132         the case of interrupt transfers, this may never happen at all. Use
1133         psdSendPipe() for those cases or enable the NAK timeout feature using
1134         psdSetAttrs().
1136         psdDoPipe() is just a call to psdSendPipe() followed by a
1137         psdWaitPipe().
1139    INPUTS
1140         pp - pointer to pipe structure to send the request to.
1141         data - pointer to the data buffer to send or receive.
1142         length - number of bytes to transfer
1144    RESULT
1145         ioerr - zero, if everything went okay, else the IO error code.
1147    SEE ALSO
1148         psdPipeSetup(), psdSendPipe(), psdAbortPipe(), psdWaitPipe()
1151 \fposeidon.library/psdEnumerateDevice       poseidon.library/psdEnumerateDevice
1153    NAME
1154         psdEnumerateDevice -- start the enumeration process for a new device
1156    SYNOPSIS
1157         pd = psdEnumerateDevice(pp);
1158         D0                      A1
1160         APTR psdEnumerateDevice(APTR);
1162    FUNCTION
1163         This function is used to enumerate a device that is still on the bus
1164         without having a valid address and still unconfigured. It will be
1165         called by the psdEnumerateHardware() function (for the root hub) and
1166         the hub class for devices connected downstream.
1168         psdLockWriteDevice() will be called to ensure that the device is
1169         protected from other tasks during that phase.
1171    INPUTS
1172         pp - pointer to a default control pipe, allocated with psdAllocPipe()
1173              on the freshly created device using psdAllocDevice()
1175    RESULT
1176         pd - pointer to the device structure (private), or NULL if the
1177              enumeration failed.
1179    SEE ALSO
1180         psdAllocDevice(), psdFreeDevice(), psdEnumerateHardware(),
1181         psdAllocPipe()
1184 \fposeidon.library/psdEnumerateHardware   poseidon.library/psdEnumerateHardware
1186    NAME
1187         psdEnumerateHardware -- start enumeration of the root hub
1189    SYNOPSIS
1190         pd = psdEnumerateHardware(phw);
1191         D0                        A0
1193         APTR psdEnumerateHardware(APTR);
1195    FUNCTION
1196         After the hardware has been allocated, the root device of the
1197         hardware (normally the root hub) must be enumerated using
1198         psdEnumerateHardware(). It adds the initial device to the device list
1199         if it configures correctly.
1201         The next step then is just to call psdClassScan() which will do the
1202         rest.
1204    INPUTS
1205         phw - pointer to a previously allocated hardware.
1207    RESULT
1208         pd - pointer to the root device, or NULL if configuration
1209              failed.
1211    SEE ALSO
1212         psdAllocHardware(), psdFreeHardware(), psdClassScan()
1215 \fposeidon.library/psdFindDevice                 poseidon.library/psdFindDevice
1217    NAME
1218         psdFindDeviceA -- find a specific device in the device list
1219         psdFindDevice -- varargs stub for psdFindDeviceA()
1221    SYNOPSIS
1222         pd = psdFindDeviceA(oldpd, taglist);
1223         D0                  A0      A1
1225         APTR psdFindDeviceA(APTR, struct TagList *);
1227         pd = psdFindDevice(oldpd, tag1, ...);
1229         APTR psdFindDevice(APTR, Tag, ...);
1231    FUNCTION
1232         Just like psdGetNextDevice(), psdFindDevice() is used to traverse the
1233         list of all devices available to stack. The only difference is, that
1234         you can give certain attributes that the device has to match ALL tags
1235         to be returned by this function. The search will also cross all
1236         mounted hardware devices.
1238         psdFindDevice() needs to be protected with a pair of
1239         psdLockReadPBase() and psdUnlockPBase() during traversal.
1241    NOTE
1242         You may not use devices directly, without adding an application
1243         binding with psdClaimAppBinding(). This will provide you with a good
1244         mechanism to find out if the device you are using gets unplugged and
1245         will also ensure exclusive usage.
1247    INPUTS
1248         oldpd - NULL for the first device or pointer to the last device
1249                 found.
1250         taglist - pointer to TagItem list, terminated by TAG_END. Every given
1251                   tag must match to return the device.
1253    TAGS
1254         Not all available tags are supported. Here's a list of what seemed
1255         sensible to add:
1257         DA_Class (UWORD) - Class code to match. Note that most devices
1258             use interface class codes instead of device class codes.
1259         DA_SubClass (UWORD) - Subclass code to match.
1260         DA_Protocol (UWORD) - Protocol code to match.
1261         DA_VendorID (UWORD) - Vendor ID number. This is a 
1262         DA_ProductID (UWORD) - Vendor specific product ID. Only valid, if
1263             DA_HasDevDesc is TRUE.
1264         DA_Version (UWORD) - BCD number of device/product version. Only
1265             valid, if DA_HasDevDesc is TRUE.
1266         DA_Manufacturer (STRPTR) - pointer to a manufacturer string. If no
1267             manufacturer string could be read from the device, Poseidon
1268             will generate a string out of the vendor ID. Be sure to handle
1269             a NULL pointer. Only valid, if DA_HasDevDesc is TRUE.
1270         DA_ProductName (STRPTR) - pointer to the product name. If no product
1271             name could be read from the device, Poseidon will generate one
1272             out of the class, the vendor and the product ID. Be sure to
1273             handle a NULL pointer. Only valid, if DA_HasDevDesc is TRUE.
1274         DA_Binding (APTR) - normally used with an NULL pointer to ensure the
1275             device has no binding already.
1277    RESULT
1278         pd - pointer to the device found in the list, or NULL if there was no
1279              device matching the criteria.
1281    SEE ALSO
1282         psdLockReadPBase(), psdUnlockPBase(), psdGetNextDevice(),
1283         psdClaimAppBinding(), psdReleaseAppBinding()
1286 \fposeidon.library/psdFreeDevice                 poseidon.library/psdFreeDevice
1288    NAME
1289         psdFreeDevice -- deallocate a device and free all bindings
1291    SYNOPSIS
1292         psdFreeDevice(pd);
1293                       A0
1295         void psdFreeDevice(APTR);
1297    FUNCTION
1298         Removes and deallocates the given device from the system. All
1299         previously allocated configuration structures and class bindings will
1300         be freed aswell. The pointer becomes invalid right after.
1302         psdFreeDevice() will use the semaphore protection of
1303         psdLockWritePBase().
1305    INPUTS
1306         pd - pointer to a device structure.
1308    SEE ALSO
1309         psdAllocDevice()
1312 \fposeidon.library/psdFreePipe                     poseidon.library/psdFreePipe
1314    NAME
1315         psdFreePipe -- free a previously allocated pipe
1317    SYNOPSIS
1318         psdFreePipe(pp);
1319                     A1
1321         void psdFreePipe(APTR);
1323    FUNCTION
1324         Deallocate a pipe created with psdAllocPipe() before. The pp pointer
1325         becomes invalid right after this call.
1327         Be sure that there is no request pending for this pipe. If you have
1328         ever done asynchronous IO, you should call psdAbortPipe() and
1329         psdWaitPipe() before psdFreePipe() to be on the safe side.
1331    INPUTS
1332         pp - pointer to pipe structure to deallocate.
1334    SEE ALSO
1335         psdAllocPipe(), psdSendPipe(), psdAbortPipe(), psdWaitPipe()
1338 \fposeidon.library/psdFreeVec                       poseidon.library/psdFreeVec
1340    NAME
1341         psdFreeVec -- free memory allocated by psdAllocVec()
1343    SYNOPSIS
1344         psdFreeVec(memptr);
1345                    A1
1347         void psdFreeVec(APTR);
1349    FUNCTION
1350         Frees the memory allocated by psdAllocVec(). Do not pass any other
1351         pointer to this function. Be sure that the given vector is not linked
1352         to any internal structure or memory might be freed twice.
1354    INPUTS
1355         memptr - pointer to the memory block allocated using psdAllocVec()
1356                  or NULL.
1358    SEE ALSO
1359         psdAllocVec()
1362 \fposeidon.library/psdGetAttrs                     poseidon.library/psdGetAttrs
1364    NAME
1365         psdGetAttrsA -- get information from an internal stack structure
1366         psdGetAttrs -- varargs stub for psdGetAttrsA()
1368    SYNOPSIS
1369         num = psdGetAttrsA(type, psdstruct, taglist);
1370         D0                 D0    A0         A1
1372         LONG psdGetAttrsA(ULONG, APTR, struct TagList *);
1374         num = psdGetAttrs(type, psdstruct, tag1, ...);
1376         LONG psdGetAttrs(ULONG, APTR, Tag, ...);
1378    FUNCTION
1379         Acquires attribute information from an internal stack structure,
1380         according to the attributes chosen in the tag list. For each entry in
1381         the tag list, ti_Tag identifies the attribute and ti_Data is a
1382         pointer to the IPTR variable where you wish the result to be stored.
1384         There are currently a number of ten different system structures which
1385         can be accessed in this way. To avoid adding multiple functions with
1386         the same semantics, psdGetAttrs() requires the type of the structure
1387         passed.
1389    INPUTS
1390         type - describes the type of the structure passed.
1391                See libraries/poseidon.h for details.
1392         psdstruct - pointer to the system structure on which information
1393                     should be gathered. Can be NULL only for PGA_STACK.
1394         taglist - pointer to TagItem list, terminated by TAG_END.
1396    TAGS
1397         All tags are read-only, except stated otherwise.
1399         PGA_STACK: (read-only)
1400         PA_HardwareList (struct List *) - pointer to the list of hardware in
1401             the system.
1402         PA_ClassList (struct List *) - pointer to the list of classes.
1403         PA_ErrorMsgList (struct List *) - pointer to the list of error
1404             messages, that have been encountered so far. The entries in this
1405             list are only valid inside a Forbid()/Permit() clause.
1407         PGA_ERRORMSG: (read-only)
1408         EMA_Level (UWORD) - level indicating the severeness of an error.
1409             Normally corresponds to RETURN_OK, RETURN_WARN, RETURN_ERROR, and
1410             RETURN_FAIL of dos/dos.h.
1411         EMA_Origin (STRPTR) - points to the name of the module that caused
1412             the error.
1413         EMA_Msg (STRPTR) - a pointer to the error message itself.
1415         PGA_USBCLASS: (read-only)
1416         UCA_ClassBase (struct Library *) - base pointer of the class library.
1417             You should consider opening the library using OpenLibrary() and
1418             UCA_ClassName, instead of using UCA_ClassBase directly.
1419         UCA_ClassName (STRPTR) - pointer to the name string of the class.
1420         UCA_UseCount (UWORD) - number of bindings active with this class.
1422         PGA_HARDWARE: (read-only)
1423         HA_DeviceName (STRPTR) - pointer to the name string of the device
1424             driver, opened by OpenDevice().
1425         HA_DeviceUnit (ULONG) - unit number of the hardware device.
1426         HA_ProductName (STRPTR) - product name of the usb hardware board.
1428         PGA_DEVICE: (partially read/write)
1429         DA_Address (UWORD) - device address on the usb bus. Only valid, if
1430             DA_HasAddress is TRUE.
1431         DA_NumConfigs (UWORD) - number of configs available for this device.
1432             Only valid, if DA_HasDevDesc is TRUE.
1433         DA_CurrConfig (UWORD) - id number of active configuration.
1434         DA_HubDevice (APTR) - pointer to the hub device the device is
1435             connected to or NULL for the root hub. May be changed, but is
1436             only sensible of doing so by the hub class.
1437         DA_UsbVersion (UWORD) - BCD number with the version of usb spec this
1438             device follows. Only valid, if DA_HasDevDesc is TRUE.
1439         DA_Class (UWORD) - Class code of the device. Note that most devices
1440             use interface class codes instead of device class codes. Only
1441             valid, if DA_HasDevDesc is TRUE.
1442         DA_SubClass (UWORD) - Subclass code. Only valid, if DA_HasDevDesc is
1443             TRUE.
1444         DA_Protocol (UWORD) - Protocol code. Only valid, if DA_HasDevDesc is
1445             TRUE.
1446         DA_VendorID (UWORD) - Vendor ID number. Can be converted into a
1447             string using PsdNumToStr(). Only valid, if DA_HasDevDesc is TRUE.
1448         DA_ProductID (UWORD) - Vendor specific product ID. Only valid, if
1449             DA_HasDevDesc is TRUE.
1450         DA_Version (UWORD) - BCD number of device/product version. Only
1451             valid, if DA_HasDevDesc is TRUE.
1452         DA_Manufacturer (STRPTR) - pointer to a manufacturer string. If no
1453             manufacturer string could be read from the device, Poseidon will
1454             generate a string out of the vendor ID. Be sure to handle a NULL
1455             pointer. Only valid, if DA_HasDevDesc is TRUE.
1456         DA_ProductName (STRPTR) - pointer to the product name. If no product
1457             name could be read from the device, Poseidon will generate one
1458             out of the class, the vendor and the product ID. Be sure to
1459             handle a NULL pointer. Only valid, if DA_HasDevDesc is TRUE.
1460         DA_Hardware (APTR) - uplinking pointer to the hardware structure the
1461             device is running on.
1462         DA_LangIDArray (UWORD *) - pointer to a null terminated array of
1463             languages the devices understands. If no such information could
1464             be acquired, this will be a NULL pointer. The LangIDs can be
1465             converted into readable strings using a call to psdNumToStr().
1466         DA_CurrLangID (UWORD) - ID of the language the device is using
1467             currently. The stack will try to set a sensible value here
1468             during enumeration. This value can also be modified, but will
1469             only effect future calls to PsdGetStringDescriptor(), not prior
1470             ones.
1471         DA_Binding (APTR) - pointer to class private binding structure which
1472             currently has a binding to the device or NULL, if no class
1473             claimed it. If DA_HasAppBinding is TRUE, this is a pointer to the
1474             AppBinding structure.
1475         DA_BindingClass (struct Library *) - class currently having a device
1476             binding. Only valid if DA_Binding is not NULL AND
1477             DA_HasAppBinding is FALSE.
1478         DA_IsLowspeed (BOOL) - Determines if the device is a lowspeed or full
1479             speed device. Can be set, but this will probably ever used by the
1480             hub class.
1481         DA_IsConnected (BOOL) - is TRUE, if the device is still mounted to
1482             the USB or FALSE, if it has been disconnected. This is normally
1483             the first thing to check whenever your pipe requests come back
1484             with UHIOERR_TIMEOUT. Hence, avoid transfers to unconnected
1485             devices.
1486         DA_HasAddress (BOOL) - is TRUE, if the device has been assigned an
1487             address. Normally, no devices with DA_HasAddress set to FALSE
1488             will remain in the system.
1489         DA_HasDevDesc (BOOL) - TRUE, if the stack was able to read out the
1490             device descriptor. this will yield information like product ID,
1491             device class etc.. FALSE, if something went wrong.
1492         DA_IsConfigured (BOOL) - yields TRUE, if there is an configuration to
1493             work with. This means that you can look at the list of
1494             configurations and may also expect interface and endpoint
1495             descriptors. If something went wrong during the config probing
1496             process, this returns FALSE.
1497         DA_HasAppBinding (BOOL) - yields TRUE, if there is an application
1498             binding.
1499         DA_ConfigList (struct List *) - pointer to the list of
1500             configurations available for this device.
1502         PGA_CONFIG: (read-only)
1503         CA_ConfigNum (UWORD) - returns the internal number of the config
1504             given. Can be used to set the config with psdSetDeviceConfig().
1505         CA_ConfigName (STRPTR) - gives back a name for the config. If no
1506             specific name could be read out from the device, Poseidon
1507             will generate a default string.
1508         CA_MaxPower (UWORD) - returns the maximum power in mA the device
1509             will use in this configuration.
1510         CA_NumInterfaces (UWORD) - holds the number of interfaces available
1511             in this configuration.
1512         CA_Device (APTR) - uplinking pointer to the device the config is
1513             attached to.
1514         CA_InterfaceList (struct List *) - pointer to the list of interfaces
1515             available for the config.
1516         CA_Attrs (UWORD) - attributes for this config (see USB specs).
1517         CA_SelfPowered (BOOL) - if the device is self-powered in this config,
1518             this flag will return TRUE. On FALSE, device is in bus-powered
1519             mode.
1520         CA_RemoteWakeup (BOOL) - in the case the device supports the remote
1521             wakeup feature, this field will be TRUE.
1523         PGA_INTERFACE: (read-only)
1524         IFA_InterfaceNum (UWORD) - returns the interface number.
1525         IFA_AlternateNum (UWORD) - if the interface has alternative settings,
1526             this will be its number, otherwise just zero.
1527         IFA_InterfaceName (STRPTR) - pointer to a string describing the
1528             interface. Poseidon will generate a default string if no specific
1529             name could be read from the device.
1530         IFA_Class (UWORD) - class code of the interface. See devices/usb.h
1531             for the list of known classes. psdNumToStr() may be used to
1532             convert this number into human readable form.
1533         IFA_SubClass (UWORD) - class dependant subclass code. Some subclasses
1534             are defined in devices/usb.h.
1535         IFA_Protocol (UWORD) - class specific protocol code.
1536         IFA_NumEndpoints (UWORD) - number of endpoints available for this
1537             interface, excluding the default control endpoint 0.
1538         IFA_Binding (APTR) - pointer to a private binding structure, if the
1539             interface has been claimed by a class or NULL, if no binding
1540             exists.
1541         IFA_BindingClass (struct Library *) - library pointer of the class
1542             having a binding to this interface. Only valid if IFA_Binding is
1543             not NULL.
1544         IFA_Config (APTR) - uplinking pointer to the config the interface is
1545             attached to.
1546         IFA_EndpointList (struct List *) - pointer to the list of endpoints
1547             available for this interface.
1548         IFA_AlternateIfList (struct List *) - pointer to the list of
1549             alternate settings available. The entries in this list are normal
1550             interface structures except for the IFA_Binding and
1551             IFA_BindingClass are not valid in the alternative setting. To
1552             make this setting the active one, use psdSetAltInterface().
1554         PGA_ENDPOINT: (read-only)
1555         EA_EndpointNum (UWORD) - number of the endpoint.
1556         EA_TransferType (UWORD) - transfer type, either USEAF_CONTROL,
1557             USEAF_ISOCHRONOUS, USEAF_BULK or USAEF_INTERRUPT
1558             (see devices/usb.h).
1559         EA_MaxPktSize (UWORD) - returns the MaxPktSize for this endpoint.
1560         EA_Interval (UWORD) - for interrupt endpoints, this field will
1561             contain the interval in milliseconds before the request should be
1562             retried.
1563         EA_Interface (APTR) - uplinking pointer to the interface the endpoint
1564             is attached to.
1565         EA_IsIn (BOOL) - returns TRUE for IN (device to host) endpoints or
1566             FALSE for OUT (host to device) endpoints.
1568         PGA_PIPE: (partially read/write)
1569         PPA_Endpoint (APTR) - pointer to the endpoint the pipe is associated
1570             with or NULL for default endpoint 0. Can be set by the user.
1571         PPA_EndpointNum (UWORD) - number of target endpoint. This field can
1572             be written for special 'hacking' purpose.
1573         PPA_DeviceAddress (UWORD) - device address of the usb device. Can be
1574             changed, but consider this hacking, that might disturb other
1575             devices on the bus.
1576         PPA_Error (BYTE) - returns the error code for the last transfer. See
1577             devices/usbhardware.h for the list of possible errors. This error
1578             code can also be converted to readable format using a call to
1579             psdNumToStr().
1580         PPA_Actual (ULONG) - number of bytes actually transferred during last
1581             pipe transfer.
1582         PPA_MaxPktSize (UWORD) - returns the number of bytes allowed for one
1583             packet. Can be changed (for good reasons only).
1584         PPA_IORequest (struct UsbHWIOReq *) - pointer to the IO request used
1585             by the pipe. Note that you will probably never wish to read or
1586             change fields in this IORequest yourself. Use the tags instead.
1587         PPA_NakTimeout (BOOL) - if set to TRUE, the pipe will be retired
1588             after the time given with PPA_NakTimeoutTime, when the device
1589             constantly replies with NAKs. This could be the case if no data
1590             is available at the endpoint, or the usb device is broken in some
1591             way. Default is FALSE, which means that the pipe will never be
1592             retired due to NAKs. Can be both read and written.
1593         PPA_NakTimeoutTime (ULONG) - time to wait in milliseconds until the
1594             request is retired due to NAK timeout (see above). This field can
1595             and should be written, if PPA_NakTimeout is set to TRUE.
1596         PPA_NoShortPackets (BOOL) - if set to TRUE, no short package (packet
1597             with size shorter than MaxPktSize) will be generated on OUT
1598             transfers, if this bit is set. This allows you to generate a
1599             constant stream of data with multiple requests. To be effective,
1600             the transfer size must be a multiple of MaxPktSize.
1601         PPA_AllowRuntPackets (BOOL) - allow packets that are smaller than the
1602             number of bytes specified without returning UHIOERR_RUNTPACKET.
1603             You will have to read the PPA_Actual field (or use
1604             psdGetPipeActual()) to get the actual amount of data transferred.
1606         PGA_APPBINDING: (read/write)
1607         ABA_ReleaseHook (struct Hook *) - pointer to a function hook that
1608             will be called if the binding must be terminated (e.g. when the
1609             device has been unplugged). After this call the application
1610             binding structure will be gone (see psdClaimAppBinding() for more
1611             details). The device will also be freed, if there are no open
1612             pipes anymore. This hook also will be called from
1613             psdReleaseAppBinding().
1614         ABA_Device (APTR) - pointer to the device that is bound with this
1615             binding. Do not change this while running.
1616         ABA_UserData (ULONG) - pointer to auxillary data for your private
1617             use.
1619    RESULT
1620         num - number of tags actually read or -1, if the request was not
1621               supported somehow.
1623    SEE ALSO
1624         psdSetAttrs(), psdNumToStr()
1627 \fposeidon.library/psdGetNextDevice           poseidon.library/psdGetNextDevice
1629    NAME
1630         psdGetNextDevice -- traverse the device list
1632    SYNOPSIS
1633         pd = psdGetNextDevice(oldpd);
1634         D0                    A0
1636         APTR psdGetNextDevice(APTR);
1638    FUNCTION
1639         psdGetNextDevice() is used to traverse the list of all devices
1640         available to stack. It will also cross all mounted hardware devices.
1642         psdGetNextDevice() needs to be protected with a pair of
1643         psdLockReadPBase() and psdUnlockPBase() during traversal.
1645    INPUTS
1646         oldpd - NULL for the first device, or pointer to the last device.
1648    RESULT
1649         pd - pointer to the next device in the list, or NULL if there was no
1650              further device.
1652    SEE ALSO
1653         psdLockReadPBase(), psdUnlockPBase(), psdFindDevice()
1656 \fposeidon.library/psdGetPipeActual           poseidon.library/psdGetPipeActual
1658    NAME
1659         psdGetPipeActual -- get amount of bytes transferred with a pipe
1661    SYNOPSIS
1662         length = psdGetPipeActual(pp);
1663         D0                        A1
1665         ULONG psdGetPipeActual(APTR);
1667    FUNCTION
1668         psdGetPipeActual() is used to determine the amount of data
1669         transferred during the last pipe transfer. This will be neccessary if
1670         you allowed the reception of runt packets enabled with the
1671         PPA_ALLOWRUNTPACKETS tag.
1673    NOTE
1674         You can also use psdGetAttrs() to read the actual length.
1676    INPUTS
1677         pp - pointer to pipe structure to send the request to.
1679    RESULT
1680         length - number of bytes transferred during last pipe transaction.
1682    SEE ALSO
1683         psdGetPipeError(), psdSendPipe(), psdAbortPipe(), psdGetAttrs()
1686 \fposeidon.library/psdGetPipeError             poseidon.library/psdGetPipeError
1688    NAME
1689         psdGetPipeError -- get last IO error from a pipe
1691    SYNOPSIS
1692         ioerr = psdGetPipeError(pp);
1693         D0                      A1
1695         LONG psdGetPipeError(APTR);
1697    FUNCTION
1698         Returns the IO error of the last transfer with the given pipe.
1699         Whenever you are using asynchronous pipe transfers, you will have to
1700         read the error code yourself from the pipe.
1702    NOTE
1703         You can also use psdGetAttrs() to read the error code.
1705         Error codes can be converted into human readable strings using the
1706         psdNumToStr() function.
1708    INPUTS
1709         pp - pointer to pipe structure to send the request to.
1711    RESULT
1712         ioerr - zero, if everthing went okay, else the IO error code.
1714    SEE ALSO
1715         psdGetPipeActual(), psdSendPipe(), psdAbortPipe(), psdGetAttrs()
1718 \fposeidon.library/psdGetStringDescriptor seidon.library/psdGetStringDescriptor
1720    NAME
1721         psdGetStringDescriptor -- try to get a device string descriptor
1723    SYNOPSIS
1724         str = psdGetStringDescriptor(pp, idx);
1725         D0                           A1  D0
1727         STRPTR psdAddClass(APTR, UWORD);
1729    FUNCTION
1730         Tries to read out a device string descriptor with the given index.
1731         Automatically does the unicode to ascii conversion and allocates
1732         enough memory to hold the final string.
1734         On the first invocation on a device, it also tries to acquire the
1735         array of supported languages and sets the current language to a
1736         reasonable value.
1738         The returned string buffer should be freed using psdFreeVec(), if it
1739         is not linked to some stack internal structure.
1741    INPUTS
1742         pp - pointer to the default control pipe of a device.
1743         idx - index number of the string to fetch.
1745    RESULT
1746         str - pointer to a newly created buffer with the string fetched,
1747               or NULL if something failed.
1749    SEE ALSO
1750         psdFreeVec()
1753 \fposeidon.library/psdLockReadDevice         poseidon.library/psdLockReadDevice
1755    NAME
1756         psdLockReadDevice -- lock device for reading
1758    SYNOPSIS
1759         psdLockReadDevice(pd);
1760                           A0
1762         void psdLockReadDevice(APTR);
1764    FUNCTION
1765         This function locks the access to the internal device structures for
1766         reading. This can be used to ensure the data and pointers remain
1767         valid during querying with GetAttrs().
1769         psdLockReadDevice() calls nest.
1771         Be sure to unlock the device after the use or you will hang the stack
1772         very quickly.
1774         Normal classes will probably not need to use this call, so it is
1775         considered to be at least semi-private.
1777    WARNING
1778         Be sure NOT to have locked the base for reading if you want to lock
1779         the base for writing later. THIS WILL CAUSE A DEADLOCK! It is
1780         possible to lock the base for reading AFTER having claimed a writing
1781         lock, but not the other way round!
1783    SEE ALSO
1784         psdUnlockDevice(), psdLockWriteDevice(), psdGetNextDevice()
1787 \fposeidon.library/psdLockReadPBase           poseidon.library/psdLockReadPBase
1789    NAME
1790         psdLockReadPBase -- lock access to internal data structures
1792    SYNOPSIS
1793         psdLockReadPBase();
1795         void psdLockReadPBase(void);
1797    FUNCTION
1798         This function locks the access to internal data structures for
1799         reading. This especially includes traversal of lists, like classes,
1800         devices, and hardware (which could change at any time otherwise).
1802         psdLockReadPBase() calls nest.
1804         Be sure to unlock the base after the use or you will hang the stack
1805         very quickly. Try to keep the locking stage as short as possible.
1807         Normal classes will probably not need to use this call, so it is
1808         considered to be at least semi-private.
1810    WARNING
1811         Be sure NOT to have locked the base for reading if you want to lock
1812         the base for writing later. THIS WILL CAUSE A DEADLOCK! It is
1813         possible to lock the base for reading AFTER having claimed a writing
1814         lock, but not the other way round!
1816    SEE ALSO
1817         psdUnlockPBase(), psdLockWritePBase(), psdGetNextDevice()
1820 \fposeidon.library/psdLockWriteDevice       poseidon.library/psdLockWriteDevice
1822    NAME
1823         psdLockWriteDevice -- lock access for changing device structures
1825    SYNOPSIS
1826         psdLockWriteDevice(pd);
1827                            A0
1829         void psdLockWriteDevice(APTR);
1831    FUNCTION
1832         This function locks the access to a device structure for writing.
1833         This will only be neccessary if you change some linkages and
1834         structures inside the device, which you will probably never do.
1836         Note that for some poseidon calls like psdEnumerateDevice(), the
1837         locking and unlocking is done automatically. Refer to the docs for
1838         that call.
1840         psdLockWriteDevice() calls nest.
1842         Be sure to unlock the base after the use or you will hang the stack
1843         very quickly.
1845         Normal classes will probably not need to use this call, so it is
1846         considered to be at least semi-private.
1848    WARNING
1849         Be sure NOT to have locked the device for reading if you want to lock
1850         the device for writing later. THIS WILL CAUSE A DEADLOCK! It is
1851         possible to lock it for reading AFTER having claimed a writing lock,
1852         but not the other way round!
1854    SEE ALSO
1855         psdUnlockDevice(), psdLockReadDevice(), psdEnumerateDevice()
1858 \fposeidon.library/psdLockWritePBase         poseidon.library/psdLockWritePBase
1860    NAME
1861         psdLockWritePBase -- lock access for changing structures
1863    SYNOPSIS
1864         psdLockWritePBase();
1866         void psdLockWritePBase(void);
1868    FUNCTION
1869         This function locks the access to internal data structures for your
1870         exclusive manipulation. The base must be locked whenever you are
1871         going to add or remove internal nodes, link or unlike system
1872         components.
1874         Note that for some poseidon calls like psdAllocDevice(), the locking
1875         and unlocking is done automatically. Refer to the docs for that call.
1877         psdLockWritePBase() calls nest.
1879         Be sure to unlock the base after the use or you will hang the stack
1880         very quickly.
1882         Normal classes will probably not need to use this call, so it is
1883         considered to be at least semi-private.
1885    WARNING
1886         Be sure NOT to have locked the base for reading if you want to lock
1887         the base for writing later. THIS WILL CAUSE A DEADLOCK! It is
1888         possible to lock the base for reading AFTER having claimed a writing
1889         lock, but not the other way round!
1891    SEE ALSO
1892         psdUnlockPBase(), psdLockReadPBase(), psdGetNextDevice()
1895 \fposeidon.library/psdNumToStr                     poseidon.library/psdNumToStr
1897    NAME
1898         psdNumToStr -- convert a value of certain meaning into a string
1900    SYNOPSIS
1901         str = psdNumToStr(type, idx, defstr);
1902         D0                D0    D1   A0
1904         STRPTR psdNumToStr(UWORD, LONG, STRPTR);
1906    FUNCTION
1907         psdNumToStr() is a support function which will convert IDs and other
1908         codes of known type into a readable string.
1910    NOTE
1911         This function adds about 36 KB to the library :)
1913    INPUTS
1914         type - code/value type. Currently this is one of these:
1915                NTS_IOERR - for io error codes
1916                NTS_LANGID - for USB language IDs
1917                NTS_TRANSTYPE - for transfer types
1918                NTS_VENDORID - for the USB vendor IDs
1919                NTS_CLASSCODE - for known class codes.
1920         idx - ID, number or code to convert.
1921         defstr - if no string is found in the database, this string will
1922                  be returned instead.
1924    RESULT
1925         str - pointer to the string corresponding to the code or defstr, if
1926               the code is unknown.
1929 \fposeidon.library/psdPipeSetup                   poseidon.library/psdPipeSetup
1931    NAME
1932         psdPipeSetup -- set request data for control pipes
1934    SYNOPSIS
1935         psdPipeSetup(pp, rt, rq, val, idx);
1936                      A1  D0  D1  D2   D3
1938         void psdPipeSetup(APTR, UWORD, UWORD, UWORD, UWORD);
1940    FUNCTION
1941         This function is used to configure a control pipe request. It sets
1942         the bmRequestType, bRequest, wValue and wIndex fields of the
1943         eight-byte setup packet (see devices/usb.h for more information). It
1944         also does the required big-endian to little-endian conversions on the
1945         wValue and wIndex fields.
1947         The wLength field is set automatically on psdDoPipe() or\v
1948         psdSendPipe().
1950    INPUTS
1951         pp - pointer to the control pipe allocated using psdAllocPipe()
1952         rt - bmRequestType field. This is a bitmap with the following flags:
1953              URTF_OUT - direction of the transfer is set to from host to
1954                  device (OUT). Normally, this is also used for control
1955                  transfers without data phase.
1956              URTF_IN - data is going to be read in (device to host) during
1957                  the data phase.
1958              URTF_STANDARD - this is a standard usb request.
1959              URTF_CLASS - this is a class specific request.
1960              URTF_VENDOR - this is a vendor specific request.
1961              URTF_DEVICE - the request is aimed at the whole device.
1962              URTF_INTERFACE - the request is targeted at an interface. For
1963                  standard usb requests, the interface number is given in the
1964                  wIndex field.
1965              URTF_ENDPOINT - the request is targeted at an endpoint. For
1966                  standard usb requests, the endpoint number is given in the
1967                  wIndex field or'ed with URTF_IN, if the endpoint is an IN
1968                  endpoint.
1969              URTF_OTHER - the request goes somewhere else.
1970         rq - request number for bRequest. See devices/usb.h for some standard
1971              requests.
1972         val - wValue in big-endian format. This is request specific.
1973         idx - wIndex in big-endian format. Also request specific.
1975    SEE ALSO
1976         psdDoPipe(), psdSendPipe()
1979 \fposeidon.library/psdReleaseAppBinding   poseidon.library/psdReleaseAppBinding
1981    NAME
1982         psdReleaseAppBinding -- release an application binding again
1984    SYNOPSIS
1985         psdReleaseAppBinding(pab);
1986                              A0
1988         void psdReleaseAppBinding(APTR);
1990    FUNCTION
1991         If you want to terminate using a device, you must release the binding
1992         previously acquired by psdClaimAppBinding(). This is done with a
1993         corresponding call to psdReleaseAppBinding(). The function will call
1994         your Hook function to allow you take the correct actions to avoid
1995         further calls to the device, as psdReleaseAppBinding() might also be
1996         called by the stack itself, when the device gets unplugged.
1998         The hook will be called via utility.library/CallHookPkt() with the
1999         hook structure itself in A0, the AppBinding as object in A2 and
2000         the contents of the ABA_UserData field as message in A1.
2002         As this abortion operation sometimes may be difficult to control with
2003         the asynchronous hook call, the device structure will not be freed to
2004         avoid crashes, IF AND ONLY IF there are still some pipes allocated
2005         for this device. However, all further transactions will be denied
2006         with an IOERR_ABORTED error code. A call to psdFreePipe(), closing
2007         the last pipe will finally free the device data. Even if the device
2008         is plugged in again, it will not be re-enabled (as there is no
2009         reliable operation to return the device to its previous state and
2010         ensure, that this is really the same one unplugged earlier).
2012         This function will free the AppBinding context, rendering further
2013         accesses to the pab pointer invalid.
2015    INPUTS
2016         pab - pointer to the internal AppBinding structure returned by
2017               psdClaimAppBinding() or psdGetAttrs() with the DA_Binding tag.
2018               Using a NULL pointer is okay, and will just do nothing.
2020    SEE ALSO
2021         psdClaimAppBinding(), psdFindDevice()
2024 \fposeidon.library/psdRemClass                     poseidon.library/psdRemClass
2026    NAME
2027         psdRemClass -- remove an usb class library from the stack
2029    SYNOPSIS
2030         psdRemClass(puc);
2031                     A1
2033         void psdRemClass(struct Library *);
2035    FUNCTION
2036         psdRemClass() removes an class library from the stack. The puc
2037         pointer will become invalid right after.
2039    NOTE
2040         If any bindings to interfaces or devices still exist, this call will
2041         try to remove all these bindings. If it does not succeed for
2042         impossible reasons, this call will go into Wait(0L) state.
2044    INPUTS
2045         puc - pointer to previously opened usb class.
2047    SEE ALSO
2048         psdAddClass(), psdClassScan()
2051 \fposeidon.library/psdRemHardware               poseidon.library/psdRemHardware
2053    NAME
2054         psdRemHardware -- close down an usb hardware
2056    SYNOPSIS
2057         psdRemHardware(phw);
2058                        A0
2060         void psdRemHardware(APTR);
2062    FUNCTION
2063         This function may be used to close down a previously allocated USB
2064         hardware using psdAllocHardware(). As all devices connected to the
2065         hardware will be closed down aswell, none of these devices may still
2066         have bindings. These bindings will be terminated aswell. For this
2067         reason, this call might take some time to complete.
2069         Normally, there is no use calling this function except for the stack
2070         manager (GUI) or the library expunge function.
2072         The phw hardware pointer becomes invalid right after.
2074    INPUTS
2075         phw - internal usb hardware pointer.
2077    SEE ALSO
2078         psdRemHardware(), psdEnumerateHardware()
2081 \fposeidon.library/psdRemErrorMsg               poseidon.library/psdRemErrorMsg
2083    NAME
2084         psdRemErrorMsg -- free an error message
2086    SYNOPSIS
2087         psdRemErrorMsg(pem);
2088                        A0
2090         void psdRemErrorMsg(APTR);
2092    FUNCTION
2093         Remove an error message from the list. This is a function which you
2094         probably will never use. Note that the pem pointer gets invalid right
2095         after this call.
2097         A pointer to the list of error messages can be acquired using
2098         psdGetAttrs(), but is only valid inside a Forbid()/Permit() clause.
2100    INPUTS
2101         pen - pointer to error message to deallocate.
2103    SEE ALSO
2104         psdAddErrorMsg()
2107 \fposeidon.library/psdSafeRawDoFmt             poseidon.library/psdSafeRawDoFmt
2109    NAME
2110         psdSafeRawDoFmtA -- add an error or information message for the user
2111         psdSafeRawDoFmt -- varargs stub for psdSafeRawDoFmtA
2113    SYNOPSIS
2114         psdSafeRawDoFmtA(buf, len, fmtstr, fmtdata);
2115                          A0   D0   A1      A2
2117         void psdSafeRawDoFmtA(STRPTR, ULONG, STRPTR, APTR);
2119         psdSafeRawDoFmt(buf, len, fmtstr, ...);
2121         APTR psdSafeRawDoFmt(STRPTR, ULONG, STRPTR, ...);
2123    FUNCTION
2124         Just like sprintf(), but avoid buffer overruns by truncating the
2125         string to the maximum buffer size.
2127    INPUTS
2128         buf - pointer to a buffer to store the formatted string in.
2129         len - size of this buffer.
2130         fmtstr - formatted string like in printf() or RawDoFmt()
2131         fmtdata - format parameters
2133    SEE ALSO
2134         RawDoFmt()
2137 \fposeidon.library/psdSendPipe                     poseidon.library/psdSendPipe
2139    NAME
2140         psdSendPipe -- initiate asynchronous pipe transfer
2142    SYNOPSIS
2143         psdSendPipe(pp, data, length);
2144                     A1  A0    D0
2146         void psdSendPipe(APTR, APTR, ULONG);
2148    FUNCTION
2149         Asynchronously start a transfer to an endpoint. Immediately returns
2150         from this call without waiting for it to terminate. You will get back
2151         the pipe request at the message port you gave when allocating the
2152         pipe when it is ready, triggering the MsgPort signal for you when it
2153         arrives.
2155         You can also use psdWaitPipe() to wait for the arrival of the
2156         message.
2158         It is illegal to reuse a pipe request while it is still pending! The
2159         contents of the pipe may not be altered during this phase. The
2160         restrictions are somewhat similar to the IORequests sent by the exec
2161         function SendIO().
2163         If you don't want to wait for the termination of a transfer, you can
2164         TRY to abort it using psdAbortPipe(), but you have still to wait for
2165         it to arrive.
2167         To get the error message, you can use the psdGetPipeError() function.
2169    NOTE
2170         The direction of the transfer is determined by the type of the
2171         endpoint for bulk, interrupt and isochronous transfers. For control
2172         transfers, however, this is given by the URTF_IN/URTF_OUT flags in
2173         the bmRequestType field of the setup packet, which can be set by
2174         psdPipeSetup(). For control transfers without data phase, using a
2175         NULL pointer for data and zero for the length is permitted. Also, the
2176         wLength field of the setup packet is filled automatically with the
2177         correct length of your data transfer request.
2179    INPUTS
2180         pp - pointer to pipe structure to send the request to.
2181         data - pointer to the data buffer to send or receive.
2182         length - number of bytes to transfer
2184    SEE ALSO
2185         psdPipeSetup(), psdDoPipe(), psdAbortPipe(), psdWaitPipe(),
2186         psdGetPipeError(), psdGetPipeActual()
2189 \fposeidon.library/psdSetAltInterface       poseidon.library/psdSetAltInterface
2191    NAME
2192         psdSetAltInterface -- change an interface to an alternate setting
2194    SYNOPSIS
2195         success = psdSetAltInterface(pp, pif);
2196         D0                           A1  A0
2198         BOOL psdSetAltInterface(APTR, APTR);
2200    FUNCTION
2202         USB devices support to have alternate settings for an interface.
2203         Whenever such alternate settings exist, you may want to switch
2204         between them. psdSetAltInterface() changes the interface to its
2205         alternate setting. These interfaces are not stored directly in the
2206         list of interfaces but in a sublist for the active one. See
2207         psdGetAttrs() for the IFA_AlterateIfList tag.
2209         This function does some internal magic for the given alternative
2210         interface to become the active one.
2212         If the given interface is already active, this operation will do
2213         nothing.
2215    NOTE
2216         Bindings will be moved alltogether. Note that pointers to the
2217         previously active interface will become obsolete for the
2218         IFA_Binding and IFA_BindingClass calls.
2220    INPUTS
2221         pp - pointer to the default control pipe of a device.
2222         pif - pointer to the alternate interface setting to become active.
2224    RESULT
2225         success - TRUE, if the modification was successful or FALSE, if the
2226                   interface could not be changed.
2228    SEE ALSO
2229         psdGetAttrs()
2232 \fposeidon.library/psdSetAttrs                     poseidon.library/psdSetAttrs
2234    NAME
2235         psdSetAttrsA -- change fields of an internal stack structure
2236         psdSetAttrs -- varargs stub for psdSetAttrsA()
2238    SYNOPSIS
2239         num = psdSetAttrsA(type, psdstruct, taglist);
2240         D0                 D0    A0         A1
2242         LONG psdSetAttrsA(ULONG, APTR, struct TagList *);
2244         num = psdSetAttrs(type, psdstruct, tag1, ...);
2246         LONG psdSetAttrs(ULONG, APTR, Tag, ...);
2248    FUNCTION
2249         Changes the fields allowed to be written of an internal stack
2250         structure according to the attributes chosen in the tag list. For
2251         each entry in the tag list, ti_Tag identifies the attribute and
2252         ti_Data is the long data you wish to change the value to.
2254         There are currently a number of ten different system structures
2255         which can be accessed in this way. To avoid adding multiple functions
2256         with the same semantics, psdSetAttrs() requires the type of the
2257         structure passed.
2259    INPUTS
2260         type - describes the type of the structure passed.
2261                See libraries/poseidon.h for details.
2262         psdstruct - pointer to the system structure on which information
2263                     should be changed. Can be NULL only for PGA_STACK.
2264         taglist - pointer to TagItem list, terminated by TAG_END.
2266    TAGS
2267         See psdGetAttrs() for the tags which can be changed.
2269    RESULT
2270         num - number of tags actually read or -1, if the request was not
2271               supported somehow.
2273    SEE ALSO
2274         psdGetAttrs()
2277 \fposeidon.library/psdSetDeviceConfig       poseidon.library/psdSetDeviceConfig
2279    NAME
2280         psdSetDeviceConfig -- change the config of a device
2282    SYNOPSIS
2283         success = psdSetDeviceConfig(pp, cfgnum);
2284         D0                           A1  D0
2286         BOOL psdSetDeviceConfig(APTR, UWORD);
2288    FUNCTION
2289         Changes the configuration of the device to a new one. As only a few
2290         devices support multiple configurations, and the stack automatically
2291         handles this case, you will probably never call this function.
2293         Classes which want to call psdSetDeviceConfig() must have a device
2294         binding. An interface binding is not enough and might conflict with
2295         other classes having bindings to interfaces.
2297    INPUTS
2298         pp - pointer to the default control pipe of a device.
2299         cfgnum - configuration number as given in the configuration
2300                  descriptor.
2302    RESULT
2303         success - TRUE, if the change was successful or FALSE, if the config
2304                   could not be altered.
2306    SEE ALSO
2307         psdGetAttrs()
2310 \fposeidon.library/psdSpawnSubTask             poseidon.library/psdSpawnSubTask
2312    NAME
2313         psdSpawnSubTask -- launch a subtask
2315    SYNOPSIS
2316         task = psdSpawnSubTask(name, initpc, userdata);
2317         D0                     A0    A1      A2
2319         struct Task * psdSpawnSubTask(STRPTR, APTR, APTR);
2321    FUNCTION
2322         Simple function to lauch a subtask. The name will be copied and
2323         automatically freed at the termination of the task, as will the 8KB
2324         of stack allocated.
2326         The task will use a default priority of 5.
2328    NOTE
2329         If these parameters don't suit you, just write your own code. Note
2330         that this really creates a Task and not a DOS Process.
2332    INPUTS
2333         name - name of the task
2334         initpc - inital program counter to start the program at.
2335         userdata - some data that will be entered in the tc_UserData field.
2337    RESULT
2338         task - pointer to a task structure or NULL, if the task creation
2339                failed. Note that the task pointer will become invalid as soon
2340                as the tasks terminates. It's recommended that you do not use
2341                it as a structure pointer, but a success indicator.
2343    BUGS
2344         Should really use taglists.
2347 \fposeidon.library/psdUnlockDevice             poseidon.library/psdUnlockDevice
2349    NAME
2350         psdUnlockDevice -- unlock access to a device
2352    SYNOPSIS
2353         psdUnlockDevice(pd);
2354                         A0
2356         void psdUnlockDevice(APTR);
2358    FUNCTION
2359         After psdLockReadDevice() or psdLockWriteDevice() had been called to
2360         lock the a device, psdUnlockDevice() must be used to unlock it again.
2362         Be sure to unlock the device after the use or you will hang the stack
2363         very quickly.
2365    SEE ALSO
2366         psdLockReadDevice(), psdLockWriteDevice()
2369 \fposeidon.library/psdUnlockPBase               poseidon.library/psdUnlockPBase
2371    NAME
2372         psdUnlockPBase -- unlock access to internal data structures
2374    SYNOPSIS
2375         psdUnlockPBase();
2377         void psdUnlockPBase(void);
2379    FUNCTION
2380         After psdLockReadPBase() or psdLockWritePBase() had been called to
2381         lock the base, psdUnlockPBase() must be used to unlock the base
2382         again.
2384         Be sure to unlock the base after the use or you will hang the stack
2385         very quickly.
2387    SEE ALSO
2388         psdLockReadPBase(), psdLockWritePBase(), psdGetNextDevice()
2391 \fposeidon.library/psdWaitPipe                     poseidon.library/psdWaitPipe
2393    NAME
2394         psdWaitPipe -- wait for the completion of a pipe transfer
2396    SYNOPSIS
2397         ioerr = psdWaitPipe(pp);
2398         D0                  A1
2400         LONG psdWaitPipe(APTR);
2402    FUNCTION
2404         After you have started a pipe or aborted a pipe, you might want to
2405         wait for it to complete or terminate. psdWaitPipe() does this for
2406         you: it waits for the pipe message to arrive, removes it from the
2407         reply port queue and returns the IO error code.
2409    NOTE
2410         If you don't want to wait for the termination of a transfer, you can
2411         TRY to abort it using psdAbortPipe(), but you have still to wait for
2412         it to arrive.
2414    INPUTS
2415         pp - pointer to pending pipe to wait for.
2417    RESULT
2418         ioerr - zero, if everthing went okay, else the IO error code.
2420    SEE ALSO
2421         psdPipeSetup(), psdDoPipe(), psdAbortPipe(), psdWaitPipe(),
2422         psdGetPipeError(), psdGetPipeActual()