Changeset 2d6787b in mainline


Ignore:
Timestamp:
2011-03-17T23:17:42Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a458bc9
Parents:
aad3587
Message:

Old code removal from usbinfo

Location:
uspace/app/usbinfo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/usbinfo/info.c

    raad3587 r2d6787b  
    246246}
    247247
    248 int dump_device(devman_handle_t hc_handle, usb_address_t address)
    249 {
    250         int rc;
    251         usb_device_connection_t wire;
    252         usb_endpoint_pipe_t ctrl_pipe;
    253 
    254         /*
    255          * Initialize pipes.
    256          */
    257         rc = usb_device_connection_initialize(&wire, hc_handle, address);
    258         if (rc != EOK) {
    259                 fprintf(stderr,
    260                     NAME ": failed to create connection to the device: %s.\n",
    261                     str_error(rc));
    262                 goto leave;
    263         }
    264         rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe, &wire);
    265         if (rc != EOK) {
    266                 fprintf(stderr,
    267                     NAME ": failed to create default control pipe: %s.\n",
    268                     str_error(rc));
    269                 goto leave;
    270         }
    271         rc = usb_endpoint_pipe_probe_default_control(&ctrl_pipe);
    272         if (rc != EOK) {
    273                 fprintf(stderr,
    274                     NAME ": probing default control pipe failed: %s.\n",
    275                     str_error(rc));
    276                 goto leave;
    277         }
    278         rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
    279         if (rc != EOK) {
    280                 fprintf(stderr,
    281                     NAME ": failed to start session on control pipe: %s.\n",
    282                     str_error(rc));
    283                 goto leave;
    284         }
    285 
    286         /*
    287          * Dump information about possible match ids.
    288          */
    289         match_id_list_t match_id_list;
    290         init_match_ids(&match_id_list);
    291         rc = usb_device_create_match_ids(&ctrl_pipe, &match_id_list);
    292         if (rc != EOK) {
    293                 fprintf(stderr,
    294                     NAME ": failed to fetch match ids of the device: %s.\n",
    295                     str_error(rc));
    296                 goto leave;
    297         }
    298         dump_match_ids(&match_id_list, get_indent(0));
    299 
    300         /*
    301          * Get device descriptor and dump it.
    302          */
    303         usb_standard_device_descriptor_t device_descriptor;
    304         rc = usb_request_get_device_descriptor(&ctrl_pipe, &device_descriptor);
    305         if (rc != EOK) {
    306                 fprintf(stderr,
    307                     NAME ": failed to fetch standard device descriptor: %s.\n",
    308                     str_error(rc));
    309                 goto leave;
    310         }
    311         dump_usb_descriptor((uint8_t *)&device_descriptor, sizeof(device_descriptor));
    312 
    313         rc = EOK;
    314         goto leave;
    315 
    316         /*
    317          * Get first configuration descriptor and dump it.
    318          */
    319         usb_standard_configuration_descriptor_t config_descriptor;
    320         int config_index = 0;
    321         rc = usb_request_get_bare_configuration_descriptor(&ctrl_pipe,
    322             config_index, &config_descriptor);
    323         if (rc != EOK) {
    324                 fprintf(stderr,
    325                     NAME ": failed to fetch standard configuration descriptor: %s.\n",
    326                     str_error(rc));
    327                 goto leave;
    328         }
    329         //dump_standard_configuration_descriptor(config_index, &config_descriptor);
    330 
    331         void *full_config_descriptor = malloc(config_descriptor.total_length);
    332         rc = usb_request_get_full_configuration_descriptor(&ctrl_pipe,
    333             config_index,
    334             full_config_descriptor, config_descriptor.total_length, NULL);
    335         if (rc != EOK) {
    336                 fprintf(stderr,
    337                     NAME ": failed to fetch full configuration descriptor: %s.\n",
    338                     str_error(rc));
    339                 goto leave;
    340         }
    341 
    342         dump_descriptor_tree(full_config_descriptor,
    343             config_descriptor.total_length);
    344 
    345         /*
    346          * Get supported languages of STRING descriptors.
    347          */
    348         l18_win_locales_t *langs;
    349         size_t langs_count;
    350         rc = usb_request_get_supported_languages(&ctrl_pipe,
    351             &langs, &langs_count);
    352         if (rc != EOK) {
    353                 fprintf(stderr,
    354                     NAME ": failed to get list of supported languages: %s.\n",
    355                     str_error(rc));
    356                 goto skip_strings;
    357         }
    358 
    359         printf("String languages (%zu):", langs_count);
    360         size_t i;
    361         for (i = 0; i < langs_count; i++) {
    362                 printf(" 0x%04x", (int) langs[i]);
    363         }
    364         printf(".\n");
    365 
    366         /*
    367          * Dump all strings in all available langages;
    368          */
    369         for (i = 0; i < langs_count; i++) {
    370                 l18_win_locales_t lang = langs[i];
    371 
    372                 printf("%sStrings for language 0x%04x:\n", get_indent(0),
    373                     (int) lang);
    374 
    375                 /*
    376                  * Try all indexes - we will see what pops-up ;-).
    377                  * However, to speed things up, we will stop after
    378                  * encountering several broken (or nonexistent ones)
    379                  * descriptors in line.
    380                  */
    381                 size_t idx;
    382                 size_t failed_count = 0;
    383                 for (idx = 1; idx < 0xFF; idx++) {
    384                         char *string;
    385                         rc = usb_request_get_string(&ctrl_pipe, idx, lang,
    386                             &string);
    387                         if (rc != EOK) {
    388                                 failed_count++;
    389                                 if (failed_count > 3) {
    390                                         break;
    391                                 }
    392                                 continue;
    393                         }
    394                         printf("%sString #%zu: \"%s\"\n", get_indent(1),
    395                             idx, string);
    396                         free(string);
    397                         failed_count = 0; /* Reset failed counter. */
    398                 }
    399         }
    400 
    401 
    402 skip_strings:
    403 
    404         rc = EOK;
    405 
    406 leave:
    407         /* Ignoring errors here. */
    408         usb_endpoint_pipe_end_session(&ctrl_pipe);
    409 
    410         return rc;
    411 }
    412 
    413248/** @}
    414249 */
  • uspace/app/usbinfo/usbinfo.h

    raad3587 r2d6787b  
    5757void dump_match_ids(match_id_list_t *, const char *);
    5858void dump_usb_descriptor(uint8_t *, size_t);
    59 int dump_device(devman_handle_t, usb_address_t);
    6059void dump_descriptor_tree(uint8_t *, size_t);
    6160
Note: See TracChangeset for help on using the changeset viewer.