Changeset e6223239 in mainline for uspace/drv/usbhub/usbhub.c
- Timestamp:
- 2011-03-26T15:56:57Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f3da9b2
- Parents:
- f97717d9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
rf97717d9 re6223239 53 53 #include "usb/classes/classes.h" 54 54 55 static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port, 56 usb_speed_t speed); 57 58 static int usb_hub_attach_non_removable_devices(usb_hub_info_t * hub, 59 usb_hub_descriptor_t * descriptor); 60 55 61 int usb_hub_control_loop(void * hub_info_param){ 56 62 usb_hub_info_t * hub_info = (usb_hub_info_t*)hub_info_param; … … 91 97 92 98 /** 93 * Load hub-specific information into hub_info structure .99 * Load hub-specific information into hub_info structure and process if needed 94 100 * 95 101 * Particularly read port count and initialize structure holding port 96 * information. 102 * information. If there are non-removable devices, start initializing them. 97 103 * This function is hub-specific and should be run only after the hub is 98 104 * configured using usb_hub_set_configuration function. … … 100 106 * @return error code 101 107 */ 102 static int usb_hub_ get_hub_specific_info(usb_hub_info_t * hub_info){108 static int usb_hub_process_hub_specific_info(usb_hub_info_t * hub_info){ 103 109 // get hub descriptor 104 110 usb_log_debug("creating serialized descriptor\n"); … … 107 113 108 114 /* this was one fix of some bug, should not be needed anymore 115 * these lines allow to reset hub once more, it can be used as 116 * brute-force initialization for non-removable devices 109 117 int opResult = usb_request_set_configuration(&result->endpoints.control, 1); 110 118 if(opResult!=EOK){ … … 141 149 hub_info->attached_devs[i].address=0; 142 150 } 151 usb_hub_attach_non_removable_devices(hub_info, descriptor); 143 152 usb_log_debug2("freeing data\n"); 144 153 free(serialized_descriptor); … … 218 227 } 219 228 //get port count and create attached_devs 220 opResult = usb_hub_ get_hub_specific_info(hub_info);229 opResult = usb_hub_process_hub_specific_info(hub_info); 221 230 if(opResult!=EOK){ 222 231 usb_log_error("could not set hub configuration, errno %d\n",opResult); … … 256 265 //********************************************* 257 266 // 258 // hub driver code, main loop 267 // hub driver code, main loop and port handling 259 268 // 260 269 //********************************************* 270 271 /** 272 * Perform \a usb_hub_init_add_device on all ports with non-removable device 273 * 274 * This will trigger operations leading to activated non-removable device. 275 * Control pipe of the hub must be open fo communication. 276 * @param hub hub instance 277 * @param descriptor usb hub descriptor 278 * @return error code 279 */ 280 static int usb_hub_attach_non_removable_devices(usb_hub_info_t * hub, 281 usb_hub_descriptor_t * descriptor) 282 { 283 usb_log_info("attaching non-removable devices(if any)\n"); 284 usb_device_request_setup_packet_t request; 285 int opResult; 286 size_t rcvd_size; 287 usb_port_status_t status; 288 uint8_t * non_removable_dev_bitmap = descriptor->devices_removable; 289 //initialize all connected, non-removable devices 290 int port; 291 for(port=1;port<=descriptor->ports_count;++port){ 292 bool is_non_removable = 293 ((non_removable_dev_bitmap[port/8]) >> (port%8)) %2; 294 if(is_non_removable){ 295 usb_log_debug("non-removable device on port %d\n",port); 296 usb_hub_set_port_status_request(&request, port); 297 opResult = usb_pipe_control_read( 298 hub->control_pipe, 299 &request, sizeof(usb_device_request_setup_packet_t), 300 &status, 4, &rcvd_size 301 ); 302 if (opResult != EOK) { 303 usb_log_error("could not get port status of port %d errno:%d\n", 304 port, opResult); 305 return opResult; 306 } 307 //this should be true.. 308 if(usb_port_dev_connected(&status)){ 309 usb_hub_init_add_device(hub,port,usb_port_speed(&status)); 310 } 311 } 312 } 313 return EOK; 314 } 315 261 316 262 317 /**
Note:
See TracChangeset
for help on using the changeset viewer.