Changes in uspace/lib/usb/src/dump.c [534dee89:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/dump.c
r534dee89 r9d58539 33 33 * Descriptor dumping. 34 34 */ 35 #include <adt/list.h> 36 #include <fibril_synch.h> 37 #include <errno.h> 35 38 #include <stdlib.h> 36 39 #include <stdio.h> … … 38 41 #include <usb/descriptor.h> 39 42 #include <usb/classes/classes.h> 40 #include <usb/classes/hub.h>41 #include <usb/usb.h>42 43 43 44 /** Mapping between descriptor id and dumping function. */ … … 275 276 const uint8_t *descriptor, size_t descriptor_length) 276 277 { 277 usb_hub_descriptor_header_t *d = 278 (usb_hub_descriptor_header_t *) descriptor; 279 if (descriptor_length < sizeof(d)) 280 return; 281 282 PRINTLINE("bDescLength: = %d", d->length); 283 PRINTLINE("bDescriptorType = 0x%02x", d->descriptor_type); 284 PRINTLINE("bNbrPorts = %d", d->port_count); 285 PRINTLINE("bHubCharacteristics = 0x%02x%02x (%s;%s%s)", 286 d->characteristics_reserved, d->characteristics, 287 (d->characteristics & HUB_CHAR_NO_POWER_SWITCH_FLAG) ? 288 "No Power Switching" : 289 ((d->characteristics & HUB_CHAR_POWER_PER_PORT_FLAG) ? 290 "Per-Port Switching" : "Ganged Power Switching"), 291 (d->characteristics & HUB_CHAR_COMPOUND_DEVICE) ? 292 "Compound Device;" : "", 293 (d->characteristics & HUB_CHAR_NO_OC_FLAG) ? 294 "No OC Protection" : 295 ((d->characteristics & HUB_CHAR_OC_PER_PORT_FLAG) ? 296 "Individual Port OC Protection" : 297 "Global OC Protection") 298 ); 299 PRINTLINE("bPwrOn2PwrGood = %d (%d ms)", 300 d->power_good_time, d->power_good_time * 2); 301 PRINTLINE("bHubContrCurrent = %d (%d mA)", 302 d->max_current, d->max_current); 303 const size_t port_bytes = (descriptor_length - sizeof(*d)) / 2; 304 const uint8_t *removable_mask = descriptor + sizeof(*d); 305 const uint8_t *powered_mask = descriptor + sizeof(*d) + port_bytes; 306 307 if (port_bytes == 0 308 || port_bytes > (((d->port_count / (unsigned)8) + 1) * 2)) { 309 PRINTLINE("::CORRUPTED DESCRIPTOR:: (%zu bytes remain)", 310 port_bytes * 2); 311 } 312 313 fprintf(output, "%sDeviceRemovable = 0x", 314 line_prefix ? line_prefix : " - "); 315 for (unsigned i = port_bytes; i > 0; --i) 316 fprintf(output, "%02x", removable_mask[i - 1]); 317 fprintf(output, " (0b1 - Device non-removable)%s", 318 line_suffix ? line_suffix : "\n"); 319 320 fprintf(output, "%sPortPwrCtrlMask = 0x", 321 line_prefix ? line_prefix : " - "); 322 for (unsigned i = port_bytes; i > 0; --i) 323 fprintf(output, "%02x", powered_mask[i - 1]); 324 fprintf(output, " (Legacy - All should be 0b1)%s", 325 line_suffix ? line_suffix : "\n"); 278 /* TODO */ 326 279 } 327 280
Note:
See TracChangeset
for help on using the changeset viewer.