Changeset c9113d2 in mainline
- Timestamp:
- 2010-12-12T14:52:39Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 138a7fd
- Parents:
- a822cd8 (diff), 3b9f1fd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/drv/usbhub
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/main.c
ra822cd8 rc9113d2 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 #include <usb/usbdrv.h> 28 29 29 #include <driver.h> 30 30 #include <errno.h> 31 #include <async.h> 32 33 #include <usb/usbdrv.h> 31 34 #include "usbhub.h" 32 35 #include "usbhub_private.h" … … 44 47 }; 45 48 49 int usb_hub_control_loop(void * noparam){ 50 while(true){ 51 usb_hub_check_hub_changes(); 52 async_usleep(10000); 53 } 54 return 0; 55 } 56 57 46 58 int main(int argc, char *argv[]) 47 59 { 48 60 usb_lst_init(&usb_hub_list); 61 fid_t fid = fibril_create(usb_hub_control_loop, NULL); 62 if (fid == 0) { 63 printf("%s: failed to start fibril for HUB devices\n", NAME); 64 return ENOMEM; 65 } 66 fibril_add_ready(fid); 67 49 68 return driver_main(&hub_driver); 50 69 } -
uspace/drv/usbhub/usbhub.h
ra822cd8 rc9113d2 46 46 /** Number of ports. */ 47 47 int port_count; 48 /** General device info. */ 49 usb_hcd_attached_device_info_t * device; 48 /** General usb device info. */ 49 usb_hcd_attached_device_info_t * usb_device; 50 /** General device info*/ 51 device_t * device; 52 50 53 } usb_hub_info_t; 51 54 52 int usb_add_hub_device(device_t *); 55 /** 56 * function running the hub-controlling loop. 57 * @param noparam fundtion does not need any parameters 58 */ 59 int usb_hub_control_loop(void * noparam); 60 61 /** Callback when new hub device is detected. 62 * 63 * @param dev New device. 64 * @return Error code. 65 */ 66 int usb_add_hub_device(device_t *dev); 67 68 /** 69 * check changes on all registered hubs 70 */ 71 void usb_hub_check_hub_changes(void); 72 73 74 //int usb_add_hub_device(device_t *); 75 76 53 77 54 78 #endif -
uspace/drv/usbhub/utils.c
ra822cd8 rc9113d2 34 34 */ 35 35 #include <driver.h> 36 #include <usb/devreq.h> 36 #include <bool.h> 37 #include <errno.h> 38 37 39 #include <usbhc_iface.h> 38 40 #include <usb/usbdrv.h> 39 41 #include <usb/descriptor.h> 40 #include <driver.h> 41 #include <bool.h> 42 #include <errno.h> 42 #include <usb/devreq.h> 43 43 #include <usb/classes/hub.h> 44 44 45 #include "usbhub.h" 45 46 #include "usbhub_private.h" 46 47 #include "port_status.h" 47 #include <usb/devreq.h> 48 49 static void check_hub_changes(void); 48 50 49 51 50 size_t USB_HUB_MAX_DESCRIPTOR_SIZE = 71; … … 302 301 //result->device = device; 303 302 result->port_count = -1; 303 /// \TODO is this correct? is the device stored? 304 result->device = device; 304 305 305 306 … … 316 317 }*/ 317 318 318 result-> device = usb_new(usb_hcd_attached_device_info_t);319 result-> device->address = addr;319 result->usb_device = usb_new(usb_hcd_attached_device_info_t); 320 result->usb_device->address = addr; 320 321 321 322 // get hub descriptor … … 362 363 } 363 364 364 /** Callback when new hub device is detected.365 *366 * @param dev New device.367 * @return Error code.368 */369 365 int usb_add_hub_device(device_t *dev) { 370 366 printf(NAME ": add_hub_device(handle=%d)\n", (int) dev->handle); … … 387 383 usb_device_request_setup_packet_t request; 388 384 usb_target_t target; 389 target.address = hub_info-> device->address;385 target.address = hub_info->usb_device->address; 390 386 target.endpoint = 0; 391 387 for (port = 0; port < hub_info->port_count; ++port) { … … 404 400 printf("[usb_hub] hub info added to list\n"); 405 401 //(void)hub_info; 406 check_hub_changes();402 usb_hub_check_hub_changes(); 407 403 408 404 /// \TODO start the check loop, if not already started... … … 412 408 413 409 printf("[usb_hub] hub dev added\n"); 410 printf("\taddress %d, has %d ports \n", 411 hub_info->usb_device->address, 412 hub_info->port_count); 414 413 415 414 return EOK; … … 429 428 * @param target 430 429 */ 431 432 430 static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) { 433 431 usb_device_request_setup_packet_t request; … … 459 457 * @param target 460 458 */ 461 static void usb_hub_finalize_add_device( 459 static void usb_hub_finalize_add_device( usb_hub_info_t * hub, 462 460 int hc, uint16_t port, usb_target_t target) { 463 461 … … 479 477 return; 480 478 } 479 480 481 481 usb_drv_release_default_address(hc); 482 482 483 484 /// \TODO driver work 485 //add_child_device..... 483 devman_handle_t child_handle; 484 opResult = usb_drv_register_child_in_devman(hc, hub->device, 485 new_device_address, &child_handle); 486 if (opResult != EOK) { 487 printf("[usb_hub] could not start driver for new device \n"); 488 return; 489 } 490 usb_drv_bind_address(hc, new_device_address, child_handle); 491 486 492 } 487 493 … … 519 525 * @param target 520 526 */ 521 static void usb_hub_process_interrupt( int hc, uint16_t port, usb_target_t target) {527 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) { 522 528 printf("[usb_hub] interrupt at port %d\n", port); 523 529 //determine type of change … … 554 560 printf("[usb_hub] finalizing add device\n"); 555 561 if (usb_port_enabled(&status)) { 556 usb_hub_finalize_add_device(h c, port, target);562 usb_hub_finalize_add_device(hub, hc, port, target); 557 563 } else { 558 564 printf("[usb_hub] ERROR: port reset, but port still not enabled\n"); … … 585 591 /** Check changes on all known hubs. 586 592 */ 587 static voidcheck_hub_changes(void) {593 void usb_hub_check_hub_changes(void) { 588 594 /* 589 595 * Iterate through all hubs. … … 594 600 lst_item = lst_item->next) { 595 601 printf("[usb_hub] checking hub changes\n"); 602 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data); 596 603 /* 597 604 * Check status change pipe of this hub. 598 605 */ 599 606 600 usb_target_t target = { 601 .address = 5, 602 .endpoint = 1 603 }; 604 /// \TODO uncomment once it works correctly 605 //target.address = usb_create_hub_info(lst_item)->device->address; 606 607 size_t port_count = 7; 607 usb_target_t target; 608 target.address = hub_info->usb_device->address; 609 target.endpoint = 1; 610 611 size_t port_count = hub_info->port_count; 608 612 609 613 /* 610 614 * Connect to respective HC. 611 615 */ 612 /// \FIXME this is incorrect code: here 613 /// must be used particular device instead of NULL 614 //which one? 615 int hc = usb_drv_hc_connect(NULL, 0); 616 int hc = usb_drv_hc_connect(hub_info->device, 0); 616 617 if (hc < 0) { 617 618 continue; … … 642 643 bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2; 643 644 if (interrupt) { 644 usb_hub_process_interrupt(h c, port, target);645 usb_hub_process_interrupt(hub_info, hc, port, target); 645 646 } 646 647 }
Note:
See TracChangeset
for help on using the changeset viewer.