Changes in uspace/drv/usbhub/usbhub.c [f40a1e2:6986418] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
rf40a1e2 r6986418 46 46 #include "usbhub_private.h" 47 47 #include "port_status.h" 48 #include "usb/usb.h"49 48 50 49 static usb_iface_t hub_usb_iface = { … … 76 75 //get some hub info 77 76 usb_address_t addr = usb_drv_get_my_address(hc, device); 78 dprintf(1,"[usb_hub] addres sof newly created hub = %d", addr);77 dprintf(1,"[usb_hub] addres of newly created hub = %d", addr); 79 78 /*if(addr<0){ 80 79 //return result; … … 86 85 87 86 // get hub descriptor 87 usb_target_t target; 88 target.address = addr; 89 target.endpoint = 0; 90 usb_device_request_setup_packet_t request; 91 //printf("[usb_hub] creating descriptor request\n"); 92 usb_hub_set_descriptor_request(&request); 88 93 89 94 //printf("[usb_hub] creating serialized descriptor\n"); … … 93 98 int opResult; 94 99 //printf("[usb_hub] starting control transaction\n"); 95 96 opResult = usb_drv_req_get_descriptor(hc, addr, 97 USB_REQUEST_TYPE_CLASS, 98 USB_DESCTYPE_HUB, 0, 0, serialized_descriptor, 100 opResult = usb_drv_sync_control_read( 101 hc, target, &request, serialized_descriptor, 99 102 USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size); 100 101 103 if (opResult != EOK) { 102 104 dprintf(1,"[usb_hub] failed when receiving hub descriptor, badcode = %d",opResult); … … 153 155 int port; 154 156 int opResult; 157 usb_device_request_setup_packet_t request; 155 158 usb_target_t target; 156 159 target.address = hub_info->usb_device->address; … … 170 173 if(std_descriptor.configuration_count<1){ 171 174 dprintf(1,"[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE"); 172 //shouldn`t I return? 173 } 174 /// \TODO check other configurations 175 } 175 176 usb_standard_configuration_descriptor_t config_descriptor; 176 177 opResult = usb_drv_req_get_bare_configuration_descriptor(hc, … … 182 183 } 183 184 //set configuration 184 opResult = usb_drv_req_set_configuration(hc, target.address, 185 config_descriptor.configuration_number); 186 185 request.request_type = 0; 186 request.request = USB_DEVREQ_SET_CONFIGURATION; 187 request.index=0; 188 request.length=0; 189 request.value_high=0; 190 request.value_low = config_descriptor.configuration_number; 191 opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0); 187 192 if (opResult != EOK) { 188 193 dprintf(1,"[usb_hub]something went wrong when setting hub`s configuration, %d", opResult); 189 194 } 190 195 191 usb_device_request_setup_packet_t request; 196 192 197 for (port = 1; port < hub_info->port_count+1; ++port) { 193 198 usb_hub_set_power_port_request(&request, port); … … 200 205 //ports powered, hub seems to be enabled 201 206 207 202 208 ipc_hangup(hc); 203 209 204 210 //add the hub to list 205 futex_down(&usb_hub_list_lock);206 211 usb_lst_append(&usb_hub_list, hub_info); 207 futex_up(&usb_hub_list_lock);208 209 212 dprintf(1,"[usb_hub] hub info added to list"); 210 213 //(void)hub_info; … … 224 227 225 228 229 226 230 //********************************************* 227 231 // … … 231 235 232 236 /** 233 * Convenience function for releasing default address and writing debug info 234 * (these few lines are used too often to be written again and again). 235 * @param hc 236 * @return 237 */ 238 inline static int usb_hub_release_default_address(int hc){ 239 int opResult; 240 dprintf(1,"[usb_hub] releasing default address"); 241 opResult = usb_drv_release_default_address(hc); 242 if (opResult != EOK) { 243 dprintf(1,"[usb_hub] failed to release default address"); 244 } 245 return opResult; 246 } 247 248 /** 249 * Reset the port with new device and reserve the default address. 237 * reset the port with new device and reserve the default address 250 238 * @param hc 251 239 * @param port … … 271 259 if (opResult != EOK) { 272 260 dprintf(1,"[usb_hub] something went wrong when reseting a port"); 273 usb_hub_release_default_address(hc);274 261 } 275 262 } 276 263 277 264 /** 278 * Finalize adding new device after port reset 265 * convenience function for releasing default address and writing debug info 266 * (these few lines are used too often to be written again and again) 267 * @param hc 268 * @return 269 */ 270 inline static int usb_hub_release_default_address(int hc){ 271 int opResult; 272 dprintf(1,"[usb_hub] releasing default address"); 273 opResult = usb_drv_release_default_address(hc); 274 if (opResult != EOK) { 275 dprintf(1,"[usb_hub] failed to release default address"); 276 } 277 return opResult; 278 } 279 280 281 /** 282 * finalize adding new device after port reset 279 283 * @param hc 280 284 * @param port … … 339 343 340 344 /** 341 * Unregister device address in hc345 * unregister device address in hc, close the port 342 346 * @param hc 343 347 * @param port … … 348 352 //usb_device_request_setup_packet_t request; 349 353 int opResult; 350 351 /** \TODO remove device from device manager - not yet implemented in 352 * devide manager 353 */ 354 //disable port 355 /*usb_hub_set_disable_port_request(&request, port); 356 opResult = usb_drv_sync_control_write( 357 hc, target, 358 &request, 359 NULL, 0 360 ); 361 if (opResult != EOK) { 362 //continue; 363 printf("[usb_hub] something went wrong when disabling a port\n"); 364 }*/ 365 /// \TODO remove device 354 366 355 367 hub->attached_devs[port].devman_handle=0; … … 372 384 373 385 /** 374 * Process interrupts on given hub port386 * process interrupts on given hub port 375 387 * @param hc 376 388 * @param port … … 430 442 usb_port_set_reset_completed(&status, false); 431 443 usb_port_set_dev_connected(&status, false); 432 if (status>>16) { 433 dprintf(1,"[usb_hub]there was some unsupported change on port %d: %X",port,status); 434 444 if (status) { 445 dprintf(1,"[usb_hub]there was some unsupported change on port %d",port); 435 446 } 436 447 /// \TODO handle other changes … … 439 450 } 440 451 441 /** 442 * Check changes on all known hubs. 452 /* Check changes on all known hubs. 443 453 */ 444 454 void usb_hub_check_hub_changes(void) { … … 447 457 */ 448 458 usb_general_list_t * lst_item; 449 futex_down(&usb_hub_list_lock);450 459 for (lst_item = usb_hub_list.next; 451 460 lst_item != &usb_hub_list; 452 461 lst_item = lst_item->next) { 453 futex_up(&usb_hub_list_lock);454 462 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data); 455 463 /* … … 460 468 target.address = hub_info->usb_device->address; 461 469 target.endpoint = 1;/// \TODO get from endpoint descriptor 462 dprintf(1,"[usb_hub] checking changes for hub at addr %d",463 target.address); 470 /*dprintf(1,"[usb_hub] checking changes for hub at addr %d", 471 target.address);*/ 464 472 465 473 size_t port_count = hub_info->port_count; … … 502 510 } 503 511 } 504 free(change_bitmap);505 512 506 513 ipc_hangup(hc); 507 futex_down(&usb_hub_list_lock); 508 } 509 futex_up(&usb_hub_list_lock); 514 } 510 515 } 511 516
Note:
See TracChangeset
for help on using the changeset viewer.