Changeset 4c74ac3 in mainline
- Timestamp:
- 2010-12-12T14:46:13Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 16ecc28
- Parents:
- b666608
- Location:
- uspace/drv/usbhub
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/main.c
rb666608 r4c74ac3 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
rb666608 r4c74ac3 53 53 } usb_hub_info_t; 54 54 55 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 56 77 57 78 #endif -
uspace/drv/usbhub/utils.c
rb666608 r4c74ac3 48 48 49 49 50 static void check_hub_changes(void);51 52 50 size_t USB_HUB_MAX_DESCRIPTOR_SIZE = 71; 53 51 … … 365 363 } 366 364 367 /** Callback when new hub device is detected.368 *369 * @param dev New device.370 * @return Error code.371 */372 365 int usb_add_hub_device(device_t *dev) { 373 366 printf(NAME ": add_hub_device(handle=%d)\n", (int) dev->handle); … … 407 400 printf("[usb_hub] hub info added to list\n"); 408 401 //(void)hub_info; 409 check_hub_changes();402 usb_hub_check_hub_changes(); 410 403 411 404 /// \TODO start the check loop, if not already started... … … 415 408 416 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); 417 413 418 414 return EOK; … … 461 457 * @param target 462 458 */ 463 static void usb_hub_finalize_add_device( 459 static void usb_hub_finalize_add_device( usb_hub_info_t * hub, 464 460 int hc, uint16_t port, usb_target_t target) { 465 461 … … 484 480 485 481 usb_drv_release_default_address(hc); 486 /* 487 devman_handle_t dev_handle; 488 rc = child_device_register_wrapper(hub_dev, "dev", 489 * match_id, match_score, &dev_handle); 490 if (rc != EOK) { 491 free(id); 492 } 493 * 494 */ 495 496 497 /// \TODO driver work 498 //add_child_device..... 499 //opResult = usb_drv_bind_address(hc, new_device_address, 500 //devman_handle_t handle);... 482 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 501 492 } 502 493 … … 534 525 * @param target 535 526 */ 536 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) { 537 528 printf("[usb_hub] interrupt at port %d\n", port); 538 529 //determine type of change … … 569 560 printf("[usb_hub] finalizing add device\n"); 570 561 if (usb_port_enabled(&status)) { 571 usb_hub_finalize_add_device(h c, port, target);562 usb_hub_finalize_add_device(hub, hc, port, target); 572 563 } else { 573 564 printf("[usb_hub] ERROR: port reset, but port still not enabled\n"); … … 600 591 /** Check changes on all known hubs. 601 592 */ 602 static voidcheck_hub_changes(void) {593 void usb_hub_check_hub_changes(void) { 603 594 /* 604 595 * Iterate through all hubs. … … 652 643 bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2; 653 644 if (interrupt) { 654 usb_hub_process_interrupt(h c, port, target);645 usb_hub_process_interrupt(hub_info, hc, port, target); 655 646 } 656 647 }
Note:
See TracChangeset
for help on using the changeset viewer.