Changeset 6bb83c7 in mainline
- Timestamp:
- 2011-02-20T21:33:03Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 070f11e, 62066b4
- Parents:
- 50ba203
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r50ba203 r6bb83c7 68 68 usb_hub_info_t * usb_create_hub_info(device_t * device) { 69 69 usb_hub_info_t* result = usb_new(usb_hub_info_t); 70 usb_device_connection_initialize_from_device(&result->connection, device); 70 usb_device_connection_initialize_from_device(&result->device_connection, 71 device); 72 usb_hc_connection_initialize_from_device(&result->connection, 73 device); 71 74 usb_endpoint_pipe_initialize_default_control(&result->endpoints.control, 72 &result-> connection);75 &result->device_connection); 73 76 74 77 … … 78 81 result->device = device; 79 82 80 <<<<<<< TREE 81 result->usb_device = usb_new(usb_hcd_attached_device_info_t); 83 //result->usb_device = usb_new(usb_hcd_attached_device_info_t); 82 84 83 =======84 85 dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc);86 if (hc < 0) {87 return result;88 }89 //get some hub info90 usb_address_t addr = usb_drv_get_my_address(hc, device);91 dprintf(USB_LOG_LEVEL_DEBUG, "address of newly created hub = %d", addr);92 /*if(addr<0){93 //return result;94 95 }*/96 97 result->address = addr;98 99 >>>>>>> MERGE-SOURCE100 85 // get hub descriptor 101 86 … … 134 119 dprintf(USB_LOG_LEVEL_INFO, "setting port count to %d",descriptor->ports_count); 135 120 result->port_count = descriptor->ports_count; 136 result->attached_devs = (usb_h ub_attached_device_t*)137 malloc((result->port_count+1) * sizeof(usb_h ub_attached_device_t));121 result->attached_devs = (usb_hc_attached_device_t*) 122 malloc((result->port_count+1) * sizeof(usb_hc_attached_device_t)); 138 123 int i; 139 124 for(i=0;i<result->port_count+1;++i){ 140 result->attached_devs[i]. devman_handle=0;125 result->attached_devs[i].handle=0; 141 126 result->attached_devs[i].address=0; 142 127 } … … 166 151 usb_hub_info_t * hub_info = usb_create_hub_info(dev); 167 152 usb_endpoint_pipe_start_session(&hub_info->endpoints.control); 153 168 154 int port; 169 155 int opResult; 170 <<<<<<< TREE171 156 //usb_target_t target; 172 157 //target.address = hub_info->usb_device->address; 173 158 //target.endpoint = 0; 174 =======175 usb_target_t target;176 target.address = hub_info->address;177 target.endpoint = 0;178 >>>>>>> MERGE-SOURCE179 159 180 160 //get configuration descriptor … … 237 217 238 218 dprintf(USB_LOG_LEVEL_INFO, "hub dev added"); 219 //address is lost... 239 220 dprintf(USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ", 240 hub_info->address,221 //hub_info->endpoints.control., 241 222 hub_info->port_count); 242 223 dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",config_descriptor.configuration_number); … … 279 260 int opResult; 280 261 dprintf(USB_LOG_LEVEL_INFO, "some connection changed"); 262 assert(hub->endpoints.control.hc_phone); 281 263 //get default address 282 ///////////////here ended pipe api upgrading 283 gfdl;gfdgldglglkfgklfjfkld;sjgk;fgklsjgld 284 opResult = usb_drv_reserve_default_address(hc); 264 //opResult = usb_drv_reserve_default_address(hc); 265 opResult = usb_hc_reserve_default_address(&hub->connection, false); 285 266 if (opResult != EOK) { 286 267 dprintf(USB_LOG_LEVEL_WARNING, "cannot assign default address, it is probably used"); … … 289 270 //reset port 290 271 usb_hub_set_reset_port_request(&request, port); 291 opResult = usb_ drv_sync_control_write(292 hc, target,293 &request, 272 opResult = usb_endpoint_pipe_control_write( 273 &hub->endpoints.control, 274 &request,sizeof(usb_device_request_setup_packet_t), 294 275 NULL, 0 295 276 ); 296 277 if (opResult != EOK) { 297 278 dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when reseting a port"); 298 usb_hub_release_default_address(hc); 279 //usb_hub_release_default_address(hc); 280 usb_hc_release_default_address(&hub->connection); 299 281 } 300 282 } … … 307 289 */ 308 290 static void usb_hub_finalize_add_device( usb_hub_info_t * hub, 309 int hc, uint16_t port, usb_target_t target) {291 uint16_t port) { 310 292 311 293 int opResult; 312 294 dprintf(USB_LOG_LEVEL_INFO, "finalizing add device"); 313 opResult = usb_hub_clear_port_feature( hc, target.address,295 opResult = usb_hub_clear_port_feature(&hub->endpoints.control, 314 296 port, USB_HUB_FEATURE_C_PORT_RESET); 297 315 298 if (opResult != EOK) { 316 299 dprintf(USB_LOG_LEVEL_ERROR, "failed to clear port reset feature"); 317 usb_hub_release_default_address(hc); 318 return; 319 } 320 321 /* Request address at from host controller. */ 322 usb_address_t new_device_address = usb_drv_request_address(hc); 300 usb_hc_release_default_address(&hub->connection); 301 return; 302 } 303 //create connection to device 304 usb_endpoint_pipe_t new_device_pipe; 305 usb_device_connection_t new_device_connection; 306 usb_device_connection_initialize_on_default_address( 307 &new_device_connection, 308 &hub->connection 309 ); 310 usb_endpoint_pipe_initialize_default_control( 311 &new_device_pipe, 312 &new_device_connection); 313 /// \TODO get highspeed info 314 315 316 317 318 319 /* Request address from host controller. */ 320 usb_address_t new_device_address = usb_hc_request_address( 321 &hub->connection, 322 false/// \TODO fullspeed?? 323 ); 323 324 if (new_device_address < 0) { 324 325 dprintf(USB_LOG_LEVEL_ERROR, "failed to get free USB address"); 325 326 opResult = new_device_address; 326 usb_h ub_release_default_address(hc);327 usb_hc_release_default_address(&hub->connection); 327 328 return; 328 329 } 329 330 dprintf(USB_LOG_LEVEL_INFO, "setting new address %d",new_device_address); 330 opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 331 new_device_address); 331 //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 332 // new_device_address); 333 opResult = usb_request_set_address(&new_device_pipe,new_device_address); 332 334 333 335 if (opResult != EOK) { 334 336 dprintf(USB_LOG_LEVEL_ERROR, "could not set address for new device"); 335 usb_hub_release_default_address(hc); 336 return; 337 } 338 339 340 opResult = usb_hub_release_default_address(hc); 337 usb_hc_release_default_address(&hub->connection); 338 return; 339 } 340 341 342 //opResult = usb_hub_release_default_address(hc); 343 opResult = usb_hc_release_default_address(&hub->connection); 341 344 if(opResult!=EOK){ 342 345 return; 343 346 } 344 347 345 devman_handle_t hc_handle;346 opResult = usb_drv_find_hc(hub->device, &hc_handle);347 if (opResult != EOK) {348 usb_log_error("Failed to get handle of host controller: %s.\n",349 str_error(opResult));350 return;351 }352 353 348 devman_handle_t child_handle; 354 opResult = usb_device_register_child_in_devman(new_device_address, 355 hc_handle, hub->device, &child_handle); 349 //?? 350 opResult = usb_device_register_child_in_devman(new_device_address, 351 hub->connection.hc_handle, hub->device, &child_handle); 352 356 353 if (opResult != EOK) { 357 354 dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device"); 358 355 return; 359 356 } 360 hub->attached_devs[port]. devman_handle = child_handle;357 hub->attached_devs[port].handle = child_handle; 361 358 hub->attached_devs[port].address = new_device_address; 362 359 363 opResult = usb_drv_bind_address(hc, new_device_address, child_handle); 360 //opResult = usb_drv_bind_address(hc, new_device_address, child_handle); 361 opResult = usb_hc_register_device( 362 &hub->connection, 363 &hub->attached_devs[port]); 364 364 if (opResult != EOK) { 365 365 dprintf(USB_LOG_LEVEL_ERROR, "could not assign address of device in hcd"); … … 378 378 */ 379 379 static void usb_hub_removed_device( 380 usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {380 usb_hub_info_t * hub,uint16_t port) { 381 381 //usb_device_request_setup_packet_t request; 382 382 int opResult; … … 385 385 * devide manager 386 386 */ 387 388 hub->attached_devs[port].devman_handle=0; 387 389 388 //close address 390 389 if(hub->attached_devs[port].address!=0){ 391 opResult = usb_drv_release_address(hc,hub->attached_devs[port].address); 390 //opResult = usb_drv_release_address(hc,hub->attached_devs[port].address); 391 opResult = usb_hc_unregister_device( 392 &hub->connection, hub->attached_devs[port].address); 392 393 if(opResult != EOK) { 393 394 dprintf(USB_LOG_LEVEL_WARNING, "could not release address of " \ … … 395 396 } 396 397 hub->attached_devs[port].address = 0; 398 hub->attached_devs[port].handle = 0; 397 399 }else{ 398 400 dprintf(USB_LOG_LEVEL_WARNING, "this is strange, disconnected device had no address"); 399 401 //device was disconnected before it`s port was reset - return default address 400 usb_drv_release_default_address(hc); 402 //usb_drv_release_default_address(hc); 403 usb_hc_release_default_address(&hub->connection); 401 404 } 402 405 } … … 412 415 dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port); 413 416 //determine type of change 414 int opResult = usb_endpoint_pipe_start_session(&hub->endpoints.control);415 417 usb_endpoint_pipe_t *pipe = &hub->endpoints.control; 418 int opResult = usb_endpoint_pipe_start_session(pipe); 419 416 420 if(opResult != EOK){ 417 continue;421 dprintf(USB_LOG_LEVEL_ERROR, "cannot open pipe %d", opResult); 418 422 } 419 423 … … 446 450 //something connected/disconnected 447 451 if (usb_port_connect_change(&status)) { 448 opResult = usb_hub_clear_port_feature( &hub->endpoints.control,452 opResult = usb_hub_clear_port_feature(pipe, 449 453 port, USB_HUB_FEATURE_C_PORT_CONNECTION); 450 454 // TODO: check opResult … … 476 480 /// \TODO handle other changes 477 481 /// \TODO debug log for various situations 478 usb_endpoint_pipe_end_session( &hub->endpoints.control);482 usb_endpoint_pipe_end_session(pipe); 479 483 480 484 … … 526 530 void *change_bitmap = malloc(byte_length); 527 531 size_t actual_size; 528 usb_handle_t handle;532 //usb_handle_t handle; 529 533 530 534 /* … … 533 537 opResult = usb_endpoint_pipe_read( 534 538 &hub_info->endpoints.status_change, 535 change_bitmap, byte_length, &actual_size ,539 change_bitmap, byte_length, &actual_size 536 540 ); 537 541 538 usb_drv_async_wait_for(handle);542 //usb_drv_async_wait_for(handle); 539 543 540 544 if (opResult != EOK) { … … 549 553 if (interrupt) { 550 554 usb_hub_process_interrupt( 551 <<<<<<< TREE552 555 hub_info, port); 553 =======554 hub_info, hc, port, hub_info->address);555 >>>>>>> MERGE-SOURCE556 556 } 557 557 } -
uspace/drv/usbhub/usbhub.h
r50ba203 r6bb83c7 42 42 #define NAME "usbhub" 43 43 44 <<<<<<< TREE 45 #include "usb/hcdhubd.h" 44 //#include "usb/hcdhubd.h" 45 #include <usb/usbdrv.h> 46 #include <usb/hub.h> 46 47 47 48 #include <usb/pipes.h> 48 49 =======50 >>>>>>> MERGE-SOURCE51 /** basic information about device attached to hub */52 typedef struct{53 usb_address_t address;54 devman_handle_t devman_handle;55 }usb_hub_attached_device_t;56 49 57 50 /* Hub endpoints. */ … … 68 61 int port_count; 69 62 /** attached device handles, for each port one */ 70 usb_h ub_attached_device_t * attached_devs;71 /** USB address of the hub. */72 usb_address_t address;63 usb_hc_attached_device_t * attached_devs; 64 /** General usb device info. */ 65 //usb_hcd_attached_device_info_t * usb_device; 73 66 /** General device info*/ 74 67 device_t * device; 75 <<<<<<< TREE76 68 /** connection to hcd */ 77 usb_device_connection_t connection; 69 //usb_device_connection_t connection; 70 usb_hc_connection_t connection; 71 /** */ 72 usb_device_connection_t device_connection; 78 73 /** hub endpoints */ 79 74 usb_hub_endpoints_t endpoints; 80 81 =======82 >>>>>>> MERGE-SOURCE83 75 } usb_hub_info_t; 84 76 -
uspace/drv/usbhub/usbhub_private.h
r50ba203 r6bb83c7 45 45 #include <fibril_synch.h> 46 46 47 #include <usb/classes/hub.h> 47 48 #include <usb/usb.h> 48 49 #include <usb/usbdrv.h> 49 #include <usb/classes/hub.h> 50 #include <usb/devreq.h>50 51 //#include <usb/devreq.h> 51 52 #include <usb/debug.h> 52 53 -
uspace/drv/usbhub/utils.c
r50ba203 r6bb83c7 114 114 115 115 //control transactions 116 116 /* 117 117 int usb_drv_sync_control_read( 118 118 int phone, usb_target_t target, … … 199 199 } 200 200 201 201 */ 202 202 203 203 -
uspace/lib/usb/include/usb/classes/hub.h
r50ba203 r6bb83c7 1 1 /* 2 * Copyright (c) 2010 Vojtech Horky2 * Copyright (c) 2010 Matus Dekanek 3 3 * All rights reserved. 4 4 * … … 33 33 * @brief USB hub related structures. 34 34 */ 35 #ifndef LIBUSB_ HUB_H_36 #define LIBUSB_ HUB_H_35 #ifndef LIBUSB_CLASS_HUB_H_ 36 #define LIBUSB_CLASS_HUB_H_ 37 37 38 38 #include <sys/types.h> -
uspace/lib/usb/include/usb/hub.h
r50ba203 r6bb83c7 39 39 #include <usb/usbdevice.h> 40 40 41 41 42 /** Info about device attached to host controller. 42 43 *
Note:
See TracChangeset
for help on using the changeset viewer.