Changes in uspace/drv/usbhub/usbhub.c [15b0432:563fb40] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r15b0432 r563fb40 39 39 40 40 #include <usb_iface.h> 41 #include <usb/ ddfiface.h>41 #include <usb/usbdrv.h> 42 42 #include <usb/descriptor.h> 43 43 #include <usb/recognise.h> 44 #include <usb/ request.h>44 #include <usb/devreq.h> 45 45 #include <usb/classes/hub.h> 46 46 … … 49 49 #include "port_status.h" 50 50 #include "usb/usb.h" 51 #include "usb/pipes.h" 52 #include "usb/classes/classes.h" 51 52 static int iface_get_hc_handle(device_t *device, devman_handle_t *handle) 53 { 54 return usb_hc_find(device->handle, handle); 55 } 56 57 static usb_iface_t hub_usb_iface = { 58 .get_hc_handle = iface_get_hc_handle 59 }; 53 60 54 61 static device_ops_t hub_device_ops = { 55 .interfaces[USB_DEV_IFACE] = & usb_iface_hub_impl62 .interfaces[USB_DEV_IFACE] = &hub_usb_iface 56 63 }; 57 58 /** Hub status-change endpoint description */59 static usb_endpoint_description_t status_change_endpoint_description = {60 .transfer_type = USB_TRANSFER_INTERRUPT,61 .direction = USB_DIRECTION_IN,62 .interface_class = USB_CLASS_HUB,63 .flags = 064 };65 66 64 67 65 //********************************************* … … 71 69 //********************************************* 72 70 73 /** 74 * Initialize connnections to host controller, device, and device 75 * control endpoint 76 * @param hub 77 * @param device 78 * @return 79 */ 80 static int usb_hub_init_communication(usb_hub_info_t * hub){ 81 int opResult; 82 opResult = usb_device_connection_initialize_from_device( 83 &hub->device_connection, 84 hub->device); 85 if(opResult != EOK){ 86 dprintf(USB_LOG_LEVEL_ERROR, 87 "could not initialize connection to hc, errno %d",opResult); 88 return opResult; 89 } 90 opResult = usb_hc_connection_initialize_from_device(&hub->connection, 91 hub->device); 92 if(opResult != EOK){ 93 dprintf(USB_LOG_LEVEL_ERROR, 94 "could not initialize connection to device, errno %d",opResult); 95 return opResult; 96 } 97 opResult = usb_endpoint_pipe_initialize_default_control(&hub->endpoints.control, 98 &hub->device_connection); 99 if(opResult != EOK){ 100 dprintf(USB_LOG_LEVEL_ERROR, 101 "could not initialize connection to device endpoint, errno %d",opResult); 102 } 103 return opResult; 104 } 105 106 /** 107 * When entering this function, hub->endpoints.control should be active. 108 * @param hub 109 * @return 110 */ 111 static int usb_hub_process_configuration_descriptors( 112 usb_hub_info_t * hub){ 113 if(hub==NULL) { 114 return EINVAL; 115 } 116 int opResult; 117 118 //device descriptor 119 usb_standard_device_descriptor_t std_descriptor; 120 opResult = usb_request_get_device_descriptor(&hub->endpoints.control, 121 &std_descriptor); 122 if(opResult!=EOK){ 123 dprintf(USB_LOG_LEVEL_ERROR, "could not get device descriptor, %d",opResult); 124 return opResult; 125 } 126 dprintf(USB_LOG_LEVEL_INFO, "hub has %d configurations", 127 std_descriptor.configuration_count); 128 if(std_descriptor.configuration_count<1){ 129 dprintf(USB_LOG_LEVEL_ERROR, "THERE ARE NO CONFIGURATIONS AVAILABLE"); 130 //shouldn`t I return? 131 } 132 133 //configuration descriptor 134 /// \TODO check other configurations 135 usb_standard_configuration_descriptor_t config_descriptor; 136 opResult = usb_request_get_bare_configuration_descriptor( 137 &hub->endpoints.control, 0, 138 &config_descriptor); 139 if(opResult!=EOK){ 140 dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult); 141 return opResult; 142 } 143 //set configuration 144 opResult = usb_request_set_configuration(&hub->endpoints.control, 145 config_descriptor.configuration_number); 146 147 if (opResult != EOK) { 148 dprintf(USB_LOG_LEVEL_ERROR, 149 "something went wrong when setting hub`s configuration, %d", 150 opResult); 151 return opResult; 152 } 153 dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d", 154 config_descriptor.configuration_number); 155 156 //full configuration descriptor 157 size_t transferred = 0; 158 uint8_t * descriptors = (uint8_t *)malloc(config_descriptor.total_length); 159 if (descriptors == NULL) { 160 dprintf(USB_LOG_LEVEL_ERROR, "insufficient memory"); 161 return ENOMEM; 162 } 163 opResult = usb_request_get_full_configuration_descriptor(&hub->endpoints.control, 164 0, descriptors, 165 config_descriptor.total_length, &transferred); 166 if(opResult!=EOK){ 167 free(descriptors); 168 dprintf(USB_LOG_LEVEL_ERROR, 169 "could not get full configuration descriptor, %d",opResult); 170 return opResult; 171 } 172 if (transferred != config_descriptor.total_length) { 173 dprintf(USB_LOG_LEVEL_ERROR, 174 "received incorrect full configuration descriptor"); 175 return ELIMIT; 176 } 177 178 /** 179 * Initialize the interrupt in endpoint. 180 * \TODO this code should be checked... 181 */ 182 usb_endpoint_mapping_t endpoint_mapping[1] = { 183 { 184 .pipe = &hub->endpoints.status_change, 185 .description = &status_change_endpoint_description, 186 .interface_no = 187 usb_device_get_assigned_interface(hub->device) 188 } 189 }; 190 opResult = usb_endpoint_pipe_initialize_from_configuration( 191 endpoint_mapping, 1, 192 descriptors, config_descriptor.total_length, 193 &hub->device_connection); 194 if (opResult != EOK) { 195 dprintf(USB_LOG_LEVEL_ERROR, 196 "Failed to initialize status change pipe: %s", 197 str_error(opResult)); 198 return opResult; 199 } 200 if (!endpoint_mapping[0].present) { 201 dprintf(USB_LOG_LEVEL_ERROR,"Not accepting device, " \ 202 "cannot understand what is happenning"); 203 return EREFUSED; 204 } 205 206 free(descriptors); 207 return EOK; 208 209 210 // Initialize the interrupt(=status change) endpoint. 211 /*usb_endpoint_pipe_initialize( 212 &result->endpoints->status_change, 213 &result->device_connection, );USB_TRANSFER_INTERRUPT 214 USB_DIRECTION_IN*/ 215 216 } 217 218 219 /** 220 * Create hub representation from device information. 221 * @param device 222 * @return pointer to created structure or NULL in case of error 223 */ 224 usb_hub_info_t * usb_create_hub_info(device_t * device) { 71 usb_hub_info_t * usb_create_hub_info(device_t * device, int hc) { 225 72 usb_hub_info_t* result = usb_new(usb_hub_info_t); 226 result->device = device;227 int opResult;228 opResult = usb_hub_init_communication(result);229 if(opResult != EOK){230 free(result);231 return NULL;232 }233 234 73 //result->device = device; 235 74 result->port_count = -1; 75 /// \TODO is this correct? is the device stored? 236 76 result->device = device; 237 77 238 //result->usb_device = usb_new(usb_hcd_attached_device_info_t); 239 size_t received_size; 78 79 dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc); 80 if (hc < 0) { 81 return result; 82 } 83 //get some hub info 84 usb_address_t addr = usb_drv_get_my_address(hc, device); 85 dprintf(USB_LOG_LEVEL_DEBUG, "address of newly created hub = %d", addr); 86 /*if(addr<0){ 87 //return result; 88 89 }*/ 90 91 result->address = addr; 240 92 241 93 // get hub descriptor 94 242 95 dprintf(USB_LOG_LEVEL_DEBUG, "creating serialized descripton"); 243 96 void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE); 244 97 usb_hub_descriptor_t * descriptor; 98 size_t received_size; 99 int opResult; 245 100 dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction"); 246 usb_endpoint_pipe_start_session(&result->endpoints.control);247 opResult = usb_ request_get_descriptor(&result->endpoints.control,101 102 opResult = usb_drv_req_get_descriptor(hc, addr, 248 103 USB_REQUEST_TYPE_CLASS, 249 104 USB_DESCTYPE_HUB, 0, 0, serialized_descriptor, 250 105 USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size); 251 usb_endpoint_pipe_end_session(&result->endpoints.control);252 106 253 107 if (opResult != EOK) { … … 263 117 return result; 264 118 } 265 266 267 119 dprintf(USB_LOG_LEVEL_INFO, "setting port count to %d",descriptor->ports_count); 268 120 result->port_count = descriptor->ports_count; 269 result->attached_devs = (usb_h c_attached_device_t*)270 malloc((result->port_count+1) * sizeof(usb_h c_attached_device_t));121 result->attached_devs = (usb_hub_attached_device_t*) 122 malloc((result->port_count+1) * sizeof(usb_hub_attached_device_t)); 271 123 int i; 272 124 for(i=0;i<result->port_count+1;++i){ 273 result->attached_devs[i]. handle=0;125 result->attached_devs[i].devman_handle=0; 274 126 result->attached_devs[i].address=0; 275 127 } … … 286 138 } 287 139 288 /**289 * Create hub representation and add it into hub list290 * @param dev291 * @return292 */293 140 int usb_add_hub_device(device_t *dev) { 294 141 dprintf(USB_LOG_LEVEL_INFO, "add_hub_device(handle=%d)", (int) dev->handle); 295 142 143 /* 144 * We are some (probably deeply nested) hub. 145 * Thus, assign our own operations and explore already 146 * connected devices. 147 */ 296 148 dev->ops = &hub_device_ops; 297 149 298 usb_hub_info_t * hub_info = usb_create_hub_info(dev); 299 300 int opResult; 301 302 //perform final configurations 303 usb_endpoint_pipe_start_session(&hub_info->endpoints.control); 304 // process descriptors 305 opResult = usb_hub_process_configuration_descriptors(hub_info); 306 if(opResult != EOK){ 307 dprintf(USB_LOG_LEVEL_ERROR,"could not get condiguration descriptors, %d", 308 opResult); 150 //create the hub structure 151 //get hc connection 152 int hc = usb_drv_hc_connect_auto(dev, 0); 153 if (hc < 0) { 154 return hc; 155 } 156 157 usb_hub_info_t * hub_info = usb_create_hub_info(dev, hc); 158 int port; 159 int opResult; 160 usb_target_t target; 161 target.address = hub_info->address; 162 target.endpoint = 0; 163 164 //get configuration descriptor 165 // this is not fully correct - there are more configurations 166 // and all should be checked 167 usb_standard_device_descriptor_t std_descriptor; 168 opResult = usb_drv_req_get_device_descriptor(hc, target.address, 169 &std_descriptor); 170 if(opResult!=EOK){ 171 dprintf(USB_LOG_LEVEL_ERROR, "could not get device descriptor, %d",opResult); 309 172 return opResult; 310 173 } 311 //power ports 174 dprintf(USB_LOG_LEVEL_INFO, "hub has %d configurations",std_descriptor.configuration_count); 175 if(std_descriptor.configuration_count<1){ 176 dprintf(USB_LOG_LEVEL_ERROR, "THERE ARE NO CONFIGURATIONS AVAILABLE"); 177 //shouldn`t I return? 178 } 179 /// \TODO check other configurations 180 usb_standard_configuration_descriptor_t config_descriptor; 181 opResult = usb_drv_req_get_bare_configuration_descriptor(hc, 182 target.address, 0, 183 &config_descriptor); 184 if(opResult!=EOK){ 185 dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult); 186 return opResult; 187 } 188 //set configuration 189 opResult = usb_drv_req_set_configuration(hc, target.address, 190 config_descriptor.configuration_number); 191 192 if (opResult != EOK) { 193 dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when setting hub`s configuration, %d", opResult); 194 } 195 312 196 usb_device_request_setup_packet_t request; 313 int port;314 197 for (port = 1; port < hub_info->port_count+1; ++port) { 315 198 usb_hub_set_power_port_request(&request, port); 316 opResult = usb_endpoint_pipe_control_write(&hub_info->endpoints.control, 317 &request,sizeof(usb_device_request_setup_packet_t), NULL, 0); 199 opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0); 318 200 dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port); 319 201 if (opResult != EOK) { … … 322 204 } 323 205 //ports powered, hub seems to be enabled 324 usb_endpoint_pipe_end_session(&hub_info->endpoints.control); 206 207 async_hangup(hc); 325 208 326 209 //add the hub to list … … 332 215 //(void)hub_info; 333 216 usb_hub_check_hub_changes(); 217 334 218 219 335 220 dprintf(USB_LOG_LEVEL_INFO, "hub dev added"); 336 //address is lost...337 221 dprintf(USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ", 338 //hub_info->endpoints.control.,222 hub_info->address, 339 223 hub_info->port_count); 224 dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",config_descriptor.configuration_number); 340 225 341 226 return EOK; … … 351 236 352 237 /** 238 * Convenience function for releasing default address and writing debug info 239 * (these few lines are used too often to be written again and again). 240 * @param hc 241 * @return 242 */ 243 inline static int usb_hub_release_default_address(int hc){ 244 int opResult; 245 dprintf(USB_LOG_LEVEL_INFO, "releasing default address"); 246 opResult = usb_drv_release_default_address(hc); 247 if (opResult != EOK) { 248 dprintf(USB_LOG_LEVEL_WARNING, "failed to release default address"); 249 } 250 return opResult; 251 } 252 253 /** 353 254 * Reset the port with new device and reserve the default address. 354 255 * @param hc … … 356 257 * @param target 357 258 */ 358 static void usb_hub_init_add_device( usb_hub_info_t * hub, uint16_t port) {259 static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) { 359 260 usb_device_request_setup_packet_t request; 360 261 int opResult; 361 262 dprintf(USB_LOG_LEVEL_INFO, "some connection changed"); 362 assert(hub->endpoints.control.hc_phone);363 263 //get default address 364 //opResult = usb_drv_reserve_default_address(hc); 365 opResult = usb_hc_reserve_default_address(&hub->connection, USB_SPEED_LOW); 366 264 opResult = usb_drv_reserve_default_address(hc); 367 265 if (opResult != EOK) { 368 266 dprintf(USB_LOG_LEVEL_WARNING, "cannot assign default address, it is probably used"); … … 371 269 //reset port 372 270 usb_hub_set_reset_port_request(&request, port); 373 opResult = usb_ endpoint_pipe_control_write(374 &hub->endpoints.control,375 &request, sizeof(usb_device_request_setup_packet_t),271 opResult = usb_drv_sync_control_write( 272 hc, target, 273 &request, 376 274 NULL, 0 377 275 ); 378 276 if (opResult != EOK) { 379 277 dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when reseting a port"); 380 //usb_hub_release_default_address(hc); 381 usb_hc_release_default_address(&hub->connection); 278 usb_hub_release_default_address(hc); 382 279 } 383 280 } … … 390 287 */ 391 288 static void usb_hub_finalize_add_device( usb_hub_info_t * hub, 392 uint16_t port) {289 int hc, uint16_t port, usb_target_t target) { 393 290 394 291 int opResult; 395 292 dprintf(USB_LOG_LEVEL_INFO, "finalizing add device"); 396 opResult = usb_hub_clear_port_feature( &hub->endpoints.control,293 opResult = usb_hub_clear_port_feature(hc, target.address, 397 294 port, USB_HUB_FEATURE_C_PORT_RESET); 398 399 295 if (opResult != EOK) { 400 296 dprintf(USB_LOG_LEVEL_ERROR, "failed to clear port reset feature"); 401 usb_hc_release_default_address(&hub->connection); 402 return; 403 } 404 //create connection to device 405 usb_endpoint_pipe_t new_device_pipe; 406 usb_device_connection_t new_device_connection; 407 usb_device_connection_initialize_on_default_address( 408 &new_device_connection, 409 &hub->connection 410 ); 411 usb_endpoint_pipe_initialize_default_control( 412 &new_device_pipe, 413 &new_device_connection); 414 /// \TODO get highspeed info 415 416 417 418 419 420 /* Request address from host controller. */ 421 usb_address_t new_device_address = usb_hc_request_address( 422 &hub->connection, 423 USB_SPEED_LOW/// \TODO fullspeed?? 424 ); 297 usb_hub_release_default_address(hc); 298 return; 299 } 300 301 /* Request address at from host controller. */ 302 usb_address_t new_device_address = usb_drv_request_address(hc); 425 303 if (new_device_address < 0) { 426 304 dprintf(USB_LOG_LEVEL_ERROR, "failed to get free USB address"); 427 305 opResult = new_device_address; 428 usb_h c_release_default_address(&hub->connection);306 usb_hub_release_default_address(hc); 429 307 return; 430 308 } 431 309 dprintf(USB_LOG_LEVEL_INFO, "setting new address %d",new_device_address); 432 //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 433 // new_device_address); 434 opResult = usb_request_set_address(&new_device_pipe,new_device_address); 310 opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 311 new_device_address); 435 312 436 313 if (opResult != EOK) { 437 314 dprintf(USB_LOG_LEVEL_ERROR, "could not set address for new device"); 438 usb_hc_release_default_address(&hub->connection); 439 return; 440 } 441 442 443 //opResult = usb_hub_release_default_address(hc); 444 opResult = usb_hc_release_default_address(&hub->connection); 315 usb_hub_release_default_address(hc); 316 return; 317 } 318 319 320 opResult = usb_hub_release_default_address(hc); 445 321 if(opResult!=EOK){ 446 322 return; 447 323 } 448 324 325 devman_handle_t hc_handle; 326 opResult = usb_drv_find_hc(hub->device, &hc_handle); 327 if (opResult != EOK) { 328 usb_log_error("Failed to get handle of host controller: %s.\n", 329 str_error(opResult)); 330 return; 331 } 332 449 333 devman_handle_t child_handle; 450 //?? 451 opResult = usb_device_register_child_in_devman(new_device_address, 452 hub->connection.hc_handle, hub->device, &child_handle); 453 334 opResult = usb_device_register_child_in_devman(new_device_address, 335 hc_handle, hub->device, &child_handle); 454 336 if (opResult != EOK) { 455 337 dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device"); 456 338 return; 457 339 } 458 hub->attached_devs[port]. handle = child_handle;340 hub->attached_devs[port].devman_handle = child_handle; 459 341 hub->attached_devs[port].address = new_device_address; 460 342 461 //opResult = usb_drv_bind_address(hc, new_device_address, child_handle); 462 opResult = usb_hc_register_device( 463 &hub->connection, 464 &hub->attached_devs[port]); 343 opResult = usb_drv_bind_address(hc, new_device_address, child_handle); 465 344 if (opResult != EOK) { 466 345 dprintf(USB_LOG_LEVEL_ERROR, "could not assign address of device in hcd"); … … 479 358 */ 480 359 static void usb_hub_removed_device( 481 usb_hub_info_t * hub, uint16_t port) {360 usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) { 482 361 //usb_device_request_setup_packet_t request; 483 362 int opResult; … … 486 365 * devide manager 487 366 */ 488 367 368 hub->attached_devs[port].devman_handle=0; 489 369 //close address 490 370 if(hub->attached_devs[port].address!=0){ 491 //opResult = usb_drv_release_address(hc,hub->attached_devs[port].address); 492 opResult = usb_hc_unregister_device( 493 &hub->connection, hub->attached_devs[port].address); 371 opResult = usb_drv_release_address(hc,hub->attached_devs[port].address); 494 372 if(opResult != EOK) { 495 373 dprintf(USB_LOG_LEVEL_WARNING, "could not release address of " \ … … 497 375 } 498 376 hub->attached_devs[port].address = 0; 499 hub->attached_devs[port].handle = 0;500 377 }else{ 501 378 dprintf(USB_LOG_LEVEL_WARNING, "this is strange, disconnected device had no address"); 502 379 //device was disconnected before it`s port was reset - return default address 503 //usb_drv_release_default_address(hc); 504 usb_hc_release_default_address(&hub->connection); 380 usb_drv_release_default_address(hc); 505 381 } 506 382 } … … 512 388 * @param target 513 389 */ 514 static void usb_hub_process_interrupt(usb_hub_info_t * hub, 515 uint16_t port ) {390 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc, 391 uint16_t port, usb_address_t address) { 516 392 dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port); 517 393 //determine type of change 518 usb_endpoint_pipe_t *pipe = &hub->endpoints.control;519 int opResult = usb_endpoint_pipe_start_session(pipe);520 521 if(opResult != EOK){522 dprintf(USB_LOG_LEVEL_ERROR, "cannot open pipe %d", opResult);523 }524 525 /*526 394 usb_target_t target; 527 395 target.address=address; 528 396 target.endpoint=0; 529 */530 531 397 usb_port_status_t status; 532 398 size_t rcvd_size; 533 399 usb_device_request_setup_packet_t request; 534 //int opResult;400 int opResult; 535 401 usb_hub_set_port_status_request(&request, port); 536 402 //endpoint 0 537 403 538 opResult = usb_ endpoint_pipe_control_read(539 pipe,540 &request, sizeof(usb_device_request_setup_packet_t),404 opResult = usb_drv_sync_control_read( 405 hc, target, 406 &request, 541 407 &status, 4, &rcvd_size 542 408 ); … … 551 417 //something connected/disconnected 552 418 if (usb_port_connect_change(&status)) { 553 opResult = usb_hub_clear_port_feature( pipe,419 opResult = usb_hub_clear_port_feature(hc, target.address, 554 420 port, USB_HUB_FEATURE_C_PORT_CONNECTION); 555 421 // TODO: check opResult 556 422 if (usb_port_dev_connected(&status)) { 557 423 dprintf(USB_LOG_LEVEL_INFO, "some connection changed"); 558 usb_hub_init_add_device(h ub, port);424 usb_hub_init_add_device(hc, port, target); 559 425 } else { 560 usb_hub_removed_device(hub, port);426 usb_hub_removed_device(hub, hc, port, target); 561 427 } 562 428 } … … 565 431 dprintf(USB_LOG_LEVEL_INFO, "port reset complete"); 566 432 if (usb_port_enabled(&status)) { 567 usb_hub_finalize_add_device(hub, port);433 usb_hub_finalize_add_device(hub, hc, port, target); 568 434 } else { 569 435 dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled"); … … 581 447 /// \TODO handle other changes 582 448 /// \TODO debug log for various situations 583 usb_endpoint_pipe_end_session(pipe);584 585 449 586 450 } … … 600 464 fibril_mutex_unlock(&usb_hub_list_lock); 601 465 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data); 602 int opResult;603 604 opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change);605 if(opResult != EOK){606 continue;607 }608 466 /* 609 467 * Check status change pipe of this hub. 610 468 */ 611 /* 469 612 470 usb_target_t target; 613 471 target.address = hub_info->address; … … 615 473 dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d", 616 474 target.address); 617 */ 475 618 476 size_t port_count = hub_info->port_count; 619 477 620 478 /* 621 479 * Connect to respective HC. 622 * 480 */ 623 481 int hc = usb_drv_hc_connect_auto(hub_info->device, 0); 624 482 if (hc < 0) { 625 483 continue; 626 } */484 } 627 485 628 486 /// FIXME: count properly … … 631 489 void *change_bitmap = malloc(byte_length); 632 490 size_t actual_size; 633 //usb_handle_t handle;491 usb_handle_t handle; 634 492 635 493 /* 636 494 * Send the request. 637 495 */ 638 opResult = usb_endpoint_pipe_read( 639 &hub_info->endpoints.status_change, 640 change_bitmap, byte_length, &actual_size 641 ); 642 643 //usb_drv_async_wait_for(handle); 496 int opResult = usb_drv_async_interrupt_in(hc, target, 497 change_bitmap, byte_length, &actual_size, 498 &handle); 499 500 usb_drv_async_wait_for(handle); 644 501 645 502 if (opResult != EOK) { … … 654 511 if (interrupt) { 655 512 usb_hub_process_interrupt( 656 hub_info, port);513 hub_info, hc, port, hub_info->address); 657 514 } 658 515 } 659 usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);660 516 free(change_bitmap); 661 662 663 //async_hangup(hc); 517 518 async_hangup(hc); 664 519 fibril_mutex_lock(&usb_hub_list_lock); 665 520 }
Note:
See TracChangeset
for help on using the changeset viewer.