Ignore:
File:
1 edited

Legend:

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

    r9d58539 re2dfa86  
    3737#include <str_error.h>
    3838#include <errno.h>
     39#include <usb/debug.h>
    3940#include <usb/dev/pipes.h>
    4041#include <usb/dev/recognise.h>
     
    4445#include "usbinfo.h"
    4546
    46 void dump_short_device_identification(usbinfo_device_t *dev)
     47void dump_short_device_identification(usb_device_t *usb_dev)
    4748{
    4849        printf("%sDevice 0x%04x by vendor 0x%04x\n", get_indent(0),
    49             (int) dev->device_descriptor.product_id,
    50             (int) dev->device_descriptor.vendor_id);
     50            usb_device_descriptors(usb_dev)->device.product_id,
     51            usb_device_descriptors(usb_dev)->device.vendor_id);
    5152}
    5253
     
    6667        }
    6768
    68         usbinfo_device_t *dev = (usbinfo_device_t *) arg;
     69        usb_device_t *usb_dev = arg;
     70        assert(usb_dev);
    6971
    7072        usb_standard_interface_descriptor_t *iface
     
    8082        match_id_list_t matches;
    8183        init_match_ids(&matches);
    82         usb_device_create_match_ids_from_interface(&dev->device_descriptor,
    83             iface, &matches);
     84        usb_device_create_match_ids_from_interface(
     85            &usb_device_descriptors(usb_dev)->device, iface, &matches);
    8486        dump_match_ids(&matches, get_indent(1));
    8587        clean_match_ids(&matches);
    8688}
    8789
    88 void dump_device_match_ids(usbinfo_device_t *dev)
     90void dump_device_match_ids(usb_device_t *usb_dev)
    8991{
    9092        match_id_list_t matches;
    9193        init_match_ids(&matches);
    9294        usb_device_create_match_ids_from_device_descriptor(
    93             &dev->device_descriptor, &matches);
     95                &usb_device_descriptors(usb_dev)->device, &matches);
    9496        printf("%sDevice match ids (0x%04x by 0x%04x, %s)\n", get_indent(0),
    95             (int) dev->device_descriptor.product_id,
    96             (int) dev->device_descriptor.vendor_id,
    97             usb_str_class(dev->device_descriptor.device_class));
     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));
    98100        dump_match_ids(&matches, get_indent(1));
    99101        clean_match_ids(&matches);
    100102
    101         usb_dp_walk_simple(dev->full_configuration_descriptor,
    102             dev->full_configuration_descriptor_size,
     103        usb_dp_walk_simple(
     104            usb_device_descriptors(usb_dev)->full_config,
     105            usb_device_descriptors(usb_dev)->full_config_size,
    103106            usb_dp_standard_descriptor_nesting,
    104             dump_match_ids_from_interface,
    105             dev);
     107            dump_match_ids_from_interface, usb_dev);
    106108}
    107109
     
    224226}
    225227
    226 void dump_descriptor_tree_brief(usbinfo_device_t *dev)
    227 {
    228         dump_descriptor_tree_callback((uint8_t *)&dev->device_descriptor,
     228void 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,
    229232            (size_t) -1, NULL);
    230         usb_dp_walk_simple(dev->full_configuration_descriptor,
    231             dev->full_configuration_descriptor_size,
     233
     234        usb_dp_walk_simple(
     235            usb_device_descriptors(usb_dev)->full_config,
     236            usb_device_descriptors(usb_dev)->full_config_size,
    232237            usb_dp_standard_descriptor_nesting,
    233             dump_descriptor_tree_callback,
    234             NULL);
    235 }
    236 
    237 void 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,
     238            dump_descriptor_tree_callback, NULL);
     239}
     240
     241void 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,
    243250            usb_dp_standard_descriptor_nesting,
    244             dump_descriptor_tree_callback,
    245             dev);
     251            dump_descriptor_tree_callback, usb_dev);
    246252}
    247253
     
    285291
    286292
    287 void dump_strings(usbinfo_device_t *dev)
     293void dump_strings(usb_device_t *usb_dev)
    288294{
    289295        /* Find used indexes. Devices with more than 64 strings are very rare.*/
    290296        uint64_t str_mask = 0;
    291         find_string_indexes_callback((uint8_t *)&dev->device_descriptor, 0,
     297        find_string_indexes_callback(
     298            (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 0,
    292299            &str_mask);
    293         usb_dp_walk_simple(dev->full_configuration_descriptor,
    294             dev->full_configuration_descriptor_size,
     300
     301        usb_dp_walk_simple(
     302            usb_device_descriptors(usb_dev)->full_config,
     303            usb_device_descriptors(usb_dev)->full_config_size,
    295304            usb_dp_standard_descriptor_nesting,
    296             find_string_indexes_callback,
    297             &str_mask);
     305            find_string_indexes_callback, &str_mask);
    298306
    299307        if (str_mask == 0) {
     
    305313        l18_win_locales_t *langs;
    306314        size_t langs_count;
    307         int rc = usb_request_get_supported_languages(&dev->ctrl_pipe,
    308             &langs, &langs_count);
     315        int rc = usb_request_get_supported_languages(
     316            usb_device_get_default_pipe(usb_dev), &langs, &langs_count);
    309317        if (rc != EOK) {
    310318                fprintf(stderr,
     
    334342                        }
    335343                        char *string = NULL;
    336                         rc = usb_request_get_string(&dev->ctrl_pipe, idx, lang,
     344                        rc = usb_request_get_string(
     345                            usb_device_get_default_pipe(usb_dev), idx, lang,
    337346                            &string);
    338347                        if ((rc != EOK) && (rc != EEMPTY)) {
     
    351360
    352361
    353 void dump_status(usbinfo_device_t *dev)
     362void dump_status(usb_device_t *usb_dev)
    354363{
    355364        int rc;
    356         uint16_t device_status = 0;
    357         uint16_t ctrl_pipe_status = 0;
     365        uint16_t status = 0;
    358366
    359367        /* Device status first. */
    360         rc = usb_request_get_status(&dev->ctrl_pipe,
    361             USB_REQUEST_RECIPIENT_DEVICE, 0,
    362             &device_status);
     368        rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev),
     369            USB_REQUEST_RECIPIENT_DEVICE, 0, &status);
    363370        if (rc != EOK) {
    364371                printf("%sFailed to get device status: %s.\n",
    365372                    get_indent(0), str_error(rc));
    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");
     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        }
    374379
    375380        /* Interface is not interesting, skipping ;-). */
    376381
    377382        /* Control endpoint zero. */
    378 try_ctrl_pipe_status:
    379         rc = usb_request_get_status(&dev->ctrl_pipe,
    380             USB_REQUEST_RECIPIENT_ENDPOINT, 0,
    381             &ctrl_pipe_status);
     383        status = 0;
     384        rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev),
     385            USB_REQUEST_RECIPIENT_ENDPOINT, 0, &status);
    382386        if (rc != EOK) {
    383387                printf("%sFailed to get control endpoint status: %s.\n",
    384388                    get_indent(0), str_error(rc));
    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 
    393 leave:
    394         return;
     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        }
    395394}
    396395
Note: See TracChangeset for help on using the changeset viewer.