Changes in uspace/app/usbinfo/info.c [bf58895:206f71a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/info.c
rbf58895 r206f71a 40 40 #include <usb/recognise.h> 41 41 #include <usb/request.h> 42 #include <usb/classes/classes.h>43 42 #include "usbinfo.h" 44 45 void dump_short_device_identification(usbinfo_device_t *dev)46 {47 printf("%sDevice 0x%04x by vendor 0x%04x\n", get_indent(0),48 (int) dev->device_descriptor.product_id,49 (int) dev->device_descriptor.vendor_id);50 }51 52 void dump_device_match_ids(usbinfo_device_t *dev)53 {54 match_id_list_t matches;55 init_match_ids(&matches);56 usb_device_create_match_ids_from_device_descriptor(57 &dev->device_descriptor, &matches);58 dump_match_ids(&matches, get_indent(0));59 }60 61 static void dump_descriptor_tree_brief_device(const char *prefix,62 usb_standard_device_descriptor_t *descriptor)63 {64 printf("%sDevice (0x%04x by 0x%04x, %s)\n", prefix,65 (int) descriptor->product_id,66 (int) descriptor->vendor_id,67 usb_str_class(descriptor->device_class));68 }69 70 static void dump_descriptor_tree_brief_configuration(const char *prefix,71 usb_standard_configuration_descriptor_t *descriptor)72 {73 printf("%sConfiguration #%d\n", prefix,74 (int) descriptor->configuration_number);75 }76 77 static void dump_descriptor_tree_brief_interface(const char *prefix,78 usb_standard_interface_descriptor_t *descriptor)79 {80 printf("%sInterface #%d (%s, 0x%02x, 0x%02x)\n", prefix,81 (int) descriptor->interface_number,82 usb_str_class(descriptor->interface_class),83 (int) descriptor->interface_subclass,84 (int) descriptor->interface_protocol);85 }86 87 static void dump_descriptor_tree_brief_endpoint(const char *prefix,88 usb_standard_endpoint_descriptor_t *descriptor)89 {90 usb_endpoint_t endpoint_no = descriptor->endpoint_address & 0xF;91 usb_transfer_type_t transfer = descriptor->attributes & 0x3;92 usb_direction_t direction = descriptor->endpoint_address & 0x8093 ? USB_DIRECTION_IN : USB_DIRECTION_OUT;94 printf("%sEndpoint #%d (%s %s, %zu)\n", prefix,95 endpoint_no, usb_str_transfer_type(transfer),96 direction == USB_DIRECTION_IN ? "in" : "out",97 (size_t) descriptor->max_packet_size);98 }99 100 101 static void dump_descriptor_tree_brief_callback(uint8_t *descriptor,102 size_t depth, void *arg)103 {104 const char *indent = get_indent(depth + 1);105 106 int descr_type = -1;107 size_t descr_size = descriptor[0];108 if (descr_size > 0) {109 descr_type = descriptor[1];110 }111 112 switch (descr_type) {113 114 #define _BRANCH(type_enum, descriptor_type, callback) \115 case type_enum: \116 if (descr_size >= sizeof(descriptor_type)) { \117 callback(indent, (descriptor_type *) descriptor); \118 } else { \119 descr_type = -1; \120 } \121 break;122 123 _BRANCH(USB_DESCTYPE_DEVICE,124 usb_standard_device_descriptor_t,125 dump_descriptor_tree_brief_device);126 _BRANCH(USB_DESCTYPE_CONFIGURATION,127 usb_standard_configuration_descriptor_t,128 dump_descriptor_tree_brief_configuration);129 _BRANCH(USB_DESCTYPE_INTERFACE,130 usb_standard_interface_descriptor_t,131 dump_descriptor_tree_brief_interface);132 _BRANCH(USB_DESCTYPE_ENDPOINT,133 usb_standard_endpoint_descriptor_t,134 dump_descriptor_tree_brief_endpoint);135 136 default:137 break;138 }139 140 if (descr_type == -1) {141 printf("%sInvalid descriptor.\n", indent);142 }143 }144 145 void dump_descriptor_tree_brief(usbinfo_device_t *dev)146 {147 dump_descriptor_tree_brief_callback((uint8_t *)&dev->device_descriptor,148 (size_t) -1, NULL);149 usb_dp_walk_simple(dev->full_configuration_descriptor,150 dev->full_configuration_descriptor_size,151 usb_dp_standard_descriptor_nesting,152 dump_descriptor_tree_brief_callback,153 NULL);154 }155 43 156 44 int dump_device(devman_handle_t hc_handle, usb_address_t address) … … 204 92 goto leave; 205 93 } 206 dump_match_ids(&match_id_list , get_indent(0));94 dump_match_ids(&match_id_list); 207 95 208 96 /* … … 218 106 } 219 107 dump_usb_descriptor((uint8_t *)&device_descriptor, sizeof(device_descriptor)); 220 221 rc = EOK;222 goto leave;223 108 224 109 /*
Note:
See TracChangeset
for help on using the changeset viewer.