Changeset 10096231 in mainline
- Timestamp:
- 2010-12-10T16:44:57Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fa9b606
- Parents:
- c01255c
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.h
rc01255c r10096231 50 50 } usb_hub_info_t; 51 51 52 53 52 int usb_add_hub_device(device_t *); 54 53 -
uspace/drv/usbhub/usbhub_private.h
rc01255c r10096231 42 42 #include <driver.h> 43 43 #include <usb/usb.h> 44 #include <usb/classes/hub.h> 44 45 #include <usb/devreq.h> 45 46 … … 152 153 * @param request 153 154 * @param addr 155 * \TODO this will be obsolete see usb/dev_req.h 154 156 */ 155 157 static inline void usb_hub_set_set_address_request( … … 169 171 * @param addr 170 172 */ 171 static inline void usb_hub_ get_descriptor_request(173 static inline void usb_hub_set_descriptor_request( 172 174 usb_device_request_setup_packet_t * request 173 175 ){ … … 175 177 request->request_type = USB_HUB_REQ_TYPE_GET_DESCRIPTOR; 176 178 request->request = USB_HUB_REQUEST_GET_DESCRIPTOR; 177 request->value = USB_DESCTYPE_HUB; 179 request->value_high = USB_DESCTYPE_HUB; 180 request->value_low = 0; 178 181 request->length = USB_HUB_MAX_DESCRIPTOR_SIZE; 179 182 } -
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 -
uspace/drv/vhc/hubops.c
rc01255c r10096231 195 195 } 196 196 197 static int get_hub_descriptor(uint8_t descriptor_type, 198 uint8_t descriptor_index, uint16_t length) 199 { 197 static int get_hub_descriptor(struct usbvirt_device *dev, 198 uint8_t descriptor_index, 199 uint8_t descriptor_type, uint16_t length) 200 { 201 if (descriptor_type == USB_DESCTYPE_HUB) { 202 int rc = dev->control_transfer_reply(dev, 0, 203 &hub_descriptor, hub_descriptor.length); 204 205 return rc; 206 207 } 208 200 209 return ENOTSUP; 201 210 } … … 313 322 314 323 case USB_HUB_REQUEST_GET_DESCRIPTOR: 315 return get_hub_descriptor( request->value_low,324 return get_hub_descriptor(dev, request->value_low, 316 325 request->value_high, request->length); 317 326 -
uspace/lib/usb/include/usb/classes/hub.h
rc01255c r10096231 177 177 178 178 /** @brief hub class request codes*/ 179 /// \TODO these are duplicit to standart descriptors 179 180 typedef enum { 180 181 /** */ -
uspace/lib/usbvirt/transaction.c
rc01255c r10096231 184 184 actual_size = size; 185 185 } 186 device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION, 187 "in transaction: will copy %zu bytes", actual_size); 186 188 if (actual_size > 0) { 187 189 memcpy(buffer, transfer->data, actual_size);
Note:
See TracChangeset
for help on using the changeset viewer.