Ignore:
File:
1 edited

Legend:

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

    re2dfa86 r9d58539  
    3737#include <str_error.h>
    3838#include <errno.h>
    39 #include <usb/debug.h>
    4039#include <usb/dev/pipes.h>
    4140#include <usb/dev/recognise.h>
     
    4544#include "usbinfo.h"
    4645
    47 void dump_short_device_identification(usb_device_t *usb_dev)
     46void dump_short_device_identification(usbinfo_device_t *dev)
    4847{
    4948        printf("%sDevice 0x%04x by vendor 0x%04x\n", get_indent(0),
    50             usb_device_descriptors(usb_dev)->device.product_id,
    51             usb_device_descriptors(usb_dev)->device.vendor_id);
     49            (int) dev->device_descriptor.product_id,
     50            (int) dev->device_descriptor.vendor_id);
    5251}
    5352
     
    6766        }
    6867
    69         usb_device_t *usb_dev = arg;
    70         assert(usb_dev);
     68        usbinfo_device_t *dev = (usbinfo_device_t *) arg;
    7169
    7270        usb_standard_interface_descriptor_t *iface
     
    8280        match_id_list_t matches;
    8381        init_match_ids(&matches);
    84         usb_device_create_match_ids_from_interface(
    85             &usb_device_descriptors(usb_dev)->device, iface, &matches);
     82        usb_device_create_match_ids_from_interface(&dev->device_descriptor,
     83            iface, &matches);
    8684        dump_match_ids(&matches, get_indent(1));
    8785        clean_match_ids(&matches);
    8886}
    8987
    90 void dump_device_match_ids(usb_device_t *usb_dev)
     88void dump_device_match_ids(usbinfo_device_t *dev)
    9189{
    9290        match_id_list_t matches;
    9391        init_match_ids(&matches);
    9492        usb_device_create_match_ids_from_device_descriptor(
    95                 &usb_device_descriptors(usb_dev)->device, &matches);
     93            &dev->device_descriptor, &matches);
    9694        printf("%sDevice match ids (0x%04x by 0x%04x, %s)\n", get_indent(0),
    97             usb_device_descriptors(usb_dev)->device.product_id,
    98             usb_device_descriptors(usb_dev)->device.vendor_id,
    99             usb_str_class(usb_device_descriptors(usb_dev)->device.device_class));
     95            (int) dev->device_descriptor.product_id,
     96            (int) dev->device_descriptor.vendor_id,
     97            usb_str_class(dev->device_descriptor.device_class));
    10098        dump_match_ids(&matches, get_indent(1));
    10199        clean_match_ids(&matches);
    102100
    103         usb_dp_walk_simple(
    104             usb_device_descriptors(usb_dev)->full_config,
    105             usb_device_descriptors(usb_dev)->full_config_size,
     101        usb_dp_walk_simple(dev->full_configuration_descriptor,
     102            dev->full_configuration_descriptor_size,
    106103            usb_dp_standard_descriptor_nesting,
    107             dump_match_ids_from_interface, usb_dev);
     104            dump_match_ids_from_interface,
     105            dev);
    108106}
    109107
     
    226224}
    227225
    228 void dump_descriptor_tree_brief(usb_device_t *usb_dev)
    229 {
    230         dump_descriptor_tree_callback(
    231             (const uint8_t *)&usb_device_descriptors(usb_dev)->device,
     226void dump_descriptor_tree_brief(usbinfo_device_t *dev)
     227{
     228        dump_descriptor_tree_callback((uint8_t *)&dev->device_descriptor,
    232229            (size_t) -1, NULL);
    233 
    234         usb_dp_walk_simple(
    235             usb_device_descriptors(usb_dev)->full_config,
    236             usb_device_descriptors(usb_dev)->full_config_size,
     230        usb_dp_walk_simple(dev->full_configuration_descriptor,
     231            dev->full_configuration_descriptor_size,
    237232            usb_dp_standard_descriptor_nesting,
    238             dump_descriptor_tree_callback, NULL);
    239 }
    240 
    241 void dump_descriptor_tree_full(usb_device_t *usb_dev)
    242 {
    243         dump_descriptor_tree_callback(
    244             (const uint8_t *)&usb_device_descriptors(usb_dev)->device,
    245             (size_t) -1, usb_dev);
    246 
    247         usb_dp_walk_simple(
    248             usb_device_descriptors(usb_dev)->full_config,
    249             usb_device_descriptors(usb_dev)->full_config_size,
     233            dump_descriptor_tree_callback,
     234            NULL);
     235}
     236
     237void dump_descriptor_tree_full(usbinfo_device_t *dev)
     238{
     239        dump_descriptor_tree_callback((uint8_t *)&dev->device_descriptor,
     240            (size_t) -1, dev);
     241        usb_dp_walk_simple(dev->full_configuration_descriptor,
     242            dev->full_configuration_descriptor_size,
    250243            usb_dp_standard_descriptor_nesting,
    251             dump_descriptor_tree_callback, usb_dev);
     244            dump_descriptor_tree_callback,
     245            dev);
    252246}
    253247
     
    291285
    292286
    293 void dump_strings(usb_device_t *usb_dev)
     287void dump_strings(usbinfo_device_t *dev)
    294288{
    295289        /* Find used indexes. Devices with more than 64 strings are very rare.*/
    296290        uint64_t str_mask = 0;
    297         find_string_indexes_callback(
    298             (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 0,
     291        find_string_indexes_callback((uint8_t *)&dev->device_descriptor, 0,
    299292            &str_mask);
    300 
    301         usb_dp_walk_simple(
    302             usb_device_descriptors(usb_dev)->full_config,
    303             usb_device_descriptors(usb_dev)->full_config_size,
     293        usb_dp_walk_simple(dev->full_configuration_descriptor,
     294            dev->full_configuration_descriptor_size,
    304295            usb_dp_standard_descriptor_nesting,
    305             find_string_indexes_callback, &str_mask);
     296            find_string_indexes_callback,
     297            &str_mask);
    306298
    307299        if (str_mask == 0) {
     
    313305        l18_win_locales_t *langs;
    314306        size_t langs_count;
    315         int rc = usb_request_get_supported_languages(
    316             usb_device_get_default_pipe(usb_dev), &langs, &langs_count);
     307        int rc = usb_request_get_supported_languages(&dev->ctrl_pipe,
     308            &langs, &langs_count);
    317309        if (rc != EOK) {
    318310                fprintf(stderr,
     
    342334                        }
    343335                        char *string = NULL;
    344                         rc = usb_request_get_string(
    345                             usb_device_get_default_pipe(usb_dev), idx, lang,
     336                        rc = usb_request_get_string(&dev->ctrl_pipe, idx, lang,
    346337                            &string);
    347338                        if ((rc != EOK) && (rc != EEMPTY)) {
     
    360351
    361352
    362 void dump_status(usb_device_t *usb_dev)
     353void dump_status(usbinfo_device_t *dev)
    363354{
    364355        int rc;
    365         uint16_t status = 0;
     356        uint16_t device_status = 0;
     357        uint16_t ctrl_pipe_status = 0;
    366358
    367359        /* Device status first. */
    368         rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev),
    369             USB_REQUEST_RECIPIENT_DEVICE, 0, &status);
     360        rc = usb_request_get_status(&dev->ctrl_pipe,
     361            USB_REQUEST_RECIPIENT_DEVICE, 0,
     362            &device_status);
    370363        if (rc != EOK) {
    371364                printf("%sFailed to get device status: %s.\n",
    372365                    get_indent(0), str_error(rc));
    373         } else {
    374                 printf("%sDevice status 0x%04x: power=%s, remote-wakeup=%s.\n",
    375                     get_indent(0), status,
    376                     status & USB_DEVICE_STATUS_SELF_POWERED ? "self" : "bus",
    377                     status & USB_DEVICE_STATUS_REMOTE_WAKEUP ? "yes" : "no");
    378         }
     366                goto try_ctrl_pipe_status;
     367        }
     368
     369        printf("%sDevice status 0x%04x: power=%s, remote-wakeup=%s.\n",
     370            get_indent(0),
     371            device_status,
     372            device_status & USB_DEVICE_STATUS_SELF_POWERED ? "self" : "bus",
     373            device_status & USB_DEVICE_STATUS_REMOTE_WAKEUP ? "yes" : "no");
    379374
    380375        /* Interface is not interesting, skipping ;-). */
    381376
    382377        /* Control endpoint zero. */
    383         status = 0;
    384         rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev),
    385             USB_REQUEST_RECIPIENT_ENDPOINT, 0, &status);
     378try_ctrl_pipe_status:
     379        rc = usb_request_get_status(&dev->ctrl_pipe,
     380            USB_REQUEST_RECIPIENT_ENDPOINT, 0,
     381            &ctrl_pipe_status);
    386382        if (rc != EOK) {
    387383                printf("%sFailed to get control endpoint status: %s.\n",
    388384                    get_indent(0), str_error(rc));
    389         } else {
    390                 printf("%sControl endpoint zero status %04X: halted=%s.\n",
    391                     get_indent(0), status,
    392                     status & USB_ENDPOINT_STATUS_HALTED ? "yes" : "no");
    393         }
     385                goto leave;
     386        }
     387
     388        printf("%sControl endpoint zero status %04X: halted=%s.\n",
     389            get_indent(0),
     390            ctrl_pipe_status,
     391            ctrl_pipe_status & USB_ENDPOINT_STATUS_HALTED ? "yes" : "no");
     392
     393leave:
     394        return;
    394395}
    395396
Note: See TracChangeset for help on using the changeset viewer.