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