Changeset e2dfa86 in mainline
- Timestamp:
- 2013-01-27T13:54:40Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eb2a0f
- Parents:
- 06f9a9c9
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/hid.c
r06f9a9c9 re2dfa86 227 227 }; 228 228 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, 229 usb_dp_walk_simple( 230 usb_device_descriptors(usb_dev)->full_config, 231 usb_device_descriptors(usb_dev)->full_config_size, 232 usb_dp_standard_descriptor_nesting, 234 233 descriptor_walk_callback, &context); 235 234 } … … 243 242 }; 244 243 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, 244 usb_dp_walk_simple( 245 usb_device_descriptors(usb_dev)->full_config, 246 usb_device_descriptors(usb_dev)->full_config_size, 247 usb_dp_standard_descriptor_nesting, 250 248 descriptor_walk_callback, &context); 251 249 } -
uspace/app/usbinfo/info.c
r06f9a9c9 re2dfa86 48 48 { 49 49 printf("%sDevice 0x%04x by vendor 0x%04x\n", get_indent(0), 50 (int) usb_device_get_device_descriptor(usb_dev)->product_id,51 (int) usb_device_get_device_descriptor(usb_dev)->vendor_id);50 usb_device_descriptors(usb_dev)->device.product_id, 51 usb_device_descriptors(usb_dev)->device.vendor_id); 52 52 } 53 53 … … 83 83 init_match_ids(&matches); 84 84 usb_device_create_match_ids_from_interface( 85 usb_device_get_device_descriptor(usb_dev), iface, &matches);85 &usb_device_descriptors(usb_dev)->device, iface, &matches); 86 86 dump_match_ids(&matches, get_indent(1)); 87 87 clean_match_ids(&matches); … … 92 92 match_id_list_t matches; 93 93 init_match_ids(&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 usb_device_create_match_ids_from_device_descriptor( 95 &usb_device_descriptors(usb_dev)->device, &matches); 97 96 printf("%sDevice match ids (0x%04x by 0x%04x, %s)\n", get_indent(0), 98 (int) dev_desc->product_id, (int) dev_desc->vendor_id, 99 usb_str_class(dev_desc->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)); 100 100 dump_match_ids(&matches, get_indent(1)); 101 101 clean_match_ids(&matches); 102 102 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, 103 usb_dp_walk_simple( 104 usb_device_descriptors(usb_dev)->full_config, 105 usb_device_descriptors(usb_dev)->full_config_size, 106 usb_dp_standard_descriptor_nesting, 108 107 dump_match_ids_from_interface, usb_dev); 109 108 } … … 230 229 { 231 230 dump_descriptor_tree_callback( 232 (const uint8_t *) usb_device_get_device_descriptor(usb_dev),231 (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 233 232 (size_t) -1, NULL); 234 233 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, 234 usb_dp_walk_simple( 235 usb_device_descriptors(usb_dev)->full_config, 236 usb_device_descriptors(usb_dev)->full_config_size, 237 usb_dp_standard_descriptor_nesting, 240 238 dump_descriptor_tree_callback, NULL); 241 239 } … … 244 242 { 245 243 dump_descriptor_tree_callback( 246 (const uint8_t *) usb_device_get_device_descriptor(usb_dev),244 (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 247 245 (size_t) -1, usb_dev); 248 246 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, 247 usb_dp_walk_simple( 248 usb_device_descriptors(usb_dev)->full_config, 249 usb_device_descriptors(usb_dev)->full_config_size, 250 usb_dp_standard_descriptor_nesting, 254 251 dump_descriptor_tree_callback, usb_dev); 255 252 } … … 299 296 uint64_t str_mask = 0; 300 297 find_string_indexes_callback( 301 (const uint8_t *) usb_device_get_device_descriptor(usb_dev), 0,298 (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 0, 302 299 &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,300 301 usb_dp_walk_simple( 302 usb_device_descriptors(usb_dev)->full_config, 303 usb_device_descriptors(usb_dev)->full_config_size, 304 usb_dp_standard_descriptor_nesting, 308 305 find_string_indexes_callback, &str_mask); 309 306 -
uspace/drv/bus/usb/usbhid/usbhid.c
r06f9a9c9 re2dfa86 120 120 assert(mapping); 121 121 const usb_standard_device_descriptor_t *d = 122 usb_device_get_device_descriptor(hid_dev->usb_dev);122 &usb_device_descriptors(hid_dev->usb_dev)->device; 123 123 124 124 return (d->vendor_id == mapping->vendor_id) -
uspace/drv/bus/usb/usbhub/usbhub.c
r06f9a9c9 re2dfa86 359 359 /* Get number of possible configurations from device descriptor */ 360 360 const size_t configuration_count = 361 usb_device_ get_device_descriptor(usb_device)->configuration_count;361 usb_device_descriptors(usb_device)->device.configuration_count; 362 362 usb_log_debug("Hub has %zu configurations.\n", configuration_count); 363 363 … … 368 368 369 369 // TODO: Make sure that the cast is correct 370 size_t config_size = 0; 370 const size_t config_size = 371 usb_device_descriptors(usb_device)->full_config_size; 371 372 const usb_standard_configuration_descriptor_t *config_descriptor = 372 usb_device_ get_configuration_descriptor(usb_device, &config_size);373 usb_device_descriptors(usb_device)->full_config; 373 374 374 375 if (config_size < sizeof(usb_standard_configuration_descriptor_t)) { … … 377 378 return EOVERFLOW; 378 379 } 379 380 380 381 381 /* Set configuration. Use the configuration that was in -
uspace/drv/bus/usb/usbmid/explore.c
r06f9a9c9 re2dfa86 118 118 usbmid_interface_t *iface = NULL; 119 119 const int rc = usbmid_spawn_interface_child(usb_dev, &iface, 120 usb_device_get_device_descriptor(usb_dev), interface);120 &usb_device_descriptors(usb_dev)->device, interface); 121 121 if (rc != EOK) { 122 122 //TODO: Do something about that failure. … … 142 142 int usbmid_explore_device(usb_device_t *dev) 143 143 { 144 assert(dev); 144 145 const unsigned dev_class = 145 usb_device_ get_device_descriptor(dev)->device_class;146 usb_device_descriptors(dev)->device.device_class; 146 147 if (dev_class != USB_CLASS_USE_INTERFACE) { 147 148 usb_log_warning( … … 154 155 155 156 /* Get coonfiguration descriptor. */ 156 size_t config_descriptor_size = 0; 157 const size_t config_descriptor_size = 158 usb_device_descriptors(dev)->full_config_size; 157 159 const void *config_descriptor_raw = 158 usb_device_get_configuration_descriptor(dev, 159 &config_descriptor_size); 160 usb_device_descriptors(dev)->full_config; 160 161 const usb_standard_configuration_descriptor_t *config_descriptor = 161 162 config_descriptor_raw; -
uspace/lib/usbdev/include/usb/dev/device.h
r06f9a9c9 re2dfa86 41 41 #include <usb/dev/pipes.h> 42 42 43 /** Some useful descriptors for USB device. */ 44 typedef struct { 45 /** Standard device descriptor. */ 46 usb_standard_device_descriptor_t device; 47 /** Full configuration descriptor of current configuration. */ 48 const void *full_config; 49 size_t full_config_size; 50 } usb_device_descriptors_t; 51 43 52 typedef struct usb_device usb_device_t; 44 53 … … 70 79 int usb_device_get_iface_number(usb_device_t *); 71 80 72 const usb_standard_device_descriptor_t * 73 usb_device_get_device_descriptor(usb_device_t *); 74 const void * usb_device_get_configuration_descriptor(usb_device_t *, size_t *); 81 const usb_device_descriptors_t * usb_device_descriptors(usb_device_t *); 82 75 83 const usb_alternate_interfaces_t * usb_device_get_alternative_ifaces( 76 84 usb_device_t *); -
uspace/lib/usbdev/src/devdrv.c
r06f9a9c9 re2dfa86 68 68 /** Alternative interfaces. */ 69 69 usb_alternate_interfaces_t alternate_interfaces; 70 71 70 /** Some useful descriptors for USB device. */ 72 struct { 73 /** Standard device descriptor. */ 74 usb_standard_device_descriptor_t device; 75 /** Full configuration descriptor of current configuration. */ 76 const uint8_t *configuration; 77 size_t configuration_size; 78 } descriptors; 79 71 usb_device_descriptors_t descriptors; 80 72 /** Generic DDF device backing this one. DO NOT TOUCH! */ 81 73 ddf_dev_t *ddf_dev; … … 160 152 { 161 153 assert(usb_dev); 162 assert(usb_dev->descriptors. configuration== NULL);154 assert(usb_dev->descriptors.full_config == NULL); 163 155 164 156 /* It is worth to start a long transfer. */ … … 175 167 rc = usb_request_get_full_configuration_descriptor_alloc( 176 168 &usb_dev->ctrl_pipe, 0, 177 (void **) &usb_dev->descriptors.configuration,178 &usb_dev->descriptors. configuration_size);169 (void**)&usb_dev->descriptors.full_config, 170 &usb_dev->descriptors.full_config_size); 179 171 180 172 leave: … … 191 183 { 192 184 assert(usb_dev); 193 free(usb_dev->descriptors. configuration);194 usb_dev->descriptors. configuration= NULL;195 usb_dev->descriptors. configuration_size = 0;185 free(usb_dev->descriptors.full_config); 186 usb_dev->descriptors.full_config = NULL; 187 usb_dev->descriptors.full_config_size = 0; 196 188 } 197 189 … … 219 211 { 220 212 assert(usb_dev); 221 assert(usb_dev->descriptors. configuration);213 assert(usb_dev->descriptors.full_config); 222 214 assert(usb_dev->pipes == NULL); 223 215 assert(usb_dev->pipes_count == 0); … … 244 236 /* Find the mapping from configuration descriptor. */ 245 237 int rc = usb_pipe_initialize_from_configuration(pipes, pipe_count, 246 usb_dev->descriptors. configuration,247 usb_dev->descriptors. configuration_size, &usb_dev->wire);238 usb_dev->descriptors.full_config, 239 usb_dev->descriptors.full_config_size, &usb_dev->wire); 248 240 if (rc != EOK) { 249 241 free(pipes); … … 338 330 } 339 331 340 const usb_standard_device_descriptor_t * 341 usb_device_get_device_descriptor(usb_device_t *usb_dev) 342 { 343 assert(usb_dev); 344 return &usb_dev->descriptors.device; 345 } 346 347 const void * usb_device_get_configuration_descriptor( 348 usb_device_t *usb_dev, size_t *size) 349 { 350 assert(usb_dev); 351 if (size) 352 *size = usb_dev->descriptors.configuration_size; 353 return usb_dev->descriptors.configuration; 332 const usb_device_descriptors_t *usb_device_descriptors(usb_device_t *usb_dev) 333 { 334 assert(usb_dev); 335 return &usb_dev->descriptors; 354 336 } 355 337 … … 430 412 usb_dev->ddf_dev = ddf_dev; 431 413 usb_dev->driver_data = NULL; 432 usb_dev->descriptors.configuration = NULL; 414 usb_dev->descriptors.full_config = NULL; 415 usb_dev->descriptors.full_config_size = 0; 433 416 usb_dev->pipes_count = 0; 434 417 usb_dev->pipes = NULL; … … 500 483 * controlling a device. */ 501 484 rc = usb_alternate_interfaces_init(&usb_dev->alternate_interfaces, 502 usb_dev->descriptors. configuration,503 usb_dev->descriptors. configuration_size, usb_dev->interface_no);485 usb_dev->descriptors.full_config, 486 usb_dev->descriptors.full_config_size, usb_dev->interface_no); 504 487 505 488 if (endpoints) { -
uspace/lib/usbhid/src/hidreport.c
r06f9a9c9 re2dfa86 60 60 }; 61 61 62 size_t desc_size = 0;63 const void *desc =64 usb_device_get_configuration_descriptor(dev, &desc_size);65 66 62 usb_dp_parser_data_t parser_data = { 67 .data = desc,68 .size = desc_size,63 .data = usb_device_descriptors(dev)->full_config, 64 .size = usb_device_descriptors(dev)->full_config_size, 69 65 .arg = NULL 70 66 }; … … 74 70 */ 75 71 const uint8_t *d = 76 usb_dp_get_nested_descriptor(&parser, &parser_data, desc); 72 usb_dp_get_nested_descriptor(&parser, &parser_data, 73 usb_device_descriptors(dev)->full_config); 77 74 78 75 /* … … 82 79 while (d != NULL && i < usb_device_get_iface_number(dev)) { 83 80 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 84 desc, d);81 usb_device_descriptors(dev)->full_config, d); 85 82 ++i; 86 83 }
Note:
See TracChangeset
for help on using the changeset viewer.