Changeset 3100ebe in mainline


Ignore:
Timestamp:
2011-03-16T10:14:57Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
81ca204
Parents:
2180979
Message:

Preparation for more modular usbinfo

Location:
uspace/app/usbinfo
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/usbinfo/Makefile

    r2180979 r3100ebe  
    3434
    3535SOURCES = \
     36        dev.c \
    3637        dump.c \
    3738        info.c \
  • uspace/app/usbinfo/dump.c

    r2180979 r3100ebe  
    101101}
    102102
    103 void dump_match_ids(match_id_list_t *matches)
     103void dump_match_ids(match_id_list_t *matches, const char *line_prefix)
    104104{
    105         printf("Match ids:\n");
    106105        link_t *link;
    107106        for (link = matches->ids.next;
     
    110109                match_id_t *match = list_get_instance(link, match_id_t, link);
    111110
    112                 printf(INDENT "%d %s\n", match->score, match->id);
     111                printf("%s%d %s\n", line_prefix, match->score, match->id);
    113112        }
    114113}
  • uspace/app/usbinfo/info.c

    r2180979 r3100ebe  
    4242#include "usbinfo.h"
    4343
     44void dump_short_device_identification(usbinfo_device_t *dev)
     45{
     46        printf("%sDevice 0x%04x by vendor 0x%04x\n", get_indent(0),
     47            (int) dev->device_descriptor.product_id,
     48            (int) dev->device_descriptor.vendor_id);
     49}
     50
     51void dump_device_match_ids(usbinfo_device_t *dev)
     52{
     53        match_id_list_t matches;
     54        init_match_ids(&matches);
     55        usb_device_create_match_ids_from_device_descriptor(
     56            &dev->device_descriptor, &matches);
     57        dump_match_ids(&matches, get_indent(0));
     58}
     59
    4460int dump_device(devman_handle_t hc_handle, usb_address_t address)
    4561{
     
    92108                goto leave;
    93109        }
    94         dump_match_ids(&match_id_list);
     110        dump_match_ids(&match_id_list, get_indent(0));
    95111
    96112        /*
  • uspace/app/usbinfo/main.c

    r2180979 r3100ebe  
    164164                }
    165165
    166                 printf("Device `%s':\n------------\n", devpath);
    167                 dump_device(hc_handle, dev_addr);
     166                usbinfo_device_t *dev = prepare_device(hc_handle, dev_addr);
     167                if (dev == NULL) {
     168                        continue;
     169                }
     170
     171                /* Run actions the user specified. */
     172                /* TODO */
     173
     174
     175                printf("%s\n", devpath);
     176                dump_short_device_identification(dev);
     177                dump_device_match_ids(dev);
     178
     179                /* Destroy the control pipe (close the session etc.). */
     180                destroy_device(dev);
    168181        }
    169182
  • uspace/app/usbinfo/usbinfo.h

    r2180979 r3100ebe  
    3838#include <usb/usb.h>
    3939#include <usb/descriptor.h>
     40#include <usb/pipes.h>
    4041#include <usb/debug.h>
    4142#include <ipc/devman.h>
    4243
     44typedef struct {
     45        usb_endpoint_pipe_t ctrl_pipe;
     46        usb_device_connection_t wire;
     47        usb_standard_device_descriptor_t device_descriptor;
     48} usbinfo_device_t;
    4349
    4450#define NAME "usbinfo"
     
    4652void dump_buffer(const char *, size_t, const uint8_t *, size_t);
    4753const char *get_indent(size_t);
    48 void dump_match_ids(match_id_list_t *matches);
     54void dump_match_ids(match_id_list_t *, const char *);
    4955void dump_usb_descriptor(uint8_t *, size_t);
    5056int dump_device(devman_handle_t, usb_address_t);
     
    5662}
    5763
     64usbinfo_device_t *prepare_device(devman_handle_t, usb_address_t);
     65void destroy_device(usbinfo_device_t *);
     66
     67
     68void dump_short_device_identification(usbinfo_device_t *);
     69void dump_device_match_ids(usbinfo_device_t *);
     70
    5871#endif
    5972/**
Note: See TracChangeset for help on using the changeset viewer.