Changes in / [16ecc28:1f3158c] in mainline
- Location:
- uspace/drv/usbhub
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/main.c
r16ecc28 r1f3158c 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 #include <usb/usbdrv.h> 29 29 #include <driver.h> 30 30 #include <errno.h> 31 #include <async.h>32 33 #include <usb/usbdrv.h>34 31 #include "usbhub.h" 35 32 #include "usbhub_private.h" … … 47 44 }; 48 45 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 58 46 int main(int argc, char *argv[]) 59 47 { 60 48 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 68 49 return driver_main(&hub_driver); 69 50 } -
uspace/drv/usbhub/usbhub.h
r16ecc28 r1f3158c 46 46 /** Number of ports. */ 47 47 int port_count; 48 /** General usb device info. */ 49 usb_hcd_attached_device_info_t * usb_device; 50 /** General device info*/ 51 device_t * device; 52 48 /** General device info. */ 49 usb_hcd_attached_device_info_t * device; 53 50 } usb_hub_info_t; 54 51 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 52 int usb_add_hub_device(device_t *); 77 53 78 54 #endif -
uspace/drv/usbhub/utils.c
r16ecc28 r1f3158c 34 34 */ 35 35 #include <driver.h> 36 #include <bool.h> 37 #include <errno.h> 38 36 #include <usb/devreq.h> 39 37 #include <usbhc_iface.h> 40 38 #include <usb/usbdrv.h> 41 39 #include <usb/descriptor.h> 42 #include <usb/devreq.h> 40 #include <driver.h> 41 #include <bool.h> 42 #include <errno.h> 43 43 #include <usb/classes/hub.h> 44 45 44 #include "usbhub.h" 46 45 #include "usbhub_private.h" 47 46 #include "port_status.h" 48 47 #include <usb/devreq.h> 48 49 static void check_hub_changes(void); 49 50 50 51 size_t USB_HUB_MAX_DESCRIPTOR_SIZE = 71; … … 301 302 //result->device = device; 302 303 result->port_count = -1; 303 /// \TODO is this correct? is the device stored?304 result->device = device;305 304 306 305 … … 317 316 }*/ 318 317 319 result-> usb_device = usb_new(usb_hcd_attached_device_info_t);320 result-> usb_device->address = addr;318 result->device = usb_new(usb_hcd_attached_device_info_t); 319 result->device->address = addr; 321 320 322 321 // get hub descriptor … … 363 362 } 364 363 364 /** Callback when new hub device is detected. 365 * 366 * @param dev New device. 367 * @return Error code. 368 */ 365 369 int usb_add_hub_device(device_t *dev) { 366 370 printf(NAME ": add_hub_device(handle=%d)\n", (int) dev->handle); … … 383 387 usb_device_request_setup_packet_t request; 384 388 usb_target_t target; 385 target.address = hub_info-> usb_device->address;389 target.address = hub_info->device->address; 386 390 target.endpoint = 0; 387 391 for (port = 0; port < hub_info->port_count; ++port) { … … 400 404 printf("[usb_hub] hub info added to list\n"); 401 405 //(void)hub_info; 402 usb_hub_check_hub_changes();406 check_hub_changes(); 403 407 404 408 /// \TODO start the check loop, if not already started... … … 408 412 409 413 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);413 414 414 415 return EOK; … … 428 429 * @param target 429 430 */ 431 430 432 static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) { 431 433 usb_device_request_setup_packet_t request; … … 457 459 * @param target 458 460 */ 459 static void usb_hub_finalize_add_device( usb_hub_info_t * hub,461 static void usb_hub_finalize_add_device( 460 462 int hc, uint16_t port, usb_target_t target) { 461 463 … … 477 479 return; 478 480 } 479 480 481 481 usb_drv_release_default_address(hc); 482 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 483 484 /// \TODO driver work 485 //add_child_device..... 492 486 } 493 487 … … 525 519 * @param target 526 520 */ 527 static void usb_hub_process_interrupt( usb_hub_info_t * hub,int hc, uint16_t port, usb_target_t target) {521 static void usb_hub_process_interrupt(int hc, uint16_t port, usb_target_t target) { 528 522 printf("[usb_hub] interrupt at port %d\n", port); 529 523 //determine type of change … … 560 554 printf("[usb_hub] finalizing add device\n"); 561 555 if (usb_port_enabled(&status)) { 562 usb_hub_finalize_add_device(h ub, hc, port, target);556 usb_hub_finalize_add_device(hc, port, target); 563 557 } else { 564 558 printf("[usb_hub] ERROR: port reset, but port still not enabled\n"); … … 591 585 /** Check changes on all known hubs. 592 586 */ 593 void usb_hub_check_hub_changes(void) {587 static void check_hub_changes(void) { 594 588 /* 595 589 * Iterate through all hubs. … … 600 594 lst_item = lst_item->next) { 601 595 printf("[usb_hub] checking hub changes\n"); 602 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);603 596 /* 604 597 * Check status change pipe of this hub. 605 598 */ 606 599 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; 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; 612 608 613 609 /* 614 610 * Connect to respective HC. 615 611 */ 616 int hc = usb_drv_hc_connect(hub_info->device, 0); 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); 617 616 if (hc < 0) { 618 617 continue; … … 643 642 bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2; 644 643 if (interrupt) { 645 usb_hub_process_interrupt(h ub_info, hc, port, target);644 usb_hub_process_interrupt(hc, port, target); 646 645 } 647 646 }
Note:
See TracChangeset
for help on using the changeset viewer.