Changeset b4b534ac in mainline for uspace/lib/usb/src/dump.c
- Timestamp:
- 2016-07-22T08:24:47Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f76d2c2
- Parents:
- 5b18137 (diff), 8351f9a4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/dump.c
r5b18137 rb4b534ac 33 33 * Descriptor dumping. 34 34 */ 35 #include <adt/list.h>36 #include <fibril_synch.h>37 #include <errno.h>38 35 #include <stdlib.h> 39 36 #include <stdio.h> … … 41 38 #include <usb/descriptor.h> 42 39 #include <usb/classes/classes.h> 40 #include <usb/classes/hub.h> 41 #include <usb/usb.h> 43 42 44 43 /** Mapping between descriptor id and dumping function. */ … … 276 275 const uint8_t *descriptor, size_t descriptor_length) 277 276 { 278 /* TODO */ 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"); 279 326 } 280 327
Note:
See TracChangeset
for help on using the changeset viewer.