Changeset 578a2547 in mainline
- Timestamp:
- 2011-04-07T12:01:05Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3eaa5a5
- Parents:
- 9f9b31ad
- Location:
- uspace/drv/usbhub
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/Makefile
r9f9b31ad r578a2547 34 34 SOURCES = \ 35 35 main.c \ 36 ports.c \ 36 37 utils.c \ 37 38 usbhub.c \ -
uspace/drv/usbhub/usbhub.c
r9f9b31ad r578a2547 54 54 55 55 56 static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,57 usb_speed_t speed);56 //static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port, 57 // usb_speed_t speed); 58 58 59 59 static int usb_hub_trigger_connecting_non_removable_devices( 60 60 usb_hub_info_t * hub, usb_hub_descriptor_t * descriptor); 61 61 62 #if 0 62 63 /** 63 64 * control loop running in hub`s fibril … … 81 82 return 0; 82 83 } 84 #endif 83 85 84 86 … … 152 154 usb_log_debug("setting port count to %d\n",descriptor->ports_count); 153 155 hub_info->port_count = descriptor->ports_count; 154 hub_info->attached_devs = (usb_hc_attached_device_t*) 155 malloc((hub_info->port_count+1) * sizeof(usb_hc_attached_device_t)); 156 int i; 157 for(i=0;i<hub_info->port_count+1;++i){ 158 hub_info->attached_devs[i].handle=0; 159 hub_info->attached_devs[i].address=0; 156 hub_info->ports = malloc(sizeof(usb_hub_port_t) * (hub_info->port_count+1)); 157 size_t port; 158 for (port = 0; port < hub_info->port_count + 1; port++) { 159 usb_hub_port_init(&hub_info->ports[port]); 160 160 } 161 161 //handle non-removable devices … … 259 259 assert(rc == EOK); 260 260 261 //create fibril for the hub control loop 262 fid_t fid = fibril_create(usb_hub_control_loop, hub_info); 263 if (fid == 0) { 264 usb_log_error("failed to start monitoring fibril for new hub.\n"); 265 return ENOMEM; 266 } 267 fibril_add_ready(fid); 268 usb_log_debug("Hub fibril created.\n"); 261 /* 262 * The processing will require opened control pipe and connection 263 * to the host controller. 264 * It is waste of resources but let's hope there will be less 265 * hubs than the phone limit. 266 * FIXME: with some proper locking over pipes and session 267 * auto destruction, this could work better. 268 */ 269 rc = usb_pipe_start_session(&usb_dev->ctrl_pipe); 270 if (rc != EOK) { 271 usb_log_error("Failed to start session on control pipe: %s.\n", 272 str_error(rc)); 273 goto leave; 274 } 275 rc = usb_hc_connection_open(&hub_info->connection); 276 if (rc != EOK) { 277 usb_pipe_end_session(&usb_dev->ctrl_pipe); 278 usb_log_error("Failed to open connection to HC: %s.\n", 279 str_error(rc)); 280 goto leave; 281 } 282 283 rc = usb_device_auto_poll(hub_info->usb_device, 0, 284 hub_port_changes_callback, ((hub_info->port_count+1) / 8) + 1, 285 NULL, hub_info); 286 if (rc != EOK) { 287 usb_log_error("Failed to create polling fibril: %s.\n", 288 str_error(rc)); 289 free(hub_info); 290 return rc; 291 } 269 292 270 293 usb_log_info("Controlling hub `%s' (%d ports).\n", 271 294 hub_info->usb_device->ddf_dev->name, hub_info->port_count); 272 295 return EOK; 296 297 leave: 298 free(hub_info); 299 300 return rc; 273 301 } 274 302 … … 399 427 } 400 428 429 #if 0 401 430 /** 402 431 * Reset the port with new device and reserve the default address. … … 440 469 return; 441 470 } 442 471 #endif 472 473 #if 0 443 474 /** 444 475 * Finalize adding new device after port reset … … 529 560 new_device_address, child_handle); 530 561 } 562 #endif 531 563 532 564 /** … … 539 571 * @param port port number, starting from 1 540 572 */ 541 staticvoid usb_hub_removed_device(573 void usb_hub_removed_device( 542 574 usb_hub_info_t * hub,uint16_t port) { 543 575 … … 552 584 553 585 //close address 554 if(hub-> attached_devs[port].address!=0){586 if(hub->ports[port].attached_device.address >= 0){ 555 587 /*uncomment this code to use it when DDF allows device removal 556 588 opResult = usb_hc_unregister_device( … … 579 611 * @param port port number, starting from 1 580 612 */ 581 staticvoid usb_hub_over_current( usb_hub_info_t * hub,613 void usb_hub_over_current( usb_hub_info_t * hub, 582 614 uint16_t port){ 583 615 int opResult; … … 590 622 } 591 623 624 #if 0 592 625 /** 593 626 * Process interrupts on given hub port … … 737 770 return EOK; 738 771 } 739 772 #endif 740 773 741 774 -
uspace/drv/usbhub/usbhub.h
r9f9b31ad r578a2547 47 47 #include <usb/devdrv.h> 48 48 49 #include "ports.h" 50 51 49 52 50 53 /** Information about attached hub. */ 51 54 typedef struct { 52 55 /** Number of ports. */ 53 int port_count;56 size_t port_count; 54 57 55 /** attached device handles, for each port one*/56 usb_h c_attached_device_t * attached_devs;58 /** Ports. */ 59 usb_hub_port_t *ports; 57 60 58 61 /** connection to hcd */ … … 100 103 int usb_hub_check_hub_changes(usb_hub_info_t * hub_info_param); 101 104 105 void usb_hub_removed_device(usb_hub_info_t *, uint16_t); 106 void usb_hub_over_current(usb_hub_info_t *, uint16_t); 102 107 103 108 int usb_hub_add_device(usb_device_t * usb_dev);
Note:
See TracChangeset
for help on using the changeset viewer.