Changes in / [bfc12ef:ff244e6] in mainline
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/main.c
rbfc12ef rff244e6 37 37 #include <usb/usbdrv.h> 38 38 39 40 39 #include "usbhub.h" 41 40 #include "usbhub_private.h" … … 65 64 int main(int argc, char *argv[]) 66 65 { 67 usb_dprintf_enable(NAME, USB_LOG_LEVEL_INFO);66 usb_dprintf_enable(NAME, 0); 68 67 69 68 fibril_mutex_initialize(&usb_hub_list_lock); -
uspace/drv/usbhub/usbhub.c
rbfc12ef rff244e6 70 70 71 71 72 dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc);72 //printf("[usb_hub] phone to hc = %d\n", hc); 73 73 if (hc < 0) { 74 74 return result; … … 76 76 //get some hub info 77 77 usb_address_t addr = usb_drv_get_my_address(hc, device); 78 dprintf( USB_LOG_LEVEL_DEBUG, "address of newly created hub = %d", addr);78 dprintf(1, "address of newly created hub = %d", addr); 79 79 /*if(addr<0){ 80 80 //return result; … … 87 87 // get hub descriptor 88 88 89 dprintf(USB_LOG_LEVEL_DEBUG, "creating serialized descripton");89 //printf("[usb_hub] creating serialized descriptor\n"); 90 90 void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE); 91 91 usb_hub_descriptor_t * descriptor; 92 92 size_t received_size; 93 93 int opResult; 94 dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");94 //printf("[usb_hub] starting control transaction\n"); 95 95 96 96 opResult = usb_drv_req_get_descriptor(hc, addr, … … 100 100 101 101 if (opResult != EOK) { 102 dprintf( USB_LOG_LEVEL_ERROR, "failed when receiving hub descriptor, badcode = %d",opResult);102 dprintf(1, "failed when receiving hub descriptor, badcode = %d",opResult); 103 103 free(serialized_descriptor); 104 104 return result; 105 105 } 106 dprintf(USB_LOG_LEVEL_DEBUG2, "deserializing descriptor");106 //printf("[usb_hub] deserializing descriptor\n"); 107 107 descriptor = usb_deserialize_hub_desriptor(serialized_descriptor); 108 108 if(descriptor==NULL){ 109 dprintf( USB_LOG_LEVEL_WARNING, "could not deserialize descriptor ");109 dprintf(1, "could not deserialize descriptor "); 110 110 result->port_count = 1;///\TODO this code is only for debug!!! 111 111 return result; 112 112 } 113 dprintf(USB_LOG_LEVEL_INFO, "setting port count to %d",descriptor->ports_count);113 //printf("[usb_hub] setting port count to %d\n",descriptor->ports_count); 114 114 result->port_count = descriptor->ports_count; 115 115 result->attached_devs = (usb_hub_attached_device_t*) … … 120 120 result->attached_devs[i].address=0; 121 121 } 122 dprintf(USB_LOG_LEVEL_DEBUG2, "freeing data");122 //printf("[usb_hub] freeing data\n"); 123 123 free(serialized_descriptor); 124 124 free(descriptor->devices_removable); … … 127 127 //finish 128 128 129 dprintf( USB_LOG_LEVEL_INFO, "hub info created");129 dprintf(1, "hub info created"); 130 130 131 131 return result; … … 133 133 134 134 int usb_add_hub_device(device_t *dev) { 135 dprintf(USB_LOG_LEVEL_INFO, "add_hub_device(handle=%d)", (int) dev->handle); 135 dprintf(1, "add_hub_device(handle=%d)", (int) dev->handle); 136 dprintf(1, "hub device"); 136 137 137 138 /* … … 163 164 &std_descriptor); 164 165 if(opResult!=EOK){ 165 dprintf( USB_LOG_LEVEL_ERROR, "could not get device descriptor, %d",opResult);166 dprintf(1, "could not get device descriptor, %d",opResult); 166 167 return opResult; 167 168 } 168 dprintf( USB_LOG_LEVEL_INFO, "hub has %d configurations",std_descriptor.configuration_count);169 dprintf(1, "hub has %d configurations",std_descriptor.configuration_count); 169 170 if(std_descriptor.configuration_count<1){ 170 dprintf( USB_LOG_LEVEL_ERROR, "THERE ARE NO CONFIGURATIONS AVAILABLE");171 dprintf(1, "THERE ARE NO CONFIGURATIONS AVAILABLE"); 171 172 //shouldn`t I return? 172 173 } … … 177 178 &config_descriptor); 178 179 if(opResult!=EOK){ 179 dprintf( USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult);180 dprintf(1, "could not get configuration descriptor, %d",opResult); 180 181 return opResult; 181 182 } … … 185 186 186 187 if (opResult != EOK) { 187 dprintf( USB_LOG_LEVEL_ERROR, "something went wrong when setting hub`s configuration, %d", opResult);188 dprintf(1, "something went wrong when setting hub`s configuration, %d", opResult); 188 189 } 189 190 … … 192 193 usb_hub_set_power_port_request(&request, port); 193 194 opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0); 194 dprintf( USB_LOG_LEVEL_INFO, "powering port %d",port);195 dprintf(1, "powering port %d",port); 195 196 if (opResult != EOK) { 196 dprintf( USB_LOG_LEVEL_WARNING, "something went wrong when setting hub`s %dth port", port);197 dprintf(1, "something went wrong when setting hub`s %dth port", port); 197 198 } 198 199 } … … 206 207 fibril_mutex_unlock(&usb_hub_list_lock); 207 208 208 dprintf( USB_LOG_LEVEL_DEBUG, "hub info added to list");209 dprintf(1, "hub info added to list"); 209 210 //(void)hub_info; 210 211 usb_hub_check_hub_changes(); … … 212 213 213 214 214 dprintf( USB_LOG_LEVEL_INFO, "hub dev added");215 dprintf( USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ",215 dprintf(1, "hub dev added"); 216 dprintf(1, "\taddress %d, has %d ports ", 216 217 hub_info->usb_device->address, 217 218 hub_info->port_count); 218 dprintf( USB_LOG_LEVEL_DEBUG, "\tused configuration %d",config_descriptor.configuration_number);219 dprintf(1, "\tused configuration %d",config_descriptor.configuration_number); 219 220 220 221 return EOK; … … 237 238 inline static int usb_hub_release_default_address(int hc){ 238 239 int opResult; 239 dprintf( USB_LOG_LEVEL_INFO, "releasing default address");240 dprintf(1, "releasing default address"); 240 241 opResult = usb_drv_release_default_address(hc); 241 242 if (opResult != EOK) { 242 dprintf( USB_LOG_LEVEL_WARNING, "failed to release default address");243 dprintf(1, "failed to release default address"); 243 244 } 244 245 return opResult; … … 254 255 usb_device_request_setup_packet_t request; 255 256 int opResult; 256 dprintf( USB_LOG_LEVEL_INFO, "some connection changed");257 dprintf(1, "some connection changed"); 257 258 //get default address 258 259 opResult = usb_drv_reserve_default_address(hc); 259 260 if (opResult != EOK) { 260 dprintf( USB_LOG_LEVEL_WARNING, "cannot assign default address, it is probably used");261 dprintf(1, "cannot assign default address, it is probably used"); 261 262 return; 262 263 } … … 269 270 ); 270 271 if (opResult != EOK) { 271 dprintf( USB_LOG_LEVEL_ERROR, "something went wrong when reseting a port");272 dprintf(1, "something went wrong when reseting a port"); 272 273 usb_hub_release_default_address(hc); 273 274 } … … 284 285 285 286 int opResult; 286 dprintf( USB_LOG_LEVEL_INFO, "finalizing add device");287 dprintf(1, "finalizing add device"); 287 288 opResult = usb_hub_clear_port_feature(hc, target.address, 288 289 port, USB_HUB_FEATURE_C_PORT_RESET); 289 290 if (opResult != EOK) { 290 dprintf( USB_LOG_LEVEL_ERROR, "failed to clear port reset feature");291 dprintf(1, "failed to clear port reset feature"); 291 292 usb_hub_release_default_address(hc); 292 293 return; … … 296 297 usb_address_t new_device_address = usb_drv_request_address(hc); 297 298 if (new_device_address < 0) { 298 dprintf( USB_LOG_LEVEL_ERROR, "failed to get free USB address");299 dprintf(1, "failed to get free USB address"); 299 300 opResult = new_device_address; 300 301 usb_hub_release_default_address(hc); 301 302 return; 302 303 } 303 dprintf( USB_LOG_LEVEL_INFO, "setting new address %d",new_device_address);304 dprintf(1, "setting new address"); 304 305 opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 305 306 new_device_address); 306 307 307 308 if (opResult != EOK) { 308 dprintf( USB_LOG_LEVEL_ERROR, "could not set address for new device");309 dprintf(1, "could not set address for new device"); 309 310 usb_hub_release_default_address(hc); 310 311 return; … … 321 322 new_device_address, &child_handle); 322 323 if (opResult != EOK) { 323 dprintf( USB_LOG_LEVEL_ERROR, "could not start driver for new device");324 dprintf(1, "could not start driver for new device"); 324 325 return; 325 326 } … … 329 330 opResult = usb_drv_bind_address(hc, new_device_address, child_handle); 330 331 if (opResult != EOK) { 331 dprintf( USB_LOG_LEVEL_ERROR, "could not assign address of device in hcd");332 return; 333 } 334 dprintf( USB_LOG_LEVEL_INFO, "new device address %d, handle %zu",332 dprintf(1, "could not assign address of device in hcd"); 333 return; 334 } 335 dprintf(1, "new device address %d, handle %zu", 335 336 new_device_address, child_handle); 336 337 … … 357 358 opResult = usb_drv_release_address(hc,hub->attached_devs[port].address); 358 359 if(opResult != EOK) { 359 dprintf( USB_LOG_LEVEL_WARNING, "could not release address of " \360 dprintf(1, "could not release address of " \ 360 361 "removed device: %d", opResult); 361 362 } 362 363 hub->attached_devs[port].address = 0; 363 364 }else{ 364 dprintf( USB_LOG_LEVEL_WARNING, "this is strange, disconnected device had no address");365 dprintf(1, "this is strange, disconnected device had no address"); 365 366 //device was disconnected before it`s port was reset - return default address 366 367 usb_drv_release_default_address(hc); … … 376 377 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc, 377 378 uint16_t port, usb_address_t address) { 378 dprintf( USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port);379 dprintf(1, "interrupt at port %d", port); 379 380 //determine type of change 380 381 usb_target_t target; … … 394 395 ); 395 396 if (opResult != EOK) { 396 dprintf( USB_LOG_LEVEL_ERROR, "ERROR: could not get port status");397 dprintf(1, "ERROR: could not get port status"); 397 398 return; 398 399 } 399 400 if (rcvd_size != sizeof (usb_port_status_t)) { 400 dprintf( USB_LOG_LEVEL_ERROR, "ERROR: received status has incorrect size");401 dprintf(1, "ERROR: received status has incorrect size"); 401 402 return; 402 403 } … … 407 408 // TODO: check opResult 408 409 if (usb_port_dev_connected(&status)) { 409 dprintf( USB_LOG_LEVEL_INFO, "some connection changed");410 dprintf(1, "some connection changed"); 410 411 usb_hub_init_add_device(hc, port, target); 411 412 } else { … … 415 416 //port reset 416 417 if (usb_port_reset_completed(&status)) { 417 dprintf( USB_LOG_LEVEL_INFO, "port reset complete");418 dprintf(1, "port reset complete"); 418 419 if (usb_port_enabled(&status)) { 419 420 usb_hub_finalize_add_device(hub, hc, port, target); 420 421 } else { 421 dprintf( USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled");422 dprintf(1, "ERROR: port reset, but port still not enabled"); 422 423 } 423 424 } … … 428 429 usb_port_set_dev_connected(&status, false); 429 430 if (status>>16) { 430 dprintf( USB_LOG_LEVEL_INFO, "there was some unsupported change on port %d: %X",port,status);431 dprintf(1, "there was some unsupported change on port %d: %X",port,status); 431 432 432 433 } … … 457 458 target.address = hub_info->usb_device->address; 458 459 target.endpoint = 1;/// \TODO get from endpoint descriptor 459 dprintf( USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d",460 dprintf(1, "checking changes for hub at addr %d", 460 461 target.address); 461 462 … … 488 489 if (opResult != EOK) { 489 490 free(change_bitmap); 490 dprintf( USB_LOG_LEVEL_WARNING, "something went wrong while getting status of hub");491 dprintf(1, "something went wrong while getting status of hub"); 491 492 continue; 492 493 } -
uspace/drv/usbhub/usbhub_private.h
rbfc12ef rff244e6 61 61 //************ 62 62 // 63 // convenience debug printf for usb hub63 // convenience debug printf 64 64 // 65 65 //************ 66 66 #define dprintf(level, format, ...) \ 67 67 usb_dprintf(NAME, (level), format "\n", ##__VA_ARGS__) 68 69 68 70 69 /** -
uspace/drv/usbhub/utils.c
rbfc12ef rff244e6 116 116 117 117 int usb_drv_sync_control_read( 118 119 120 121 ) {118 int phone, usb_target_t target, 119 usb_device_request_setup_packet_t * request, 120 void * rcvd_buffer, size_t rcvd_size, size_t * actual_size 121 ) { 122 122 usb_handle_t handle; 123 123 int opResult; 124 124 //setup 125 125 opResult = usb_drv_async_control_read_setup(phone, target, 126 127 126 request, sizeof (usb_device_request_setup_packet_t), 127 &handle); 128 128 if (opResult != EOK) { 129 129 return opResult; … … 158 158 159 159 int usb_drv_sync_control_write( 160 161 162 163 ) {160 int phone, usb_target_t target, 161 usb_device_request_setup_packet_t * request, 162 void * sent_buffer, size_t sent_size 163 ) { 164 164 usb_handle_t handle; 165 165 int opResult; 166 166 //setup 167 167 opResult = usb_drv_async_control_write_setup(phone, target, 168 169 168 request, sizeof (usb_device_request_setup_packet_t), 169 &handle); 170 170 if (opResult != EOK) { 171 171 return opResult; … … 188 188 //finalize 189 189 opResult = usb_drv_async_control_write_status(phone, target, 190 190 &handle); 191 191 if (opResult != EOK) { 192 192 return opResult; -
uspace/lib/usb/include/usb/usbmem.h
rbfc12ef rff244e6 1 1 /* 2 * Copyright (c) 201 1Matus Dekanek2 * Copyright (c) 2010 Matus Dekanek 3 3 * All rights reserved. 4 4 * … … 35 35 * @{ 36 36 */ 37 /** @file definitions of memory management with address translation, used mostly in usb stack37 /** @file definitions of special memory management, used mostly in usb stack 38 38 * 39 39 * USB HCD needs traslation between physical and virtual addresses. These … … 59 59 60 60 extern void * mman_malloc( 61 62 63 61 size_t size, 62 size_t alignment, 63 unsigned long max_physical_address); 64 64 65 65 extern void * mman_getVA(void * addr); -
uspace/lib/usb/src/usbmem.c
rbfc12ef rff244e6 1 1 /* 2 * Copyright (c) 201 1Matus Dekanek2 * Copyright (c) 2010 Matus Dekanek 3 3 * All rights reserved. 4 4 * … … 69 69 } 70 70 71 static void addr_remove_callback(link_t * 71 static void addr_remove_callback(link_t *item) 72 72 { 73 73 //delete item
Note:
See TracChangeset
for help on using the changeset viewer.