Changes in / [3a1aa20:0475e13] in mainline
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/uhci-hcd.ma
r3a1aa20 r0475e13 1 1 10 pci/ven=8086&dev=7020 2 2 10 pci/ven=8086&dev=7112 3 4 10 pci/ven=8086&dev=27c85 10 pci/ven=8086&dev=27c96 10 pci/ven=8086&dev=27ca7 10 pci/ven=8086&dev=27cb8 9 10 10 pci/ven=8086&dev=283011 10 pci/ven=8086&dev=283112 10 pci/ven=8086&dev=283213 10 pci/ven=8086&dev=283414 10 pci/ven=8086&dev=283515 16 10 pci/ven=8086&dev=293417 10 pci/ven=8086&dev=293518 10 pci/ven=8086&dev=293619 10 pci/ven=8086&dev=293720 10 pci/ven=8086&dev=293821 10 pci/ven=8086&dev=2939 -
uspace/drv/usbhub/main.c
r3a1aa20 r0475e13 34 34 #include <errno.h> 35 35 #include <async.h> 36 #include <stdio.h>37 36 38 37 #include "usbhub.h" … … 52 51 }; 53 52 53 int usb_hub_control_loop(void * noparam){ 54 while(true){ 55 usb_hub_check_hub_changes(); 56 async_usleep(1000 * 1000 );/// \TODO proper number once 57 } 58 return 0; 59 } 60 61 54 62 int main(int argc, char *argv[]) 55 63 { 56 64 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 57 dprintf(USB_LOG_LEVEL_INFO, "starting hub driver"); 58 59 //this is probably not needed anymore 65 60 66 fibril_mutex_initialize(&usb_hub_list_lock); 61 67 fibril_mutex_lock(&usb_hub_list_lock); 62 68 usb_lst_init(&usb_hub_list); 63 69 fibril_mutex_unlock(&usb_hub_list_lock); 64 70 71 fid_t fid = fibril_create(usb_hub_control_loop, NULL); 72 if (fid == 0) { 73 fprintf(stderr, NAME ": failed to start monitoring fibril," \ 74 " driver aborting.\n"); 75 return ENOMEM; 76 } 77 fibril_add_ready(fid); 78 65 79 return ddf_driver_main(&hub_driver); 66 80 } -
uspace/drv/usbhub/port_status.h
r3a1aa20 r0475e13 177 177 } 178 178 179 /**180 * set the device request to be a port disable request181 * @param request182 * @param port183 */184 static inline void usb_hub_unset_power_port_request(185 usb_device_request_setup_packet_t * request, uint16_t port186 ){187 request->index = port;188 request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;189 request->request = USB_HUB_REQUEST_CLEAR_FEATURE;190 request->value = USB_HUB_FEATURE_PORT_POWER;191 request->length = 0;192 }193 194 179 /** get i`th bit of port status */ 195 180 static inline bool usb_port_get_bit(usb_port_status_t * status, int idx) -
uspace/drv/usbhub/usbhub.c
r3a1aa20 r0475e13 44 44 #include <usb/request.h> 45 45 #include <usb/classes/hub.h> 46 #include <stdio.h>47 46 48 47 #include "usbhub.h" … … 57 56 }; 58 57 59 /** Hub status-change endpoint description 60 * 61 * For more see usb hub specification in 11.15.1 of 62 */ 58 /** Hub status-change endpoint description */ 63 59 static usb_endpoint_description_t status_change_endpoint_description = { 64 60 .transfer_type = USB_TRANSFER_INTERRUPT, 65 61 .direction = USB_DIRECTION_IN, 66 62 .interface_class = USB_CLASS_HUB, 67 .interface_subclass = 0,68 .interface_protocol = 0,69 63 .flags = 0 70 64 }; 71 72 int usb_hub_control_loop(void * hub_info_param){73 usb_hub_info_t * hub_info = (usb_hub_info_t*)hub_info_param;74 while(true){75 usb_hub_check_hub_changes(hub_info);76 async_usleep(1000 * 1000 );/// \TODO proper number once77 }78 return 0;79 }80 65 81 66 … … 150 135 151 136 //configuration descriptor 152 /// \TODO check other configurations ?137 /// \TODO check other configurations 153 138 usb_standard_configuration_descriptor_t config_descriptor; 154 139 opResult = usb_request_get_bare_configuration_descriptor( … … 194 179 } 195 180 181 /** 182 * Initialize the interrupt in endpoint. 183 * \TODO this code should be checked... 184 */ 196 185 usb_endpoint_mapping_t endpoint_mapping[1] = { 197 186 { … … 221 210 return EOK; 222 211 212 213 // Initialize the interrupt(=status change) endpoint. 214 /*usb_endpoint_pipe_initialize( 215 &result->endpoints->status_change, 216 &result->device_connection, );USB_TRANSFER_INTERRUPT 217 USB_DIRECTION_IN*/ 218 223 219 } 224 220 … … 271 267 } 272 268 269 273 270 dprintf(USB_LOG_LEVEL_INFO, "setting port count to %d",descriptor->ports_count); 274 271 result->port_count = descriptor->ports_count; … … 332 329 333 330 //add the hub to list 334 //is this needed now?335 331 fibril_mutex_lock(&usb_hub_list_lock); 336 332 usb_lst_append(&usb_hub_list, hub_info); 337 333 fibril_mutex_unlock(&usb_hub_list_lock); 334 338 335 dprintf(USB_LOG_LEVEL_DEBUG, "hub info added to list"); 339 340 dprintf(USB_LOG_LEVEL_DEBUG, "adding to ddf");341 ddf_fun_t *hub_fun = ddf_fun_create(dev, fun_exposed, "hub");342 assert(hub_fun != NULL);343 hub_fun->ops = NULL;344 345 int rc = ddf_fun_bind(hub_fun);346 assert(rc == EOK);347 rc = ddf_fun_add_to_class(hub_fun, "hub");348 assert(rc == EOK);349 350 fid_t fid = fibril_create(usb_hub_control_loop, hub_info);351 if (fid == 0) {352 dprintf(USB_LOG_LEVEL_ERROR,353 ": failed to start monitoring fibril for new hub");354 return ENOMEM;355 }356 fibril_add_ready(fid);357 358 dprintf(USB_LOG_LEVEL_DEBUG, "hub fibril created");359 336 //(void)hub_info; 360 //usb_hub_check_hub_changes();337 usb_hub_check_hub_changes(); 361 338 362 339 dprintf(USB_LOG_LEVEL_INFO, "hub dev added"); … … 391 368 //opResult = usb_drv_reserve_default_address(hc); 392 369 opResult = usb_hc_reserve_default_address(&hub->connection, USB_SPEED_LOW); 393 394 if (opResult != EOK) { 395 dprintf(USB_LOG_LEVEL_WARNING, 396 "cannot assign default address, it is probably used %d",opResult); 370 371 if (opResult != EOK) { 372 dprintf(USB_LOG_LEVEL_WARNING, "cannot assign default address, it is probably used"); 397 373 return; 398 374 } … … 405 381 ); 406 382 if (opResult != EOK) { 407 dprintf(USB_LOG_LEVEL_ERROR, 408 "something went wrong when reseting a port %d",opResult); 383 dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when reseting a port"); 409 384 //usb_hub_release_default_address(hc); 410 385 usb_hc_release_default_address(&hub->connection); … … 419 394 */ 420 395 static void usb_hub_finalize_add_device( usb_hub_info_t * hub, 421 uint16_t port , bool isLowSpeed) {396 uint16_t port) { 422 397 423 398 int opResult; … … 442 417 &new_device_connection); 443 418 /// \TODO get highspeed info 444 usb_speed_t speed = isLowSpeed?USB_SPEED_LOW:USB_SPEED_FULL; 419 420 421 445 422 446 423 … … 448 425 usb_address_t new_device_address = usb_hc_request_address( 449 426 &hub->connection, 450 speed/// \TODO fullspeed??427 USB_SPEED_LOW/// \TODO fullspeed?? 451 428 ); 452 429 if (new_device_address < 0) { … … 459 436 //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 460 437 // new_device_address); 461 usb_endpoint_pipe_start_session(&new_device_pipe);462 438 opResult = usb_request_set_address(&new_device_pipe,new_device_address); 463 usb_endpoint_pipe_end_session(&new_device_pipe); 464 if (opResult != EOK) { 465 dprintf(USB_LOG_LEVEL_ERROR, 466 "could not set address for new device %d",opResult); 439 440 if (opResult != EOK) { 441 dprintf(USB_LOG_LEVEL_ERROR, "could not set address for new device"); 467 442 usb_hc_release_default_address(&hub->connection); 468 443 return; … … 483 458 484 459 if (opResult != EOK) { 485 dprintf(USB_LOG_LEVEL_ERROR, 486 "could not start driver for new device %d",opResult); 460 dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device"); 487 461 return; 488 462 } … … 495 469 &hub->attached_devs[port]); 496 470 if (opResult != EOK) { 497 dprintf(USB_LOG_LEVEL_ERROR, 498 "could not assign address of device in hcd %d",opResult); 471 dprintf(USB_LOG_LEVEL_ERROR, "could not assign address of device in hcd"); 499 472 return; 500 473 } … … 538 511 } 539 512 540 541 /**542 *Process over current condition on port.543 *544 * Turn off the power on the port.545 *546 * @param hub547 * @param port548 */549 static void usb_hub_over_current( usb_hub_info_t * hub,550 uint16_t port){551 int opResult;552 opResult = usb_hub_clear_port_feature(&hub->endpoints.control,553 port, USB_HUB_FEATURE_PORT_POWER);554 if(opResult!=EOK){555 dprintf(USB_LOG_LEVEL_ERROR, "cannot power off port %d; %d",556 port, opResult);557 }558 }559 560 513 /** 561 514 * Process interrupts on given hub port … … 569 522 //determine type of change 570 523 usb_endpoint_pipe_t *pipe = &hub->endpoints.control; 524 int opResult = usb_endpoint_pipe_start_session(pipe); 571 525 572 int opResult; 526 if(opResult != EOK){ 527 dprintf(USB_LOG_LEVEL_ERROR, "cannot open pipe %d", opResult); 528 } 529 530 /* 531 usb_target_t target; 532 target.address=address; 533 target.endpoint=0; 534 */ 573 535 574 536 usb_port_status_t status; … … 585 547 ); 586 548 if (opResult != EOK) { 587 dprintf(USB_LOG_LEVEL_ERROR, " could not get port status");549 dprintf(USB_LOG_LEVEL_ERROR, "ERROR: could not get port status"); 588 550 return; 589 551 } 590 552 if (rcvd_size != sizeof (usb_port_status_t)) { 591 dprintf(USB_LOG_LEVEL_ERROR, " received status has incorrect size");553 dprintf(USB_LOG_LEVEL_ERROR, "ERROR: received status has incorrect size"); 592 554 return; 593 555 } … … 604 566 } 605 567 } 606 //over current607 if (usb_port_overcurrent_change(&status)) {608 //check if it was not auto-resolved609 if(usb_port_over_current(&status)){610 usb_hub_over_current(hub,port);611 }else{612 dprintf(USB_LOG_LEVEL_INFO,613 "over current condition was auto-resolved on port %d",port);614 }615 }616 568 //port reset 617 569 if (usb_port_reset_completed(&status)) { 618 570 dprintf(USB_LOG_LEVEL_INFO, "port reset complete"); 619 571 if (usb_port_enabled(&status)) { 620 usb_hub_finalize_add_device(hub, port , usb_port_low_speed(&status));572 usb_hub_finalize_add_device(hub, port); 621 573 } else { 622 dprintf(USB_LOG_LEVEL_WARNING, " port reset, but port still not enabled");574 dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled"); 623 575 } 624 576 } … … 633 585 } 634 586 /// \TODO handle other changes 635 } 636 637 /** 638 * Check changes on particular hub 639 * @param hub_info_param 640 */ 641 void usb_hub_check_hub_changes(usb_hub_info_t * hub_info){ 642 int opResult; 643 opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change); 644 if(opResult != EOK){ 645 dprintf(USB_LOG_LEVEL_ERROR, 646 "could not initialize communication for hub; %d", opResult); 647 return; 648 } 649 650 size_t port_count = hub_info->port_count; 651 652 /// FIXME: count properly 653 size_t byte_length = ((port_count+1) / 8) + 1; 587 /// \TODO debug log for various situations 588 usb_endpoint_pipe_end_session(pipe); 589 590 591 } 592 593 /** 594 * Check changes on all known hubs. 595 */ 596 void usb_hub_check_hub_changes(void) { 597 /* 598 * Iterate through all hubs. 599 */ 600 usb_general_list_t * lst_item; 601 fibril_mutex_lock(&usb_hub_list_lock); 602 for (lst_item = usb_hub_list.next; 603 lst_item != &usb_hub_list; 604 lst_item = lst_item->next) { 605 fibril_mutex_unlock(&usb_hub_list_lock); 606 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data); 607 int opResult; 608 609 opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change); 610 if(opResult != EOK){ 611 continue; 612 } 613 /* 614 * Check status change pipe of this hub. 615 */ 616 /* 617 usb_target_t target; 618 target.address = hub_info->address; 619 target.endpoint = 1;/// \TODO get from endpoint descriptor 620 dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d", 621 target.address); 622 */ 623 size_t port_count = hub_info->port_count; 624 625 /* 626 * Connect to respective HC. 627 * 628 int hc = usb_drv_hc_connect_auto(hub_info->device, 0); 629 if (hc < 0) { 630 continue; 631 }*/ 632 633 /// FIXME: count properly 634 size_t byte_length = ((port_count+1) / 8) + 1; 635 654 636 void *change_bitmap = malloc(byte_length); 655 size_t actual_size; 656 657 /* 658 * Send the request. 659 */ 660 opResult = usb_endpoint_pipe_read( 661 &hub_info->endpoints.status_change, 662 change_bitmap, byte_length, &actual_size 663 ); 664 665 if (opResult != EOK) { 637 size_t actual_size; 638 //usb_handle_t handle; 639 640 /* 641 * Send the request. 642 */ 643 opResult = usb_endpoint_pipe_read( 644 &hub_info->endpoints.status_change, 645 change_bitmap, byte_length, &actual_size 646 ); 647 648 //usb_drv_async_wait_for(handle); 649 650 if (opResult != EOK) { 651 free(change_bitmap); 652 dprintf(USB_LOG_LEVEL_WARNING, "something went wrong while getting status of hub"); 653 continue; 654 } 655 unsigned int port; 656 for (port = 1; port < port_count+1; ++port) { 657 bool interrupt = 658 (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2; 659 if (interrupt) { 660 usb_hub_process_interrupt( 661 hub_info, port); 662 } 663 } 664 usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change); 666 665 free(change_bitmap); 667 dprintf(USB_LOG_LEVEL_WARNING, "something went wrong while getting status of hub"); 668 usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change); 669 return; 670 } 671 unsigned int port; 672 opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.control); 673 if(opResult!=EOK){ 674 dprintf(USB_LOG_LEVEL_ERROR, "could not start control pipe session %d", 675 opResult); 676 usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change); 677 return; 678 } 679 opResult = usb_hc_connection_open(&hub_info->connection); 680 if(opResult!=EOK){ 681 dprintf(USB_LOG_LEVEL_ERROR, "could not start host controller session %d", 682 opResult); 683 usb_endpoint_pipe_end_session(&hub_info->endpoints.control); 684 usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change); 685 return; 686 } 687 688 ///todo, opresult check, pre obe konekce 689 for (port = 1; port < port_count+1; ++port) { 690 bool interrupt = 691 (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2; 692 if (interrupt) { 693 usb_hub_process_interrupt( 694 hub_info, port); 695 } 696 } 697 usb_hc_connection_close(&hub_info->connection); 698 usb_endpoint_pipe_end_session(&hub_info->endpoints.control); 699 usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change); 700 free(change_bitmap); 701 } 666 667 668 //async_hangup(hc); 669 fibril_mutex_lock(&usb_hub_list_lock); 670 } 671 fibril_mutex_unlock(&usb_hub_list_lock); 672 } 673 674 702 675 703 676 -
uspace/drv/usbhub/usbhub.h
r3a1aa20 r0475e13 75 75 /** 76 76 * function running the hub-controlling loop. 77 * @param hub_info_param hub info pointer77 * @param noparam fundtion does not need any parameters 78 78 */ 79 int usb_hub_control_loop(void * hub_info_param);79 int usb_hub_control_loop(void * noparam); 80 80 81 81 /** Callback when new hub device is detected. … … 87 87 88 88 /** 89 * check changes on specified hub 90 * @param hub_info_param pointer to usb_hub_info_t structure 89 * check changes on all registered hubs 91 90 */ 92 void usb_hub_check_hub_changes( usb_hub_info_t * hub_info_param);91 void usb_hub_check_hub_changes(void); 93 92 94 93 94 //int usb_add_hub_device(device_t *); 95 95 96 96 -
uspace/drv/usbhub/usbhub_private.h
r3a1aa20 r0475e13 162 162 } 163 163 164 /**165 * @brief create uint8_t array with serialized descriptor166 *167 * @param descriptor168 * @return newly created serializd descriptor pointer169 */170 void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);171 172 /**173 * @brief create deserialized desriptor structure out of serialized descriptor174 *175 * The serialized descriptor must be proper usb hub descriptor,176 * otherwise an eerror might occur.177 *178 * @param sdescriptor serialized descriptor179 * @return newly created deserialized descriptor pointer180 */181 usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);182 164 183 165 -
uspace/lib/usb/include/usb/classes/hub.h
r3a1aa20 r0475e13 196 196 extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE; 197 197 198 /** 199 * @brief create uint8_t array with serialized descriptor 200 * 201 * @param descriptor 202 */ 203 void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor); 204 205 /** 206 * @brief create deserialized desriptor structure out of serialized descriptor 207 * 208 * The serialized descriptor must be proper usb hub descriptor, otherwise an eerror might occur. 209 * 210 * @param sdescriptor serialized descriptor 211 */ 212 usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor); 198 213 199 214
Note:
See TracChangeset
for help on using the changeset viewer.