2 ** PsdDevLister by Chris Hodges <chrisly@platon42.de>
9 #include <libraries/poseidon.h>
12 #include <proto/poseidon.h>
13 #include <proto/exec.h>
14 #include <proto/dos.h>
16 #define ARGS_SHOWROOT 0
18 #define ARGS_STRINGS 2
21 static const char *template = "SHOWROOT/S,QUICK/S,STRINGS/S";
22 const char *version
= "$VER: PsdDevLister 4.0 (03.06.09) by Chris Hodges <chrisly@platon42.de>";
23 static IPTR ArgsArray
[ARGS_SIZEOF
];
24 static struct RDArgs
*ArgsHook
= NULL
;
41 int main(int argc
, char *argv
[])
80 #ifdef AROS_USB30_CODE
96 struct List
*altpiflist
;
98 struct List
*descriptors
= NULL
;
117 struct Task
*apptask
;
118 struct Library
*bindingcls
;
134 if(!(ArgsHook
= ReadArgs(template, ArgsArray
, NULL
)))
136 fail("Wrong arguments!\n");
139 if((ps
= OpenLibrary("poseidon.library", 4)))
142 mp
= CreateMsgPort();
144 while((pd
= psdGetNextDevice(pd
)))
146 psdLockReadDevice(pd
);
155 psdGetAttrs(PGA_DEVICE
, pd
,
157 DA_HubDevice
, &devhub
,
158 DA_HubThinkTime
, &devhubthinktime
,
159 DA_AtHubPortNumber
, &devhubport
,
160 DA_UsbVersion
, &devusbvers
,
161 DA_MaxPktSize0
, &devmaxpktsize0
,
163 DA_SubClass
, &devsubclass
,
164 DA_Protocol
, &devproto
,
165 DA_VendorID
, &devvendorid
,
166 DA_ProductID
, &devprodid
,
167 DA_Version
, &devversion
,
168 DA_Manufacturer
, &devmanufact
,
169 DA_ProductName
, &devprodname
,
170 DA_SerialNumber
, &devserial
,
171 DA_CloneCount
, &devclonecount
,
172 DA_IDString
, &devidstr
,
173 DA_CurrLangID
, &devcurrlang
,
174 DA_LangIDArray
, &devlangarray
,
175 DA_IsLowspeed
, &devislowspeed
,
176 DA_IsHighspeed
, &devishighspeed
,
177 #ifdef AROS_USB30_CODE
178 DA_IsSuperspeed
, &devissuperspeed
,
180 DA_IsConnected
, &devisconnected
,
181 DA_NeedsSplitTrans
, &devneedssplit
,
182 DA_HasAddress
, &devhasaddress
,
183 DA_HasDevDesc
, &devhasdevdesc
,
184 DA_IsConfigured
, &devisconfigured
,
185 DA_IsSuspended
, &devissuspended
,
186 DA_NumConfigs
, &devnumcfgs
,
187 DA_ConfigList
, &cfgs
,
188 DA_Binding
, &binding
,
189 DA_BindingClass
, &bindingcls
,
190 DA_HasAppBinding
, &hasappbinding
,
191 DA_LowPower
, &devlowpower
,
192 DA_PowerDrained
, &devpowerdrain
,
193 DA_PowerSupply
, &devpoweravail
,
194 DA_DescriptorList
, &descriptors
,
198 psdGetAttrs(PGA_DEVICE
, devhub
,
199 DA_ProductName
, &devhubname
,
203 if(!ArgsArray
[ARGS_SHOWROOT
])
205 Printf("Skipping '%s' (use SHOWROOT to list)\n", devidstr
);
206 PutStr("---------------------------------------------------------------------------\n");
212 if((devclass
== HUB_CLASSCODE
) && devishighspeed
)
214 switch(devhubthinktime
)
217 strthinktime
= " (Hub Think Time: 8 bit times)";
220 strthinktime
= " (Hub Think Time: 16 bit times)";
223 strthinktime
= " (Hub Think Time: 24 bit times)";
226 strthinktime
= " (Hub Think Time: 32 bit times)";
230 Printf(" Poseidon DevID : '%s'\n"
231 " Product Name : '%s' (ID: %04lx, Vers: %04lx)\n"
232 " Manufacturer : '%s' (Vendor: %04lx (%s))\n"
233 " Serial Number : '%s' (USBVers: %04lx)\n"
234 " Device State : %s%s%s%s%s%s%s\n"
235 " Device Address : %ld (Port %ld at %s)\n"
236 " Class/Sub/Proto : %ld/%ld/%ld (%s)\n"
237 " MaxPktSize EP 0 : %ld%s\n"
238 " Power Check : Supply = %ldmA, Drain = %ldmA%s\n"
239 " Current Language: %s\n",
241 devprodname
, devprodid
, devversion
,
242 devmanufact
, devvendorid
,
243 psdNumToStr(NTS_VENDORID
, (LONG
) devvendorid
, "unknown"),
244 devserial
, devusbvers
,
245 #ifdef AROS_USB30_CODE
246 devislowspeed
? "lowspeed " : (devissuperspeed
? "superspeed " : (devishighspeed
? "highspeed " : "fullspeed ")),
248 devislowspeed
? "lowspeed " : (devishighspeed
? "highspeed " : "fullspeed "),
250 devisconnected
? "connected " : "disconnected ",
251 devhasaddress
? "hasaddress " : "",
252 devhasdevdesc
? "hasdevdesc " : "",
253 devisconfigured
? "configured " : "",
254 devissuspended
? "suspended " : "",
255 devneedssplit
? "\n SplitTransaction: USB1.1 at USB2.0 port!" : "",
257 devhubport
, devhubname
,
258 devclass
, devsubclass
, devproto
,
259 psdNumToStr(NTS_COMBOCLASS
, (devclass
<<NTSCCS_CLASS
)|(devsubclass
<<NTSCCS_SUBCLASS
)|(devproto
<<NTSCCS_PROTO
)|
260 NTSCCF_CLASS
|NTSCCF_SUBCLASS
|NTSCCF_PROTO
, "<unknown>"),
261 devmaxpktsize0
, strthinktime
,
262 devpoweravail
, devpowerdrain
,
263 devlowpower
? " LOWPOWER!" : "",
264 psdNumToStr(NTS_LANGID
, devcurrlang
, "<unknown>"));
265 if(devlangarray
&& (!ArgsArray
[ARGS_QUICK
]))
267 UWORD
*wptr
= devlangarray
;
269 PutStr(" Supported Langs : ");
272 PutStr(psdNumToStr(NTS_LANGID
, (ULONG
) *wptr
, "<unknown>"));
285 if(ArgsArray
[ARGS_STRINGS
])
288 pp
= psdAllocPipe(pd
, mp
, NULL
);
291 strdesc
= psdGetStringDescriptor(pp
, idx
);
294 Printf(" String descriptor %04ld: '%s'\n", idx
, strdesc
);
305 PutStr(" ... aborting\n");
316 psdGetAttrs(PGA_APPBINDING
, binding
,
319 Printf("\n This device is bound to application %s with context %08lx.\n",
320 apptask
->tc_Node
.ln_Name
, binding
);
322 Printf("\n This device is bound to %s, context %08lx.\n",
323 bindingcls
->lib_Node
.ln_Name
, binding
);
326 Printf("\n %ld configuration(s):\n", devnumcfgs
);
330 psdGetAttrs(PGA_CONFIG
, pc
,
331 CA_SelfPowered
, &cfgselfpow
,
332 CA_RemoteWakeup
, &cfgremwake
,
333 CA_ConfigNum
, &cfgnum
,
334 CA_MaxPower
, &cfgmaxpower
,
335 CA_ConfigName
, &cfgname
,
336 CA_NumInterfaces
, &cfgnumifs
,
337 CA_InterfaceList
, &ifs
,
339 Printf("\n · Config %ld (%s)\n"
341 " MaxPower: %ld mA\n",
343 cfgselfpow
? "self-powered " : "bus-powered ",
344 cfgremwake
? "remote-wakeup" : "",
346 Printf("\n %ld interface(s) for this config:", cfgnumifs
);
353 psdGetAttrs(PGA_INTERFACE
, altpif
,
354 IFA_InterfaceNum
, &ifnum
,
355 IFA_AlternateNum
, &ifaltnum
,
357 IFA_SubClass
, &ifsubclass
,
358 IFA_Protocol
, &ifproto
,
359 IFA_InterfaceName
, &ifname
,
360 IFA_IDString
, &ifidstr
,
361 IFA_NumEndpoints
, &ifnumeps
,
362 IFA_EndpointList
, &eps
,
363 IFA_AlternateIfList
, &altpiflist
,
364 IFA_Binding
, &binding
,
365 IFA_BindingClass
, &bindingcls
,
367 Printf("\n · Interface %ld (%s) (ID: '%s')\n"
368 " Alternate Setting: %ld\n"
369 " Class/Sub/Proto : %ld/%ld/%ld (%s)\n",
370 ifnum
, ifname
, ifidstr
,
372 ifclass
, ifsubclass
, ifproto
,
373 psdNumToStr(NTS_COMBOCLASS
, (ifclass
<<NTSCCS_CLASS
)|(ifsubclass
<<NTSCCS_SUBCLASS
)|(ifproto
<<NTSCCS_PROTO
)|
374 NTSCCF_CLASS
|NTSCCF_SUBCLASS
|NTSCCF_PROTO
, "<unknown>"));
377 Printf("\n This interface is bound to %s, context %08lx.\n",
378 bindingcls
->lib_Node
.ln_Name
, binding
);
380 if(ArgsArray
[ARGS_QUICK
])
382 Printf("\n %ld endpoint(s).\n", ifnumeps
);
384 Printf("\n %ld endpoint(s) for this interface:\n", ifnumeps
);
391 psdGetAttrs(PGA_ENDPOINT
, pep
,
393 EA_EndpointNum
, &epnum
,
394 EA_TransferType
, &eptranstype
,
395 EA_MaxPktSize
, &epmaxpktsize
,
396 EA_Interval
, &epinterval
,
397 EA_NumTransMuFrame
, &epnumtransmu
,
398 EA_SyncType
, &epsynctype
,
399 EA_UsageType
, &epusagetype
,
401 Printf(" · Endpoint %ld (%s %s)\n"
402 " MaxPktSize: %s%ld\n",
403 epnum
, psdNumToStr(NTS_TRANSTYPE
, eptranstype
, "?"),
404 episin
? "<-[ IN" : "OUT ]->",
405 (epnumtransmu
== 2) ? "2x " : ((epnumtransmu
== 3) ? "3x " : ""),
408 if(devishighspeed
|| ((eptranstype
!= USEAF_CONTROL
) && (eptranstype
!= USEAF_BULK
)))
410 Printf(" %s : %ld %s\n",
411 (((eptranstype
== USEAF_CONTROL
) || (eptranstype
== USEAF_BULK
)) && devishighspeed
) ? "NAK-Rate" : "Interval",
413 devishighspeed
? "µFrames" : "ms");
415 if(eptranstype
== USEAF_ISOCHRONOUS
)
417 Printf(" SyncType : %s\n"
419 psdNumToStr(NTS_SYNCTYPE
, epsynctype
, "?"),
420 psdNumToStr(NTS_USAGETYPE
, epusagetype
, "?"));
427 altpif
= (struct Node
*) altpiflist
->lh_Head
;
428 /* check for alternate settings */
431 Printf("\n No alternate settings.\n");
434 Printf("\n Alternate settings:\n");
436 altpif
= altpif
->ln_Succ
;
447 if(descriptors
&& (!ArgsArray
[ARGS_QUICK
]))
449 pdd
= descriptors
->lh_Head
;
450 PutStr("\n Standard Descriptors:");
458 psdGetAttrs(PGA_DESCRIPTOR
, pdd
,
462 DDA_DescriptorType
, &desctype
,
463 DDA_DescriptorLength
, &desclen
,
464 DDA_DescriptorData
, &descdata
,
469 psdGetAttrs(PGA_INTERFACE
, pif
,
475 descname
= psdNumToStr(NTS_DESCRIPTOR
, desctype
|(ifclass
<<8), NULL
);
479 descname
= psdNumToStr(NTS_DESCRIPTOR
, desctype
, "<unknown>");
481 Printf("\n Desc. %02lx (%s), %ld bytes",
487 psdGetAttrs(PGA_CONFIG
, pc
,
488 CA_ConfigNum
, &cfgnum
,
492 psdGetAttrs(PGA_INTERFACE
, pif
,
493 IFA_InterfaceNum
, &ifnum
,
494 IFA_AlternateNum
, &ifaltnum
,
498 psdGetAttrs(PGA_ENDPOINT
, pep
,
499 EA_EndpointNum
, &epnum
,
501 Printf(" (EP %ld, IF %ld/%ld, Cfg %ld)", epnum
, ifnum
, ifaltnum
, cfgnum
);
503 Printf(" (Iface %ld/%ld, Cfg %ld)", ifnum
, ifaltnum
, cfgnum
);
506 Printf(" (Config %ld)", cfgnum
);
509 // skip basic descriptors
510 if(!((desctype
>= UDT_DEVICE
) && (desctype
<= UDT_ENDPOINT
)))
518 Printf(" %02lx:", cnt
);
520 Printf(" %02lx", *descdata
++);
521 if((!(++cnt
& 15)) && desclen
)
531 Printf("\n Google: http://www.google.com/search?q=usb+0x%04lx+0x%04lx\n",
532 devvendorid
, devprodid
);
534 PutStr("---------------------------------------------------------------------------\n");
540 errmsg
= "Unable to open poseidon.library\n";
544 return(0); // never gets here, just to shut the compiler up