Changeset 06f9a9c9 in mainline
- Timestamp:
- 2013-01-27T13:17:49Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e2dfa86
- Parents:
- 5b401b9
- Location:
- uspace/app/usbinfo
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/Makefile
r5b401b9 r06f9a9c9 43 43 SOURCES = \ 44 44 desctree.c \ 45 dev.c \46 45 dump.c \ 47 46 hid.c \ -
uspace/app/usbinfo/hid.c
r5b401b9 r06f9a9c9 36 36 #include <stdio.h> 37 37 #include <str_error.h> 38 #include <usb/debug.h> 38 39 #include <usb/classes/classes.h> 39 40 #include <usb/dev/request.h> … … 50 51 51 52 typedef struct { 52 usb info_device_t *dev;53 usb_device_t *usb_dev; 53 54 hid_dump_type_t dump_type; 54 55 usb_standard_interface_descriptor_t *last_iface; … … 213 214 214 215 retrieve_and_dump_hid_report(context->dump_type, 215 &context->dev->ctrl_pipe, context->last_iface->interface_number,216 report_size);217 } 218 219 220 void dump_hidreport_raw(usb info_device_t *dev)216 usb_device_get_default_pipe(context->usb_dev), 217 context->last_iface->interface_number, report_size); 218 } 219 220 221 void dump_hidreport_raw(usb_device_t *usb_dev) 221 222 { 222 223 descriptor_walk_context_t context = { 223 . dev =dev,224 .usb_dev = usb_dev, 224 225 .dump_type = HID_DUMP_RAW, 225 226 .last_iface = NULL 226 227 }; 227 228 228 usb_dp_walk_simple(dev->full_configuration_descriptor, 229 dev->full_configuration_descriptor_size, 230 usb_dp_standard_descriptor_nesting, 229 size_t desc_size = 0; 230 const void *desc = 231 usb_device_get_configuration_descriptor(usb_dev, &desc_size); 232 233 usb_dp_walk_simple(desc, desc_size, usb_dp_standard_descriptor_nesting, 231 234 descriptor_walk_callback, &context); 232 235 } 233 236 234 void dump_hidreport_usages(usb info_device_t *dev)237 void dump_hidreport_usages(usb_device_t *usb_dev) 235 238 { 236 239 descriptor_walk_context_t context = { 237 . dev =dev,240 .usb_dev = usb_dev, 238 241 .dump_type = HID_DUMP_USAGES, 239 242 .last_iface = NULL 240 243 }; 241 244 242 usb_dp_walk_simple(dev->full_configuration_descriptor, 243 dev->full_configuration_descriptor_size, 244 usb_dp_standard_descriptor_nesting, 245 size_t desc_size = 0; 246 const void *desc = 247 usb_device_get_configuration_descriptor(usb_dev, &desc_size); 248 249 usb_dp_walk_simple(desc, desc_size, usb_dp_standard_descriptor_nesting, 245 250 descriptor_walk_callback, &context); 246 251 } -
uspace/app/usbinfo/info.c
r5b401b9 r06f9a9c9 37 37 #include <str_error.h> 38 38 #include <errno.h> 39 #include <usb/debug.h> 39 40 #include <usb/dev/pipes.h> 40 41 #include <usb/dev/recognise.h> … … 44 45 #include "usbinfo.h" 45 46 46 void dump_short_device_identification(usb info_device_t *dev)47 void dump_short_device_identification(usb_device_t *usb_dev) 47 48 { 48 49 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 (int) usb_device_get_device_descriptor(usb_dev)->product_id, 51 (int) usb_device_get_device_descriptor(usb_dev)->vendor_id); 51 52 } 52 53 … … 66 67 } 67 68 68 usbinfo_device_t *dev = (usbinfo_device_t *) arg; 69 usb_device_t *usb_dev = arg; 70 assert(usb_dev); 69 71 70 72 usb_standard_interface_descriptor_t *iface … … 80 82 match_id_list_t matches; 81 83 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_get_device_descriptor(usb_dev), iface, &matches); 84 86 dump_match_ids(&matches, get_indent(1)); 85 87 clean_match_ids(&matches); 86 88 } 87 89 88 void dump_device_match_ids(usb info_device_t *dev)90 void dump_device_match_ids(usb_device_t *usb_dev) 89 91 { 90 92 match_id_list_t matches; 91 93 init_match_ids(&matches); 92 usb_device_create_match_ids_from_device_descriptor( 93 &dev->device_descriptor, &matches); 94 const usb_standard_device_descriptor_t *dev_desc = 95 usb_device_get_device_descriptor(usb_dev); 96 usb_device_create_match_ids_from_device_descriptor(dev_desc, &matches); 94 97 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)); 98 (int) dev_desc->product_id, (int) dev_desc->vendor_id, 99 usb_str_class(dev_desc->device_class)); 98 100 dump_match_ids(&matches, get_indent(1)); 99 101 clean_match_ids(&matches); 100 102 101 usb_dp_walk_simple(dev->full_configuration_descriptor, 102 dev->full_configuration_descriptor_size, 103 usb_dp_standard_descriptor_nesting, 104 dump_match_ids_from_interface, 105 dev); 103 size_t desc_size = 0; 104 const void *desc = 105 usb_device_get_configuration_descriptor(usb_dev, &desc_size); 106 107 usb_dp_walk_simple(desc, desc_size, usb_dp_standard_descriptor_nesting, 108 dump_match_ids_from_interface, usb_dev); 106 109 } 107 110 … … 224 227 } 225 228 226 void dump_descriptor_tree_brief(usbinfo_device_t *dev) 227 { 228 dump_descriptor_tree_callback((uint8_t *)&dev->device_descriptor, 229 void dump_descriptor_tree_brief(usb_device_t *usb_dev) 230 { 231 dump_descriptor_tree_callback( 232 (const uint8_t *)usb_device_get_device_descriptor(usb_dev), 229 233 (size_t) -1, NULL); 230 usb_dp_walk_simple(dev->full_configuration_descriptor, 231 dev->full_configuration_descriptor_size, 232 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, 243 usb_dp_standard_descriptor_nesting, 244 dump_descriptor_tree_callback, 245 dev); 234 235 size_t desc_size = 0; 236 const void *desc = 237 usb_device_get_configuration_descriptor(usb_dev, &desc_size); 238 239 usb_dp_walk_simple(desc, desc_size, usb_dp_standard_descriptor_nesting, 240 dump_descriptor_tree_callback, NULL); 241 } 242 243 void dump_descriptor_tree_full(usb_device_t *usb_dev) 244 { 245 dump_descriptor_tree_callback( 246 (const uint8_t *)usb_device_get_device_descriptor(usb_dev), 247 (size_t) -1, usb_dev); 248 249 size_t desc_size = 0; 250 const void *desc = 251 usb_device_get_configuration_descriptor(usb_dev, &desc_size); 252 253 usb_dp_walk_simple(desc, desc_size, usb_dp_standard_descriptor_nesting, 254 dump_descriptor_tree_callback, usb_dev); 246 255 } 247 256 … … 285 294 286 295 287 void dump_strings(usb info_device_t *dev)296 void dump_strings(usb_device_t *usb_dev) 288 297 { 289 298 /* Find used indexes. Devices with more than 64 strings are very rare.*/ 290 299 uint64_t str_mask = 0; 291 find_string_indexes_callback((uint8_t *)&dev->device_descriptor, 0, 300 find_string_indexes_callback( 301 (const uint8_t *)usb_device_get_device_descriptor(usb_dev), 0, 292 302 &str_mask); 293 usb_dp_walk_simple(dev->full_configuration_descriptor, 294 dev->full_configuration_descriptor_size, 295 usb_dp_standard_descriptor_nesting, 296 find_string_indexes_callback, 297 &str_mask); 303 size_t desc_size = 0; 304 const void *desc = 305 usb_device_get_configuration_descriptor(usb_dev, &desc_size); 306 307 usb_dp_walk_simple(desc, desc_size, usb_dp_standard_descriptor_nesting, 308 find_string_indexes_callback, &str_mask); 298 309 299 310 if (str_mask == 0) { … … 305 316 l18_win_locales_t *langs; 306 317 size_t langs_count; 307 int rc = usb_request_get_supported_languages( &dev->ctrl_pipe,308 &langs, &langs_count);318 int rc = usb_request_get_supported_languages( 319 usb_device_get_default_pipe(usb_dev), &langs, &langs_count); 309 320 if (rc != EOK) { 310 321 fprintf(stderr, … … 334 345 } 335 346 char *string = NULL; 336 rc = usb_request_get_string(&dev->ctrl_pipe, idx, lang, 347 rc = usb_request_get_string( 348 usb_device_get_default_pipe(usb_dev), idx, lang, 337 349 &string); 338 350 if ((rc != EOK) && (rc != EEMPTY)) { … … 351 363 352 364 353 void dump_status(usb info_device_t *dev)365 void dump_status(usb_device_t *usb_dev) 354 366 { 355 367 int rc; … … 357 369 358 370 /* Device status first. */ 359 rc = usb_request_get_status( &dev->ctrl_pipe,371 rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev), 360 372 USB_REQUEST_RECIPIENT_DEVICE, 0, &status); 361 373 if (rc != EOK) { … … 373 385 /* Control endpoint zero. */ 374 386 status = 0; 375 rc = usb_request_get_status( &dev->ctrl_pipe,387 rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev), 376 388 USB_REQUEST_RECIPIENT_ENDPOINT, 0, &status); 377 389 if (rc != EOK) { -
uspace/app/usbinfo/main.c
r5b401b9 r06f9a9c9 198 198 199 199 /* The initialization is here only to make compiler happy. */ 200 devman_handle_t hc_handle = 0; 201 usb_address_t dev_addr = 0; 200 devman_handle_t handle = 0; 202 201 int rc = usb_resolve_device_handle(devpath, 203 &hc_handle, &dev_addr, NULL);202 NULL, NULL, &handle); 204 203 if (rc != EOK) { 205 204 fprintf(stderr, NAME ": device `%s' not found " … … 209 208 } 210 209 211 usb info_device_t *dev = prepare_device(devpath,212 hc_handle, dev_addr); 213 if ( dev == NULL) {210 usb_device_t *usb_dev = usb_device_create(handle); 211 212 if (usb_dev == NULL) { 214 213 continue; 215 214 } … … 221 220 while (actions[action].opt != 0) { 222 221 if (actions[action].active) { 223 actions[action].action( dev);222 actions[action].action(usb_dev); 224 223 } 225 224 action++; 226 225 } 227 226 228 /* Destroy the control pipe (close the session etc.). */ 229 destroy_device(dev); 227 usb_device_destroy(usb_dev); 230 228 } 231 229 -
uspace/app/usbinfo/usbinfo.h
r5b401b9 r06f9a9c9 38 38 #include <usb/usb.h> 39 39 #include <usb/descriptor.h> 40 #include <usb/dev/pipes.h> 41 #include <usb/debug.h> 40 #include <usb/dev/device.h> 42 41 #include <usb/dev/dp.h> 43 42 #include <ipc/devman.h> 44 43 45 44 typedef struct { 46 usb_hc_connection_t hc_conn;47 usb_device_connection_t wire;48 usb_pipe_t ctrl_pipe;49 usb_standard_device_descriptor_t device_descriptor;50 uint8_t *full_configuration_descriptor;51 size_t full_configuration_descriptor_size;52 } usbinfo_device_t;53 54 typedef struct {55 45 int opt; 56 void (*action)(usb info_device_t *dev);46 void (*action)(usb_device_t *usb_dev); 57 47 bool active; 58 48 } usbinfo_action_t; … … 72 62 } 73 63 74 usbinfo_device_t *prepare_device(const char *, devman_handle_t, usb_address_t);75 void destroy_device(usbinfo_device_t *);76 77 64 typedef void (*dump_descriptor_in_tree_t)(const uint8_t *, size_t, void *); 78 65 void browse_descriptor_tree(uint8_t *, size_t, usb_dp_descriptor_nesting_t *, … … 81 68 void list(void); 82 69 83 void dump_short_device_identification(usbinfo_device_t *); 84 void dump_device_match_ids(usbinfo_device_t *); 85 void dump_descriptor_tree_brief(usbinfo_device_t *); 86 void dump_descriptor_tree_full(usbinfo_device_t *); 87 void dump_strings(usbinfo_device_t *); 88 void dump_status(usbinfo_device_t *); 89 void dump_hidreport_raw(usbinfo_device_t *); 90 void dump_hidreport_usages(usbinfo_device_t *); 91 70 void dump_short_device_identification(usb_device_t *); 71 void dump_device_match_ids(usb_device_t *); 72 void dump_descriptor_tree_brief(usb_device_t *); 73 void dump_descriptor_tree_full(usb_device_t *); 74 void dump_strings(usb_device_t *); 75 void dump_status(usb_device_t *); 76 void dump_hidreport_raw(usb_device_t *); 77 void dump_hidreport_usages(usb_device_t *); 92 78 93 79 #endif
Note:
See TracChangeset
for help on using the changeset viewer.