Changeset 10096231 in mainline for uspace/drv/usbhub/utils.c
- Timestamp:
- 2010-12-10T16:44:57Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fa9b606
- Parents:
- c01255c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/utils.c
rc01255c r10096231 89 89 usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * serialized_descriptor) { 90 90 uint8_t * sdescriptor = (uint8_t*) serialized_descriptor; 91 if (sdescriptor[1] != USB_DESCTYPE_HUB) return NULL; 91 92 if (sdescriptor[1] != USB_DESCTYPE_HUB) { 93 printf("[usb_hub] wrong descriptor %x\n",sdescriptor[1]); 94 return NULL; 95 } 96 92 97 usb_hub_descriptor_t * result = usb_new(usb_hub_descriptor_t); 93 //uint8_t size = sdescriptor[0]; 98 99 94 100 result->ports_count = sdescriptor[2]; 95 101 /// @fixme handling of endianness?? … … 99 105 size_t var_size = result->ports_count / 8 + ((result->ports_count % 8 > 0) ? 1 : 0); 100 106 result->devices_removable = (uint8_t*) malloc(var_size); 101 107 //printf("[usb_hub] getting removable devices data \n"); 102 108 size_t i; 103 109 for (i = 0; i < var_size; ++i) { … … 298 304 299 305 300 printf("[usb_hub] phone to hc = %d\n", hc);306 //printf("[usb_hub] phone to hc = %d\n", hc); 301 307 if (hc < 0) { 302 308 return result; 303 309 } 304 310 //get some hub info 305 /// \TODO get correct params306 311 usb_address_t addr = usb_drv_get_my_address(hc, device); 307 312 addr = 7; … … 320 325 target.endpoint = 0; 321 326 usb_device_request_setup_packet_t request; 322 usb_hub_get_descriptor_request(&request); 327 //printf("[usb_hub] creating descriptor request\n"); 328 usb_hub_set_descriptor_request(&request); 329 330 //printf("[usb_hub] creating serialized descriptor\n"); 323 331 void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE); 324 332 usb_hub_descriptor_t * descriptor; 325 333 size_t received_size; 326 334 int opResult; 327 335 //printf("[usb_hub] starting control transaction\n"); 328 336 opResult = usb_drv_sync_control_read( 329 337 hc, target, &request, serialized_descriptor, 330 338 USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size); 331 339 if (opResult != EOK) { 332 printf("[usb_hub] failed when receiving hub descriptor \n"); 333 } 340 printf("[usb_hub] failed when receiving hub descriptor, badcode = %d\n",opResult); 341 ///\TODO memory leak will occur here! 342 return result; 343 } 344 //printf("[usb_hub] deserializing descriptor\n"); 334 345 descriptor = usb_deserialize_hub_desriptor(serialized_descriptor); 346 if(descriptor==NULL){ 347 printf("[usb_hub] could not deserialize descriptor \n"); 348 result->port_count = 1;///\TODO this code is only for debug!!! 349 return result; 350 } 351 //printf("[usb_hub] setting port count to %d\n",descriptor->ports_count); 335 352 result->port_count = descriptor->ports_count; 353 //printf("[usb_hub] freeing data\n"); 336 354 free(serialized_descriptor); 355 free(descriptor->devices_removable); 337 356 free(descriptor); 338 357 … … 362 381 //get hc connection 363 382 /// \TODO correct params 364 int hc = usb_drv_hc_connect( NULL, 0);383 int hc = usb_drv_hc_connect(dev, 0); 365 384 366 385 usb_hub_info_t * hub_info = usb_create_hub_info(dev, hc); … … 416 435 int opResult; 417 436 printf("[usb_hub] some connection changed\n"); 437 418 438 opResult = usb_drv_reserve_default_address(hc); 419 439 if (opResult != EOK) { 420 440 printf("[usb_hub] cannot assign default address, it is probably used\n"); 441 return; 421 442 } 422 443 //reset port … … 456 477 if (opResult != EOK) { 457 478 printf("[usb_hub] could not set address for new device\n"); 479 //will retry later... 480 return; 458 481 } 459 482 usb_drv_release_default_address(hc); … … 461 484 462 485 /// \TODO driver work 486 //add_child_device..... 463 487 } 464 488
Note:
See TracChangeset
for help on using the changeset viewer.