Changeset deece2f in mainline
- Timestamp:
- 2011-02-21T22:25:58Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 233e68d
- Parents:
- fb78ae72 (diff), dbe25f1 (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. - Files:
-
- 9 added
- 5 deleted
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
rfb78ae72 rdeece2f 88 88 ./uspace/drv/usbhub/usbhub 89 89 ./uspace/drv/usbhid/usbhid 90 ./uspace/drv/usbmid/usbmid 90 91 ./uspace/drv/vhc/vhc 91 92 ./uspace/srv/bd/ata_bd/ata_bd -
boot/arch/amd64/Makefile.inc
rfb78ae72 rdeece2f 47 47 usbhub \ 48 48 usbhid \ 49 usbmid \ 49 50 vhc 50 51 -
uspace/Makefile
rfb78ae72 rdeece2f 121 121 drv/usbhid \ 122 122 drv/usbhub \ 123 drv/usbmid \ 123 124 drv/vhc 124 125 endif … … 136 137 drv/usbhid \ 137 138 drv/usbhub \ 139 drv/usbmid \ 138 140 drv/vhc 139 141 endif -
uspace/app/usbinfo/info.c
rfb78ae72 rdeece2f 37 37 #include <str_error.h> 38 38 #include <errno.h> 39 #include <usb/usbdrv.h>40 39 #include <usb/pipes.h> 41 40 #include <usb/recognise.h> -
uspace/app/usbinfo/main.c
rfb78ae72 rdeece2f 43 43 #include <devman.h> 44 44 #include <devmap.h> 45 #include <usb/usbdrv.h>46 45 #include "usbinfo.h" 47 46 -
uspace/doc/doxygroups.h
rfb78ae72 rdeece2f 220 220 221 221 /** 222 * @defgroup drvusbmid USB multi interface device driver 223 * @ingroup usb 224 * @brief USB multi interface device driver 225 * @details 226 * This driver serves as a mini hub (or bus) driver for devices 227 * that have the class defined at interface level (those devices 228 * usually have several interfaces). 229 * 230 * The term multi interface device driver (MID) was borrowed 231 * Solaris operating system. 232 */ 233 234 /** 222 235 * @defgroup drvusbhub USB hub driver 223 236 * @ingroup usb -
uspace/drv/uhci-hcd/iface.c
rfb78ae72 rdeece2f 42 42 #include "uhci.h" 43 43 44 static int get_address(device_t *dev, devman_handle_t handle,45 usb_address_t *address)46 {47 assert(dev);48 uhci_t *hc = dev_to_uhci(dev);49 assert(hc);50 *address = usb_address_keeping_find(&hc->address_manager, handle);51 if (*address <= 0)52 return *address;53 return EOK;54 }55 44 /*----------------------------------------------------------------------------*/ 56 45 static int reserve_default_address(device_t *dev, usb_speed_t speed) … … 168 157 /*----------------------------------------------------------------------------*/ 169 158 usbhc_iface_t uhci_iface = { 170 .tell_address = get_address,171 172 159 .reserve_default_address = reserve_default_address, 173 160 .release_default_address = release_default_address, -
uspace/drv/uhci-hcd/main.c
rfb78ae72 rdeece2f 34 34 #include <driver.h> 35 35 #include <usb_iface.h> 36 #include <usb/ddfiface.h> 36 37 #include <device/hw_res.h> 37 38 … … 48 49 49 50 static int uhci_add_device(device_t *device); 50 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle); 51 /*----------------------------------------------------------------------------*/ 52 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)51 52 static int usb_iface_get_address(device_t *dev, devman_handle_t handle, 53 usb_address_t *address) 53 54 { 54 /* This shall be called only for the UHCI itself. */ 55 assert(dev->parent == NULL); 55 assert(dev); 56 uhci_t *hc = dev_to_uhci(dev); 57 assert(hc); 56 58 57 *handle = dev->handle; 59 usb_address_t addr = usb_address_keeping_find(&hc->address_manager, 60 handle); 61 if (addr < 0) { 62 return addr; 63 } 64 65 if (address != NULL) { 66 *address = addr; 67 } 68 58 69 return EOK; 59 70 } 60 /*----------------------------------------------------------------------------*/ 71 72 61 73 static usb_iface_t hc_usb_iface = { 62 .get_hc_handle = usb_iface_get_hc_handle 74 .get_hc_handle = usb_iface_get_hc_handle_hc_impl, 75 .get_address = usb_iface_get_address 63 76 }; 64 77 /*----------------------------------------------------------------------------*/ -
uspace/drv/uhci-rhd/main.c
rfb78ae72 rdeece2f 34 34 #include <driver.h> 35 35 #include <usb_iface.h> 36 #include <usb/ddfiface.h> 36 37 37 38 #include <errno.h> … … 56 57 57 58 static usb_iface_t uhci_rh_usb_iface = { 58 .get_hc_handle = usb_iface_get_hc_handle 59 .get_hc_handle = usb_iface_get_hc_handle, 60 .get_address = usb_iface_get_address_hub_impl 59 61 }; 60 62 -
uspace/drv/uhci-rhd/root_hub.c
rfb78ae72 rdeece2f 35 35 #include <stdint.h> 36 36 37 #include <usb/usbdrv.h>38 37 #include <usb/debug.h> 39 38 -
uspace/drv/usbhid/main.c
rfb78ae72 rdeece2f 36 36 */ 37 37 38 #include <usb/usbdrv.h>39 38 #include <driver.h> 40 39 #include <ipc/driver.h> … … 265 264 for (i = 0; i < count; ++i) { 266 265 printf("%d ", key_codes[i]); 266 } 267 printf("\n"); 268 269 for (i = 0; i < count; ++i) { 267 270 // TODO: Key press / release 268 271 269 272 // TODO: NOT WORKING 270 273 unsigned int key = usbkbd_parse_scancode(key_codes[i]); 274 275 if (key == 0) { 276 continue; 277 } 271 278 kbd_push_ev(KEY_PRESS, key); 272 279 } … … 348 355 { 349 356 .pipe = &kbd_dev->poll_pipe, 350 .description = &poll_endpoint_description 357 .description = &poll_endpoint_description, 358 .interface_no = 359 usb_device_get_assigned_interface(kbd_dev->device) 351 360 } 352 361 }; -
uspace/drv/usbhub/main.c
rfb78ae72 rdeece2f 34 34 #include <errno.h> 35 35 #include <async.h> 36 37 #include <usb/usbdrv.h>38 39 36 40 37 #include "usbhub.h" -
uspace/drv/usbhub/port_status.h
rfb78ae72 rdeece2f 35 35 #include <bool.h> 36 36 #include <sys/types.h> 37 #include <usb/ devreq.h>37 #include <usb/request.h> 38 38 #include "usbhub_private.h" 39 39 -
uspace/drv/usbhub/usbhub.c
rfb78ae72 rdeece2f 39 39 40 40 #include <usb_iface.h> 41 #include <usb/ usbdrv.h>41 #include <usb/ddfiface.h> 42 42 #include <usb/descriptor.h> 43 43 #include <usb/recognise.h> 44 #include <usb/ devreq.h>44 #include <usb/request.h> 45 45 #include <usb/classes/hub.h> 46 46 … … 49 49 #include "port_status.h" 50 50 #include "usb/usb.h" 51 52 static int iface_get_hc_handle(device_t *device, devman_handle_t *handle) 53 { 54 return usb_hc_find(device->handle, handle); 55 } 56 57 static usb_iface_t hub_usb_iface = { 58 .get_hc_handle = iface_get_hc_handle 51 #include "usb/pipes.h" 52 #include "usb/classes/classes.h" 53 54 static device_ops_t hub_device_ops = { 55 .interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl 59 56 }; 60 57 61 static device_ops_t hub_device_ops = { 62 .interfaces[USB_DEV_IFACE] = &hub_usb_iface 58 /** Hub status-change endpoint description */ 59 static usb_endpoint_description_t status_change_endpoint_description = { 60 .transfer_type = USB_TRANSFER_INTERRUPT, 61 .direction = USB_DIRECTION_IN, 62 .interface_class = USB_CLASS_HUB, 63 .flags = 0 63 64 }; 65 64 66 65 67 //********************************************* … … 69 71 //********************************************* 70 72 71 usb_hub_info_t * usb_create_hub_info(device_t * device, int hc) { 73 /** 74 * Initialize connnections to host controller, device, and device 75 * control endpoint 76 * @param hub 77 * @param device 78 * @return 79 */ 80 static int usb_hub_init_communication(usb_hub_info_t * hub){ 81 int opResult; 82 opResult = usb_device_connection_initialize_from_device( 83 &hub->device_connection, 84 hub->device); 85 if(opResult != EOK){ 86 dprintf(USB_LOG_LEVEL_ERROR, 87 "could not initialize connection to hc, errno %d",opResult); 88 return opResult; 89 } 90 opResult = usb_hc_connection_initialize_from_device(&hub->connection, 91 hub->device); 92 if(opResult != EOK){ 93 dprintf(USB_LOG_LEVEL_ERROR, 94 "could not initialize connection to device, errno %d",opResult); 95 return opResult; 96 } 97 opResult = usb_endpoint_pipe_initialize_default_control(&hub->endpoints.control, 98 &hub->device_connection); 99 if(opResult != EOK){ 100 dprintf(USB_LOG_LEVEL_ERROR, 101 "could not initialize connection to device endpoint, errno %d",opResult); 102 } 103 return opResult; 104 } 105 106 /** 107 * When entering this function, hub->endpoints.control should be active. 108 * @param hub 109 * @return 110 */ 111 static int usb_hub_process_configuration_descriptors( 112 usb_hub_info_t * hub){ 113 if(hub==NULL) { 114 return EINVAL; 115 } 116 int opResult; 117 118 //device descriptor 119 usb_standard_device_descriptor_t std_descriptor; 120 opResult = usb_request_get_device_descriptor(&hub->endpoints.control, 121 &std_descriptor); 122 if(opResult!=EOK){ 123 dprintf(USB_LOG_LEVEL_ERROR, "could not get device descriptor, %d",opResult); 124 return opResult; 125 } 126 dprintf(USB_LOG_LEVEL_INFO, "hub has %d configurations", 127 std_descriptor.configuration_count); 128 if(std_descriptor.configuration_count<1){ 129 dprintf(USB_LOG_LEVEL_ERROR, "THERE ARE NO CONFIGURATIONS AVAILABLE"); 130 //shouldn`t I return? 131 } 132 133 //configuration descriptor 134 /// \TODO check other configurations 135 usb_standard_configuration_descriptor_t config_descriptor; 136 opResult = usb_request_get_bare_configuration_descriptor( 137 &hub->endpoints.control, 0, 138 &config_descriptor); 139 if(opResult!=EOK){ 140 dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult); 141 return opResult; 142 } 143 //set configuration 144 opResult = usb_request_set_configuration(&hub->endpoints.control, 145 config_descriptor.configuration_number); 146 147 if (opResult != EOK) { 148 dprintf(USB_LOG_LEVEL_ERROR, 149 "something went wrong when setting hub`s configuration, %d", 150 opResult); 151 return opResult; 152 } 153 dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d", 154 config_descriptor.configuration_number); 155 156 //full configuration descriptor 157 size_t transferred = 0; 158 uint8_t * descriptors = (uint8_t *)malloc(config_descriptor.total_length); 159 if (descriptors == NULL) { 160 dprintf(USB_LOG_LEVEL_ERROR, "insufficient memory"); 161 return ENOMEM; 162 } 163 opResult = usb_request_get_full_configuration_descriptor(&hub->endpoints.control, 164 0, descriptors, 165 config_descriptor.total_length, &transferred); 166 if(opResult!=EOK){ 167 free(descriptors); 168 dprintf(USB_LOG_LEVEL_ERROR, 169 "could not get full configuration descriptor, %d",opResult); 170 return opResult; 171 } 172 if (transferred != config_descriptor.total_length) { 173 dprintf(USB_LOG_LEVEL_ERROR, 174 "received incorrect full configuration descriptor"); 175 return ELIMIT; 176 } 177 178 /** 179 * Initialize the interrupt in endpoint. 180 * \TODO this code should be checked... 181 */ 182 usb_endpoint_mapping_t endpoint_mapping[1] = { 183 { 184 .pipe = &hub->endpoints.status_change, 185 .description = &status_change_endpoint_description, 186 .interface_no = 187 usb_device_get_assigned_interface(hub->device) 188 } 189 }; 190 opResult = usb_endpoint_pipe_initialize_from_configuration( 191 endpoint_mapping, 1, 192 descriptors, config_descriptor.total_length, 193 &hub->device_connection); 194 if (opResult != EOK) { 195 dprintf(USB_LOG_LEVEL_ERROR, 196 "Failed to initialize status change pipe: %s", 197 str_error(opResult)); 198 return opResult; 199 } 200 if (!endpoint_mapping[0].present) { 201 dprintf(USB_LOG_LEVEL_ERROR,"Not accepting device, " \ 202 "cannot understand what is happenning"); 203 return EREFUSED; 204 } 205 206 free(descriptors); 207 return EOK; 208 209 210 // Initialize the interrupt(=status change) endpoint. 211 /*usb_endpoint_pipe_initialize( 212 &result->endpoints->status_change, 213 &result->device_connection, );USB_TRANSFER_INTERRUPT 214 USB_DIRECTION_IN*/ 215 216 } 217 218 219 /** 220 * Create hub representation from device information. 221 * @param device 222 * @return pointer to created structure or NULL in case of error 223 */ 224 usb_hub_info_t * usb_create_hub_info(device_t * device) { 72 225 usb_hub_info_t* result = usb_new(usb_hub_info_t); 226 result->device = device; 227 int opResult; 228 opResult = usb_hub_init_communication(result); 229 if(opResult != EOK){ 230 free(result); 231 return NULL; 232 } 233 73 234 //result->device = device; 74 235 result->port_count = -1; 75 /// \TODO is this correct? is the device stored?76 236 result->device = device; 77 237 78 79 dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc); 80 if (hc < 0) { 81 return result; 82 } 83 //get some hub info 84 usb_address_t addr = usb_drv_get_my_address(hc, device); 85 dprintf(USB_LOG_LEVEL_DEBUG, "address of newly created hub = %d", addr); 86 /*if(addr<0){ 87 //return result; 88 89 }*/ 90 91 result->address = addr; 238 //result->usb_device = usb_new(usb_hcd_attached_device_info_t); 239 size_t received_size; 92 240 93 241 // get hub descriptor 94 95 242 dprintf(USB_LOG_LEVEL_DEBUG, "creating serialized descripton"); 96 243 void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE); 97 244 usb_hub_descriptor_t * descriptor; 98 size_t received_size;99 int opResult;100 245 dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction"); 101 102 opResult = usb_ drv_req_get_descriptor(hc, addr,246 usb_endpoint_pipe_start_session(&result->endpoints.control); 247 opResult = usb_request_get_descriptor(&result->endpoints.control, 103 248 USB_REQUEST_TYPE_CLASS, 104 249 USB_DESCTYPE_HUB, 0, 0, serialized_descriptor, 105 250 USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size); 251 usb_endpoint_pipe_end_session(&result->endpoints.control); 106 252 107 253 if (opResult != EOK) { … … 117 263 return result; 118 264 } 265 266 119 267 dprintf(USB_LOG_LEVEL_INFO, "setting port count to %d",descriptor->ports_count); 120 268 result->port_count = descriptor->ports_count; 121 result->attached_devs = (usb_h ub_attached_device_t*)122 malloc((result->port_count+1) * sizeof(usb_h ub_attached_device_t));269 result->attached_devs = (usb_hc_attached_device_t*) 270 malloc((result->port_count+1) * sizeof(usb_hc_attached_device_t)); 123 271 int i; 124 272 for(i=0;i<result->port_count+1;++i){ 125 result->attached_devs[i]. devman_handle=0;273 result->attached_devs[i].handle=0; 126 274 result->attached_devs[i].address=0; 127 275 } … … 138 286 } 139 287 288 /** 289 * Create hub representation and add it into hub list 290 * @param dev 291 * @return 292 */ 140 293 int usb_add_hub_device(device_t *dev) { 141 294 dprintf(USB_LOG_LEVEL_INFO, "add_hub_device(handle=%d)", (int) dev->handle); 142 295 143 /*144 * We are some (probably deeply nested) hub.145 * Thus, assign our own operations and explore already146 * connected devices.147 */148 296 dev->ops = &hub_device_ops; 149 297 150 //create the hub structure 151 //get hc connection 152 int hc = usb_drv_hc_connect_auto(dev, 0); 153 if (hc < 0) { 154 return hc; 155 } 156 157 usb_hub_info_t * hub_info = usb_create_hub_info(dev, hc); 298 usb_hub_info_t * hub_info = usb_create_hub_info(dev); 299 300 int opResult; 301 302 //perform final configurations 303 usb_endpoint_pipe_start_session(&hub_info->endpoints.control); 304 // process descriptors 305 opResult = usb_hub_process_configuration_descriptors(hub_info); 306 if(opResult != EOK){ 307 dprintf(USB_LOG_LEVEL_ERROR,"could not get condiguration descriptors, %d", 308 opResult); 309 return opResult; 310 } 311 //power ports 312 usb_device_request_setup_packet_t request; 158 313 int port; 159 int opResult;160 usb_target_t target;161 target.address = hub_info->address;162 target.endpoint = 0;163 164 //get configuration descriptor165 // this is not fully correct - there are more configurations166 // and all should be checked167 usb_standard_device_descriptor_t std_descriptor;168 opResult = usb_drv_req_get_device_descriptor(hc, target.address,169 &std_descriptor);170 if(opResult!=EOK){171 dprintf(USB_LOG_LEVEL_ERROR, "could not get device descriptor, %d",opResult);172 return opResult;173 }174 dprintf(USB_LOG_LEVEL_INFO, "hub has %d configurations",std_descriptor.configuration_count);175 if(std_descriptor.configuration_count<1){176 dprintf(USB_LOG_LEVEL_ERROR, "THERE ARE NO CONFIGURATIONS AVAILABLE");177 //shouldn`t I return?178 }179 /// \TODO check other configurations180 usb_standard_configuration_descriptor_t config_descriptor;181 opResult = usb_drv_req_get_bare_configuration_descriptor(hc,182 target.address, 0,183 &config_descriptor);184 if(opResult!=EOK){185 dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult);186 return opResult;187 }188 //set configuration189 opResult = usb_drv_req_set_configuration(hc, target.address,190 config_descriptor.configuration_number);191 192 if (opResult != EOK) {193 dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when setting hub`s configuration, %d", opResult);194 }195 196 usb_device_request_setup_packet_t request;197 314 for (port = 1; port < hub_info->port_count+1; ++port) { 198 315 usb_hub_set_power_port_request(&request, port); 199 opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0); 316 opResult = usb_endpoint_pipe_control_write(&hub_info->endpoints.control, 317 &request,sizeof(usb_device_request_setup_packet_t), NULL, 0); 200 318 dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port); 201 319 if (opResult != EOK) { … … 204 322 } 205 323 //ports powered, hub seems to be enabled 206 207 async_hangup(hc); 324 usb_endpoint_pipe_end_session(&hub_info->endpoints.control); 208 325 209 326 //add the hub to list … … 215 332 //(void)hub_info; 216 333 usb_hub_check_hub_changes(); 217 218 334 219 220 335 dprintf(USB_LOG_LEVEL_INFO, "hub dev added"); 336 //address is lost... 221 337 dprintf(USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ", 222 hub_info->address,338 //hub_info->endpoints.control., 223 339 hub_info->port_count); 224 dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",config_descriptor.configuration_number);225 340 226 341 return EOK; … … 236 351 237 352 /** 238 * Convenience function for releasing default address and writing debug info239 * (these few lines are used too often to be written again and again).240 * @param hc241 * @return242 */243 inline static int usb_hub_release_default_address(int hc){244 int opResult;245 dprintf(USB_LOG_LEVEL_INFO, "releasing default address");246 opResult = usb_drv_release_default_address(hc);247 if (opResult != EOK) {248 dprintf(USB_LOG_LEVEL_WARNING, "failed to release default address");249 }250 return opResult;251 }252 253 /**254 353 * Reset the port with new device and reserve the default address. 255 354 * @param hc … … 257 356 * @param target 258 357 */ 259 static void usb_hub_init_add_device( int hc, uint16_t port, usb_target_t target) {358 static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port) { 260 359 usb_device_request_setup_packet_t request; 261 360 int opResult; 262 361 dprintf(USB_LOG_LEVEL_INFO, "some connection changed"); 362 assert(hub->endpoints.control.hc_phone); 263 363 //get default address 264 opResult = usb_drv_reserve_default_address(hc); 364 //opResult = usb_drv_reserve_default_address(hc); 365 opResult = usb_hc_reserve_default_address(&hub->connection, USB_SPEED_LOW); 366 265 367 if (opResult != EOK) { 266 368 dprintf(USB_LOG_LEVEL_WARNING, "cannot assign default address, it is probably used"); … … 269 371 //reset port 270 372 usb_hub_set_reset_port_request(&request, port); 271 opResult = usb_ drv_sync_control_write(272 hc, target,273 &request, 373 opResult = usb_endpoint_pipe_control_write( 374 &hub->endpoints.control, 375 &request,sizeof(usb_device_request_setup_packet_t), 274 376 NULL, 0 275 377 ); 276 378 if (opResult != EOK) { 277 379 dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when reseting a port"); 278 usb_hub_release_default_address(hc); 380 //usb_hub_release_default_address(hc); 381 usb_hc_release_default_address(&hub->connection); 279 382 } 280 383 } … … 287 390 */ 288 391 static void usb_hub_finalize_add_device( usb_hub_info_t * hub, 289 int hc, uint16_t port, usb_target_t target) {392 uint16_t port) { 290 393 291 394 int opResult; 292 395 dprintf(USB_LOG_LEVEL_INFO, "finalizing add device"); 293 opResult = usb_hub_clear_port_feature( hc, target.address,396 opResult = usb_hub_clear_port_feature(&hub->endpoints.control, 294 397 port, USB_HUB_FEATURE_C_PORT_RESET); 398 295 399 if (opResult != EOK) { 296 400 dprintf(USB_LOG_LEVEL_ERROR, "failed to clear port reset feature"); 297 usb_hub_release_default_address(hc); 298 return; 299 } 300 301 /* Request address at from host controller. */ 302 usb_address_t new_device_address = usb_drv_request_address(hc); 401 usb_hc_release_default_address(&hub->connection); 402 return; 403 } 404 //create connection to device 405 usb_endpoint_pipe_t new_device_pipe; 406 usb_device_connection_t new_device_connection; 407 usb_device_connection_initialize_on_default_address( 408 &new_device_connection, 409 &hub->connection 410 ); 411 usb_endpoint_pipe_initialize_default_control( 412 &new_device_pipe, 413 &new_device_connection); 414 /// \TODO get highspeed info 415 416 417 418 419 420 /* Request address from host controller. */ 421 usb_address_t new_device_address = usb_hc_request_address( 422 &hub->connection, 423 USB_SPEED_LOW/// \TODO fullspeed?? 424 ); 303 425 if (new_device_address < 0) { 304 426 dprintf(USB_LOG_LEVEL_ERROR, "failed to get free USB address"); 305 427 opResult = new_device_address; 306 usb_h ub_release_default_address(hc);428 usb_hc_release_default_address(&hub->connection); 307 429 return; 308 430 } 309 431 dprintf(USB_LOG_LEVEL_INFO, "setting new address %d",new_device_address); 310 opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 311 new_device_address); 432 //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 433 // new_device_address); 434 opResult = usb_request_set_address(&new_device_pipe,new_device_address); 312 435 313 436 if (opResult != EOK) { 314 437 dprintf(USB_LOG_LEVEL_ERROR, "could not set address for new device"); 315 usb_hub_release_default_address(hc); 316 return; 317 } 318 319 320 opResult = usb_hub_release_default_address(hc); 438 usb_hc_release_default_address(&hub->connection); 439 return; 440 } 441 442 443 //opResult = usb_hub_release_default_address(hc); 444 opResult = usb_hc_release_default_address(&hub->connection); 321 445 if(opResult!=EOK){ 322 446 return; 323 447 } 324 448 325 devman_handle_t hc_handle;326 opResult = usb_drv_find_hc(hub->device, &hc_handle);327 if (opResult != EOK) {328 usb_log_error("Failed to get handle of host controller: %s.\n",329 str_error(opResult));330 return;331 }332 333 449 devman_handle_t child_handle; 334 opResult = usb_device_register_child_in_devman(new_device_address, 335 hc_handle, hub->device, &child_handle); 450 //?? 451 opResult = usb_device_register_child_in_devman(new_device_address, 452 hub->connection.hc_handle, hub->device, &child_handle); 453 336 454 if (opResult != EOK) { 337 455 dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device"); 338 456 return; 339 457 } 340 hub->attached_devs[port]. devman_handle = child_handle;458 hub->attached_devs[port].handle = child_handle; 341 459 hub->attached_devs[port].address = new_device_address; 342 460 343 opResult = usb_drv_bind_address(hc, new_device_address, child_handle); 461 //opResult = usb_drv_bind_address(hc, new_device_address, child_handle); 462 opResult = usb_hc_register_device( 463 &hub->connection, 464 &hub->attached_devs[port]); 344 465 if (opResult != EOK) { 345 466 dprintf(USB_LOG_LEVEL_ERROR, "could not assign address of device in hcd"); … … 358 479 */ 359 480 static void usb_hub_removed_device( 360 usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {481 usb_hub_info_t * hub,uint16_t port) { 361 482 //usb_device_request_setup_packet_t request; 362 483 int opResult; … … 365 486 * devide manager 366 487 */ 367 368 hub->attached_devs[port].devman_handle=0; 488 369 489 //close address 370 490 if(hub->attached_devs[port].address!=0){ 371 opResult = usb_drv_release_address(hc,hub->attached_devs[port].address); 491 //opResult = usb_drv_release_address(hc,hub->attached_devs[port].address); 492 opResult = usb_hc_unregister_device( 493 &hub->connection, hub->attached_devs[port].address); 372 494 if(opResult != EOK) { 373 495 dprintf(USB_LOG_LEVEL_WARNING, "could not release address of " \ … … 375 497 } 376 498 hub->attached_devs[port].address = 0; 499 hub->attached_devs[port].handle = 0; 377 500 }else{ 378 501 dprintf(USB_LOG_LEVEL_WARNING, "this is strange, disconnected device had no address"); 379 502 //device was disconnected before it`s port was reset - return default address 380 usb_drv_release_default_address(hc); 503 //usb_drv_release_default_address(hc); 504 usb_hc_release_default_address(&hub->connection); 381 505 } 382 506 } … … 388 512 * @param target 389 513 */ 390 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,391 uint16_t port , usb_address_t address) {514 static void usb_hub_process_interrupt(usb_hub_info_t * hub, 515 uint16_t port) { 392 516 dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port); 393 517 //determine type of change 518 usb_endpoint_pipe_t *pipe = &hub->endpoints.control; 519 int opResult = usb_endpoint_pipe_start_session(pipe); 520 521 if(opResult != EOK){ 522 dprintf(USB_LOG_LEVEL_ERROR, "cannot open pipe %d", opResult); 523 } 524 525 /* 394 526 usb_target_t target; 395 527 target.address=address; 396 528 target.endpoint=0; 529 */ 530 397 531 usb_port_status_t status; 398 532 size_t rcvd_size; 399 533 usb_device_request_setup_packet_t request; 400 int opResult;534 //int opResult; 401 535 usb_hub_set_port_status_request(&request, port); 402 536 //endpoint 0 403 537 404 opResult = usb_ drv_sync_control_read(405 hc, target,406 &request, 538 opResult = usb_endpoint_pipe_control_read( 539 pipe, 540 &request, sizeof(usb_device_request_setup_packet_t), 407 541 &status, 4, &rcvd_size 408 542 ); … … 417 551 //something connected/disconnected 418 552 if (usb_port_connect_change(&status)) { 419 opResult = usb_hub_clear_port_feature( hc, target.address,553 opResult = usb_hub_clear_port_feature(pipe, 420 554 port, USB_HUB_FEATURE_C_PORT_CONNECTION); 421 555 // TODO: check opResult 422 556 if (usb_port_dev_connected(&status)) { 423 557 dprintf(USB_LOG_LEVEL_INFO, "some connection changed"); 424 usb_hub_init_add_device(h c, port, target);558 usb_hub_init_add_device(hub, port); 425 559 } else { 426 usb_hub_removed_device(hub, hc, port, target);560 usb_hub_removed_device(hub, port); 427 561 } 428 562 } … … 431 565 dprintf(USB_LOG_LEVEL_INFO, "port reset complete"); 432 566 if (usb_port_enabled(&status)) { 433 usb_hub_finalize_add_device(hub, hc, port, target);567 usb_hub_finalize_add_device(hub, port); 434 568 } else { 435 569 dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled"); … … 447 581 /// \TODO handle other changes 448 582 /// \TODO debug log for various situations 583 usb_endpoint_pipe_end_session(pipe); 584 449 585 450 586 } … … 464 600 fibril_mutex_unlock(&usb_hub_list_lock); 465 601 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data); 602 int opResult; 603 604 opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change); 605 if(opResult != EOK){ 606 continue; 607 } 466 608 /* 467 609 * Check status change pipe of this hub. 468 610 */ 469 611 /* 470 612 usb_target_t target; 471 613 target.address = hub_info->address; … … 473 615 dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d", 474 616 target.address); 475 617 */ 476 618 size_t port_count = hub_info->port_count; 477 619 478 620 /* 479 621 * Connect to respective HC. 480 * /622 * 481 623 int hc = usb_drv_hc_connect_auto(hub_info->device, 0); 482 624 if (hc < 0) { 483 625 continue; 484 } 626 }*/ 485 627 486 628 /// FIXME: count properly … … 489 631 void *change_bitmap = malloc(byte_length); 490 632 size_t actual_size; 491 usb_handle_t handle;633 //usb_handle_t handle; 492 634 493 635 /* 494 636 * Send the request. 495 637 */ 496 int opResult = usb_drv_async_interrupt_in(hc, target, 497 change_bitmap, byte_length, &actual_size, 498 &handle); 499 500 usb_drv_async_wait_for(handle); 638 opResult = usb_endpoint_pipe_read( 639 &hub_info->endpoints.status_change, 640 change_bitmap, byte_length, &actual_size 641 ); 642 643 //usb_drv_async_wait_for(handle); 501 644 502 645 if (opResult != EOK) { … … 511 654 if (interrupt) { 512 655 usb_hub_process_interrupt( 513 hub_info, hc, port, hub_info->address);656 hub_info, port); 514 657 } 515 658 } 659 usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change); 516 660 free(change_bitmap); 517 518 async_hangup(hc); 661 662 663 //async_hangup(hc); 519 664 fibril_mutex_lock(&usb_hub_list_lock); 520 665 } -
uspace/drv/usbhub/usbhub.h
rfb78ae72 rdeece2f 42 42 #define NAME "usbhub" 43 43 44 /** basic information about device attached to hub */ 45 typedef struct{ 46 usb_address_t address; 47 devman_handle_t devman_handle; 48 }usb_hub_attached_device_t; 44 #include <usb/hub.h> 45 46 #include <usb/pipes.h> 47 48 /* Hub endpoints. */ 49 typedef struct { 50 usb_endpoint_pipe_t control; 51 usb_endpoint_pipe_t status_change; 52 } usb_hub_endpoints_t; 53 54 49 55 50 56 /** Information about attached hub. */ … … 52 58 /** Number of ports. */ 53 59 int port_count; 54 /** attached device handles */55 usb_h ub_attached_device_t * attached_devs;56 /** USB address of the hub. */57 usb_address_t address;60 /** attached device handles, for each port one */ 61 usb_hc_attached_device_t * attached_devs; 62 /** General usb device info. */ 63 //usb_hcd_attached_device_info_t * usb_device; 58 64 /** General device info*/ 59 65 device_t * device; 66 /** connection to hcd */ 67 //usb_device_connection_t connection; 68 usb_hc_connection_t connection; 69 /** */ 70 usb_device_connection_t device_connection; 71 /** hub endpoints */ 72 usb_hub_endpoints_t endpoints; 60 73 } usb_hub_info_t; 61 74 -
uspace/drv/usbhub/usbhub_private.h
rfb78ae72 rdeece2f 45 45 #include <fibril_synch.h> 46 46 47 #include <usb/classes/hub.h> 47 48 #include <usb/usb.h> 48 #include <usb/usbdrv.h>49 #include <usb/classes/hub.h>50 #include <usb/devreq.h>51 49 #include <usb/debug.h> 50 #include <usb/request.h> 52 51 53 52 //************ … … 77 76 * @return 78 77 */ 79 usb_hub_info_t * usb_create_hub_info(device_t * device , int hc);78 usb_hub_info_t * usb_create_hub_info(device_t * device); 80 79 81 80 /** List of hubs maanged by this driver */ … … 98 97 * @return error code 99 98 */ 99 /* 100 100 int usb_drv_sync_control_read( 101 int phone, usb_target_t target,101 usb_endpoint_pipe_t *pipe, 102 102 usb_device_request_setup_packet_t * request, 103 103 void * rcvd_buffer, size_t rcvd_size, size_t * actual_size 104 ); 104 );*/ 105 105 106 106 /** … … 115 115 * @return error code 116 116 */ 117 int usb_drv_sync_control_write(118 int phone, usb_target_t target,117 /*int usb_drv_sync_control_write( 118 usb_endpoint_pipe_t *pipe, 119 119 usb_device_request_setup_packet_t * request, 120 120 void * sent_buffer, size_t sent_size 121 ); 121 );*/ 122 122 123 123 /** … … 147 147 * @return Operation result 148 148 */ 149 static inline int usb_hub_clear_port_feature( int hc, usb_address_t address,149 static inline int usb_hub_clear_port_feature(usb_endpoint_pipe_t *pipe, 150 150 int port_index, 151 151 usb_hub_class_feature_t feature) { 152 usb_target_t target = { 153 .address = address, 154 .endpoint = 0 155 }; 152 156 153 usb_device_request_setup_packet_t clear_request = { 157 154 .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE, … … 161 158 }; 162 159 clear_request.value = feature; 163 return usb_ drv_psync_control_write(hc, target, &clear_request,160 return usb_endpoint_pipe_control_write(pipe, &clear_request, 164 161 sizeof(clear_request), NULL, 0); 165 162 } -
uspace/drv/usbhub/utils.c
rfb78ae72 rdeece2f 38 38 39 39 #include <usbhc_iface.h> 40 #include <usb/usbdrv.h>41 40 #include <usb/descriptor.h> 42 #include <usb/devreq.h>43 41 #include <usb/classes/hub.h> 44 42 … … 114 112 115 113 //control transactions 116 114 /* 117 115 int usb_drv_sync_control_read( 118 116 int phone, usb_target_t target, … … 199 197 } 200 198 201 199 */ 202 200 203 201 -
uspace/drv/vhc/conn.h
rfb78ae72 rdeece2f 38 38 #include <usb/usb.h> 39 39 #include <usbhc_iface.h> 40 #include <usb_iface.h> 40 41 #include "vhcd.h" 41 42 #include "devices.h" … … 43 44 void connection_handler_host(sysarg_t); 44 45 45 usbhc_iface_t vhc_iface; 46 extern usbhc_iface_t vhc_iface; 47 extern usb_iface_t vhc_usb_iface; 46 48 47 49 void address_init(void); -
uspace/drv/vhc/connhost.c
rfb78ae72 rdeece2f 37 37 #include <usb/usb.h> 38 38 #include <usb/addrkeep.h> 39 #include <usb/ddfiface.h> 39 40 40 41 #include "vhcd.h" … … 313 314 static usb_address_keeping_t addresses; 314 315 316 static int tell_address(device_t *dev, devman_handle_t handle, 317 usb_address_t *address) 318 { 319 usb_address_t addr = usb_address_keeping_find(&addresses, handle); 320 if (addr < 0) { 321 return addr; 322 } 323 324 *address = addr; 325 return EOK; 326 } 315 327 316 328 static int reserve_default_address(device_t *dev, usb_speed_t ignored) … … 350 362 } 351 363 352 static int tell_address(device_t *dev, devman_handle_t handle,353 usb_address_t *address)354 {355 usb_address_t addr = usb_address_keeping_find(&addresses, handle);356 if (addr < 0) {357 return addr;358 }359 360 *address = addr;361 return EOK;362 }363 364 364 void address_init(void) 365 365 { … … 368 368 369 369 usbhc_iface_t vhc_iface = { 370 .tell_address = tell_address,371 372 370 .reserve_default_address = reserve_default_address, 373 371 .release_default_address = release_default_address, … … 383 381 }; 384 382 383 usb_iface_t vhc_usb_iface = { 384 .get_hc_handle = usb_iface_get_hc_handle_hc_impl, 385 .get_address = tell_address 386 }; 387 388 385 389 /** 386 390 * @} -
uspace/drv/vhc/hcd.c
rfb78ae72 rdeece2f 45 45 46 46 #include <usb/usb.h> 47 #include <usb/ddfiface.h> 47 48 #include <usb_iface.h> 48 49 #include "vhcd.h" … … 52 53 #include "conn.h" 53 54 54 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)55 {56 /* This shall be called only for VHC device. */57 assert(dev->parent == NULL);58 59 *handle = dev->handle;60 return EOK;61 }62 63 static usb_iface_t hc_usb_iface = {64 .get_hc_handle = usb_iface_get_hc_handle65 };66 67 55 static device_ops_t vhc_ops = { 68 56 .interfaces[USBHC_DEV_IFACE] = &vhc_iface, 69 .interfaces[USB_DEV_IFACE] = & hc_usb_iface,57 .interfaces[USB_DEV_IFACE] = &vhc_usb_iface, 70 58 .close = on_client_close, 71 59 .default_handler = default_connection_handler -
uspace/drv/vhc/hub.c
rfb78ae72 rdeece2f 40 40 #include <stdlib.h> 41 41 #include <driver.h> 42 #include <usb/ usbdrv.h>42 #include <usb/hub.h> 43 43 #include <usb/recognise.h> 44 44 … … 71 71 } 72 72 73 static int pretend_port_rest(int unused, void *unused2) 74 { 75 return EOK; 76 } 77 73 78 /** Register root hub in devman. 74 79 * … … 80 85 device_t *hc_dev = (device_t *) arg; 81 86 82 int hc; 87 /* 88 * Wait until parent device is properly initialized. 89 */ 90 int phone; 83 91 do { 84 hc = usb_drv_hc_connect(hc_dev, hc_dev->handle,85 IPC_FLAG_BLOCKING);86 } while (hc < 0);92 phone = devman_device_connect(hc_dev->handle, 0); 93 } while (phone < 0); 94 async_hangup(phone); 87 95 88 usb_drv_reserve_default_address(hc); 96 usb_hc_connection_t hc_conn; 97 usb_hc_connection_initialize(&hc_conn, hc_dev->handle); 89 98 90 usb_address_t hub_address = usb_drv_request_address(hc); 91 usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, hub_address); 99 usb_hc_connection_open(&hc_conn); 92 100 93 usb_drv_release_default_address(hc); 101 int rc = usb_hc_new_device_wrapper(hc_dev, &hc_conn, USB_SPEED_FULL, 102 pretend_port_rest, 0, NULL, 103 NULL, NULL); 104 if (rc != EOK) { 105 usb_log_fatal("Failed to create root hub: %s.\n", 106 str_error(rc)); 107 } 94 108 95 devman_handle_t hub_handle; 96 usb_device_register_child_in_devman(hub_address, hc_dev->handle, 97 hc_dev, &hub_handle); 98 //usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle); 99 usb_drv_bind_address(hc, hub_address, hub_handle); 109 usb_hc_connection_close(&hc_conn); 100 110 101 return EOK;111 return 0; 102 112 } 103 113 -
uspace/drv/vhc/hub/hub.c
rfb78ae72 rdeece2f 40 40 #include <stdlib.h> 41 41 #include <driver.h> 42 #include <usb/usbdrv.h>43 42 44 43 #include "hub.h" -
uspace/drv/vhc/hub/virthub.c
rfb78ae72 rdeece2f 41 41 #include <stdlib.h> 42 42 #include <driver.h> 43 #include <usb/usbdrv.h>44 43 45 44 #include "virthub.h" -
uspace/lib/drv/generic/remote_usb.c
rfb78ae72 rdeece2f 40 40 41 41 42 static void remote_usb_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 43 static void remote_usb_get_interface(device_t *, void *, ipc_callid_t, ipc_call_t *); 42 44 static void remote_usb_get_hc_handle(device_t *, void *, ipc_callid_t, ipc_call_t *); 43 45 //static void remote_usb(device_t *, void *, ipc_callid_t, ipc_call_t *); … … 45 47 /** Remote USB interface operations. */ 46 48 static remote_iface_func_ptr_t remote_usb_iface_ops [] = { 49 remote_usb_get_address, 50 remote_usb_get_interface, 47 51 remote_usb_get_hc_handle 48 52 }; … … 56 60 }; 57 61 62 63 void remote_usb_get_address(device_t *device, void *iface, 64 ipc_callid_t callid, ipc_call_t *call) 65 { 66 usb_iface_t *usb_iface = (usb_iface_t *) iface; 67 68 if (usb_iface->get_address == NULL) { 69 async_answer_0(callid, ENOTSUP); 70 return; 71 } 72 73 devman_handle_t handle = DEV_IPC_GET_ARG1(*call); 74 75 usb_address_t address; 76 int rc = usb_iface->get_address(device, handle, &address); 77 if (rc != EOK) { 78 async_answer_0(callid, rc); 79 } else { 80 async_answer_1(callid, EOK, address); 81 } 82 } 83 84 void remote_usb_get_interface(device_t *device, void *iface, 85 ipc_callid_t callid, ipc_call_t *call) 86 { 87 usb_iface_t *usb_iface = (usb_iface_t *) iface; 88 89 if (usb_iface->get_interface == NULL) { 90 async_answer_0(callid, ENOTSUP); 91 return; 92 } 93 94 devman_handle_t handle = DEV_IPC_GET_ARG1(*call); 95 96 int iface_no; 97 int rc = usb_iface->get_interface(device, handle, &iface_no); 98 if (rc != EOK) { 99 async_answer_0(callid, rc); 100 } else { 101 async_answer_1(callid, EOK, iface_no); 102 } 103 } 58 104 59 105 void remote_usb_get_hc_handle(device_t *device, void *iface, -
uspace/lib/drv/generic/remote_usbhc.c
rfb78ae72 rdeece2f 43 43 #define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 4 44 44 45 static void remote_usbhc_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *);46 45 static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 47 46 static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *); 47 static void remote_usbhc_bulk_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 48 static void remote_usbhc_bulk_in(device_t *, void *, ipc_callid_t, ipc_call_t *); 48 49 static void remote_usbhc_control_write(device_t *, void *, ipc_callid_t, ipc_call_t *); 49 50 static void remote_usbhc_control_read(device_t *, void *, ipc_callid_t, ipc_call_t *); … … 57 58 /** Remote USB host controller interface operations. */ 58 59 static remote_iface_func_ptr_t remote_usbhc_iface_ops [] = { 59 remote_usbhc_get_address,60 61 60 remote_usbhc_reserve_default_address, 62 61 remote_usbhc_release_default_address, … … 68 67 remote_usbhc_interrupt_out, 69 68 remote_usbhc_interrupt_in, 69 70 remote_usbhc_bulk_out, 71 remote_usbhc_bulk_in, 70 72 71 73 remote_usbhc_control_write, … … 121 123 } 122 124 123 void remote_usbhc_get_address(device_t *device, void *iface,124 ipc_callid_t callid, ipc_call_t *call)125 {126 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;127 128 if (!usb_iface->tell_address) {129 async_answer_0(callid, ENOTSUP);130 return;131 }132 133 devman_handle_t handle = DEV_IPC_GET_ARG1(*call);134 135 usb_address_t address;136 int rc = usb_iface->tell_address(device, handle, &address);137 if (rc != EOK) {138 async_answer_0(callid, rc);139 } else {140 async_answer_1(callid, EOK, address);141 }142 }143 144 125 void remote_usbhc_reserve_default_address(device_t *device, void *iface, 145 126 ipc_callid_t callid, ipc_call_t *call) … … 389 370 return remote_usbhc_in_transfer(device, callid, call, 390 371 usb_iface->interrupt_in); 372 } 373 374 void remote_usbhc_bulk_out(device_t *device, void *iface, 375 ipc_callid_t callid, ipc_call_t *call) 376 { 377 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 378 assert(usb_iface != NULL); 379 380 return remote_usbhc_out_transfer(device, callid, call, 381 usb_iface->bulk_out); 382 } 383 384 void remote_usbhc_bulk_in(device_t *device, void *iface, 385 ipc_callid_t callid, ipc_call_t *call) 386 { 387 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 388 assert(usb_iface != NULL); 389 390 return remote_usbhc_in_transfer(device, callid, call, 391 usb_iface->bulk_in); 391 392 } 392 393 -
uspace/lib/drv/include/usb_iface.h
rfb78ae72 rdeece2f 41 41 #include <usb/usb.h> 42 42 typedef enum { 43 /** Tell USB address assigned to device. 44 * Parameters: 45 * - devman handle id 46 * Answer: 47 * - EINVAL - unknown handle or handle not managed by this driver 48 * - ENOTSUP - operation not supported (shall not happen) 49 * - arbitrary error code if returned by remote implementation 50 * - EOK - handle found, first parameter contains the USB address 51 */ 52 IPC_M_USB_GET_ADDRESS, 53 54 /** Tell interface number given device can use. 55 * Parameters 56 * - devman handle id of the device 57 * Answer: 58 * - ENOTSUP - operation not supported (can also mean any interface) 59 * - EOK - operation okay, first parameter contains interface number 60 */ 61 IPC_M_USB_GET_INTERFACE, 62 43 63 /** Tell devman handle of device host controller. 44 64 * Parameters: … … 55 75 /** USB device communication interface. */ 56 76 typedef struct { 77 int (*get_address)(device_t *, devman_handle_t, usb_address_t *); 78 int (*get_interface)(device_t *, devman_handle_t, int *); 57 79 int (*get_hc_handle)(device_t *, devman_handle_t *); 58 80 } usb_iface_t; -
uspace/lib/drv/include/usbhc_iface.h
rfb78ae72 rdeece2f 85 85 */ 86 86 typedef enum { 87 /** Tell USB address assigned to device.88 * Parameters:89 * - devman handle id90 * Answer:91 * - EINVAL - unknown handle or handle not managed by this driver92 * - ENOTSUP - operation not supported by HC (shall not happen)93 * - arbitrary error code if returned by remote implementation94 * - EOK - handle found, first parameter contains the USB address95 */96 IPC_M_USBHC_GET_ADDRESS,97 98 99 87 /** Reserve usage of default address. 100 88 * This call informs the host controller that the caller will be … … 153 141 IPC_M_USBHC_INTERRUPT_IN, 154 142 143 /** Send bulk data to device. 144 * See explanation at usb_iface_funcs_t (OUT transaction). 145 */ 146 IPC_M_USBHC_BULK_OUT, 147 148 /** Get bulk data from device. 149 * See explanation at usb_iface_funcs_t (IN transaction). 150 */ 151 IPC_M_USBHC_BULK_IN, 152 155 153 /** Issue control WRITE transfer. 156 154 * See explanation at usb_iface_funcs_t (OUT transaction) for … … 196 194 /** USB host controller communication interface. */ 197 195 typedef struct { 198 int (*tell_address)(device_t *, devman_handle_t, usb_address_t *);199 200 196 int (*reserve_default_address)(device_t *, usb_speed_t); 201 197 int (*release_default_address)(device_t *); … … 207 203 usbhc_iface_transfer_in_t interrupt_in; 208 204 205 usbhc_iface_transfer_out_t bulk_out; 206 usbhc_iface_transfer_in_t bulk_in; 207 209 208 int (*control_write)(device_t *, usb_target_t, 210 209 size_t, -
uspace/lib/usb/Makefile
rfb78ae72 rdeece2f 35 35 src/addrkeep.c \ 36 36 src/class.c \ 37 src/ddfiface.c \ 37 38 src/debug.c \ 38 39 src/dp.c \ 39 src/drvpsync.c \40 40 src/dump.c \ 41 41 src/hidparser.c \ … … 48 48 src/usb.c \ 49 49 src/usbdevice.c \ 50 src/usbdrvreq.c \51 src/usbdrv.c \52 50 src/usbmem.c 53 51 -
uspace/lib/usb/include/usb/classes/hub.h
rfb78ae72 rdeece2f 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/dp.h
rfb78ae72 rdeece2f 45 45 } usb_dp_descriptor_nesting_t; 46 46 47 extern usb_dp_descriptor_nesting_t usb_dp_standard_descriptor_nesting[]; 48 47 49 typedef struct { 48 50 usb_dp_descriptor_nesting_t *nesting; -
uspace/lib/usb/include/usb/pipes.h
rfb78ae72 rdeece2f 107 107 /** Endpoint description. */ 108 108 const usb_endpoint_description_t *description; 109 /** Interface number the endpoint must belong to (-1 for any). */ 110 const int interface_no; 109 111 /** Found descriptor fitting the description. */ 110 112 usb_standard_endpoint_descriptor_t *descriptor; … … 121 123 int usb_device_connection_initialize(usb_device_connection_t *, 122 124 devman_handle_t, usb_address_t); 125 126 int usb_device_get_assigned_interface(device_t *); 123 127 124 128 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *, -
uspace/lib/usb/include/usb/recognise.h
rfb78ae72 rdeece2f 41 41 #include <ipc/devman.h> 42 42 43 int usb_device_create_match_ids_from_device_descriptor( 44 const usb_standard_device_descriptor_t *, match_id_list_t *); 45 46 int usb_device_create_match_ids_from_interface( 47 const usb_standard_device_descriptor_t *, 48 const usb_standard_interface_descriptor_t *, match_id_list_t *); 49 43 50 int usb_device_create_match_ids(usb_endpoint_pipe_t *, match_id_list_t *); 44 51 -
uspace/lib/usb/include/usb/request.h
rfb78ae72 rdeece2f 41 41 #include <usb/descriptor.h> 42 42 43 /** Standard device request. */ 44 typedef enum { 45 USB_DEVREQ_GET_STATUS = 0, 46 USB_DEVREQ_CLEAR_FEATURE = 1, 47 USB_DEVREQ_SET_FEATURE = 3, 48 USB_DEVREQ_SET_ADDRESS = 5, 49 USB_DEVREQ_GET_DESCRIPTOR = 6, 50 USB_DEVREQ_SET_DESCRIPTOR = 7, 51 USB_DEVREQ_GET_CONFIGURATION = 8, 52 USB_DEVREQ_SET_CONFIGURATION = 9, 53 USB_DEVREQ_GET_INTERFACE = 10, 54 USB_DEVREQ_SET_INTERFACE = 11, 55 USB_DEVREQ_SYNCH_FRAME = 12, 56 USB_DEVREQ_LAST_STD 57 } usb_stddevreq_t; 58 59 /** Device request setup packet. 60 * The setup packet describes the request. 61 */ 62 typedef struct { 63 /** Request type. 64 * The type combines transfer direction, request type and 65 * intended recipient. 66 */ 67 uint8_t request_type; 68 /** Request identification. */ 69 uint8_t request; 70 /** Main parameter to the request. */ 71 union { 72 uint16_t value; 73 /* FIXME: add #ifdefs according to host endianess */ 74 struct { 75 uint8_t value_low; 76 uint8_t value_high; 77 }; 78 }; 79 /** Auxiliary parameter to the request. 80 * Typically, it is offset to something. 81 */ 82 uint16_t index; 83 /** Length of extra data. */ 84 uint16_t length; 85 } __attribute__ ((packed)) usb_device_request_setup_packet_t; 86 43 87 int usb_control_request_set(usb_endpoint_pipe_t *, 44 88 usb_request_type_t, usb_request_recipient_t, uint8_t, -
uspace/lib/usb/src/dp.c
rfb78ae72 rdeece2f 37 37 #include <str_error.h> 38 38 #include <errno.h> 39 #include < usb/usbdrv.h>39 #include <assert.h> 40 40 #include <bool.h> 41 41 #include <usb/dp.h> 42 #include <usb/descriptor.h> 43 44 #define NESTING(parentname, childname) \ 45 { \ 46 .child = USB_DESCTYPE_##childname, \ 47 .parent = USB_DESCTYPE_##parentname, \ 48 } 49 #define LAST_NESTING { -1, -1 } 50 51 /** Nesting of standard USB descriptors. */ 52 usb_dp_descriptor_nesting_t usb_dp_standard_descriptor_nesting[] = { 53 NESTING(CONFIGURATION, INTERFACE), 54 NESTING(INTERFACE, ENDPOINT), 55 NESTING(INTERFACE, HUB), 56 NESTING(INTERFACE, HID), 57 NESTING(HID, HID_REPORT), 58 LAST_NESTING 59 }; 60 61 #undef NESTING 62 #undef LAST_NESTING 42 63 43 64 /** Tells whether pointer points inside descriptor data. -
uspace/lib/usb/src/hub.c
rfb78ae72 rdeece2f 301 301 } 302 302 303 304 303 /** 305 304 * @} -
uspace/lib/usb/src/pipes.c
rfb78ae72 rdeece2f 36 36 #include <usb/pipes.h> 37 37 #include <usbhc_iface.h> 38 #include <usb_iface.h> 38 39 #include <errno.h> 39 40 #include <assert.h> … … 41 42 /** Tell USB address assigned to given device. 42 43 * 43 * @param phone Phone to my HC.44 * @param phone Phone to parent device. 44 45 * @param dev Device in question. 45 46 * @return USB address or error code. … … 48 49 { 49 50 sysarg_t address; 50 int rc = async_req_2_1(phone, DEV_IFACE_ID(USB HC_DEV_IFACE),51 IPC_M_USB HC_GET_ADDRESS,51 int rc = async_req_2_1(phone, DEV_IFACE_ID(USB_DEV_IFACE), 52 IPC_M_USB_GET_ADDRESS, 52 53 dev->handle, &address); 53 54 … … 57 58 58 59 return (usb_address_t) address; 60 } 61 62 /** Tell USB interface assigned to given device. 63 * 64 * @param device Device in question. 65 * @return Interface number (negative code means any). 66 */ 67 int usb_device_get_assigned_interface(device_t *device) 68 { 69 int parent_phone = devman_parent_device_connect(device->handle, 70 IPC_FLAG_BLOCKING); 71 if (parent_phone < 0) { 72 return -1; 73 } 74 75 sysarg_t iface_no; 76 int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE), 77 IPC_M_USB_GET_INTERFACE, 78 device->handle, &iface_no); 79 80 async_hangup(parent_phone); 81 82 if (rc != EOK) { 83 return -1; 84 } 85 86 return (int) iface_no; 59 87 } 60 88 … … 80 108 } 81 109 82 int hc_phone = devman_device_connect(hc_handle, 0); 83 if (hc_phone < 0) { 84 return hc_phone; 85 } 86 87 my_address = get_my_address(hc_phone, device); 110 int parent_phone = devman_parent_device_connect(device->handle, 111 IPC_FLAG_BLOCKING); 112 if (parent_phone < 0) { 113 return parent_phone; 114 } 115 116 my_address = get_my_address(parent_phone, device); 88 117 if (my_address < 0) { 89 118 rc = my_address; … … 95 124 96 125 leave: 97 async_hangup( hc_phone);126 async_hangup(parent_phone); 98 127 return rc; 99 128 } -
uspace/lib/usb/src/pipesinit.c
rfb78ae72 rdeece2f 109 109 * @param mapping_count Number of endpoint mappings in @p mapping. 110 110 * @param found_endpoint Description of found endpoint. 111 * @param interface_number Number of currently processed interface. 111 112 * @return Endpoint mapping corresponding to @p found_endpoint. 112 113 * @retval NULL No corresponding endpoint found. … … 114 115 static usb_endpoint_mapping_t *find_endpoint_mapping( 115 116 usb_endpoint_mapping_t *mapping, size_t mapping_count, 116 usb_endpoint_description_t *found_endpoint) 117 usb_endpoint_description_t *found_endpoint, 118 int interface_number) 117 119 { 118 120 while (mapping_count > 0) { 119 if (endpoint_fits_description(mapping->description, 120 found_endpoint)) { 121 bool interface_number_fits = (mapping->interface_no < 0) 122 || (mapping->interface_no == interface_number); 123 124 bool endpoint_descriptions_fits = endpoint_fits_description( 125 mapping->description, found_endpoint); 126 127 if (interface_number_fits && endpoint_descriptions_fits) { 121 128 return mapping; 122 129 } … … 169 176 */ 170 177 usb_endpoint_mapping_t *ep_mapping = find_endpoint_mapping(mapping, 171 mapping_count, &description );178 mapping_count, &description, interface->interface_number); 172 179 if (ep_mapping == NULL) { 173 180 return ENOENT; -
uspace/lib/usb/src/pipesio.c
rfb78ae72 rdeece2f 71 71 ipc_method = IPC_M_USBHC_INTERRUPT_IN; 72 72 break; 73 case USB_TRANSFER_BULK: 74 ipc_method = IPC_M_USBHC_BULK_IN; 75 break; 73 76 default: 74 77 return ENOTSUP; … … 194 197 case USB_TRANSFER_INTERRUPT: 195 198 ipc_method = IPC_M_USBHC_INTERRUPT_OUT; 199 break; 200 case USB_TRANSFER_BULK: 201 ipc_method = IPC_M_USBHC_BULK_OUT; 196 202 break; 197 203 default: -
uspace/lib/usb/src/recognise.c
rfb78ae72 rdeece2f 34 34 */ 35 35 #include <sys/types.h> 36 #include <usb_iface.h>37 #include <usb/usbdrv.h>38 36 #include <usb/pipes.h> 39 37 #include <usb/recognise.h> 38 #include <usb/ddfiface.h> 40 39 #include <usb/request.h> 41 40 #include <usb/classes/classes.h> … … 46 45 static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex); 47 46 48 /** Callback for getting host controller handle.49 *50 * @param dev Device in question.51 * @param[out] handle Devman handle of the host controller.52 * @return Error code.53 */54 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)55 {56 assert(dev);57 assert(dev->parent != NULL);58 59 device_t *parent = dev->parent;60 61 if (parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {62 usb_iface_t *usb_iface63 = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];64 assert(usb_iface != NULL);65 if (usb_iface->get_hc_handle) {66 int rc = usb_iface->get_hc_handle(parent, handle);67 return rc;68 }69 }70 71 return ENOTSUP;72 }73 74 static usb_iface_t usb_iface = {75 .get_hc_handle = usb_iface_get_hc_handle76 };77 78 47 device_ops_t child_ops = { 79 .interfaces[USB_DEV_IFACE] = &usb_iface 48 .interfaces[USB_DEV_IFACE] = &usb_iface_hub_child_impl 80 49 }; 81 50 … … 142 111 } 143 112 113 #define ADD_MATCHID_OR_RETURN(match_ids, score, format, ...) \ 114 do { \ 115 int __rc = usb_add_match_id((match_ids), (score), \ 116 format, ##__VA_ARGS__); \ 117 if (__rc != EOK) { \ 118 return __rc; \ 119 } \ 120 } while (0) 121 122 /** Create device match ids based on its interface. 123 * 124 * @param[in] descriptor Interface descriptor. 125 * @param[out] matches Initialized list of match ids. 126 * @return Error code (the two mentioned are not the only ones). 127 * @retval EINVAL Invalid input parameters (expects non NULL pointers). 128 * @retval ENOENT Interface does not specify class. 129 */ 130 int usb_device_create_match_ids_from_interface( 131 const usb_standard_device_descriptor_t *desc_device, 132 const usb_standard_interface_descriptor_t *desc_interface, 133 match_id_list_t *matches) 134 { 135 if (desc_interface == NULL) { 136 return EINVAL; 137 } 138 if (matches == NULL) { 139 return EINVAL; 140 } 141 142 if (desc_interface->interface_class == USB_CLASS_USE_INTERFACE) { 143 return ENOENT; 144 } 145 146 const char *classname = usb_str_class(desc_interface->interface_class); 147 assert(classname != NULL); 148 149 #define IFACE_PROTOCOL_FMT "interface&class=%s&subclass=0x%02x&protocol=0x%02x" 150 #define IFACE_PROTOCOL_ARGS classname, desc_interface->interface_subclass, \ 151 desc_interface->interface_protocol 152 153 #define IFACE_SUBCLASS_FMT "interface&class=%s&subclass=0x%02x" 154 #define IFACE_SUBCLASS_ARGS classname, desc_interface->interface_subclass 155 156 #define IFACE_CLASS_FMT "interface&class=%s" 157 #define IFACE_CLASS_ARGS classname 158 159 #define VENDOR_RELEASE_FMT "vendor=0x%04x&product=0x%04x&release=" BCD_FMT 160 #define VENDOR_RELEASE_ARGS desc_device->vendor_id, desc_device->product_id, \ 161 BCD_ARGS(desc_device->device_version) 162 163 #define VENDOR_PRODUCT_FMT "vendor=0x%04x&product=0x%04x" 164 #define VENDOR_PRODUCT_ARGS desc_device->vendor_id, desc_device->product_id 165 166 #define VENDOR_ONLY_FMT "vendor=0x%04x" 167 #define VENDOR_ONLY_ARGS desc_device->vendor_id 168 169 /* 170 * If the vendor is specified, create match ids with vendor with 171 * higher score. 172 * Then the same ones without the vendor part. 173 */ 174 if ((desc_device != NULL) && (desc_device->vendor_id != 0)) { 175 /* First, interface matches with device release number. */ 176 ADD_MATCHID_OR_RETURN(matches, 250, 177 "usb&" VENDOR_RELEASE_FMT "&" IFACE_PROTOCOL_FMT, 178 VENDOR_RELEASE_ARGS, IFACE_PROTOCOL_ARGS); 179 ADD_MATCHID_OR_RETURN(matches, 240, 180 "usb&" VENDOR_RELEASE_FMT "&" IFACE_SUBCLASS_FMT, 181 VENDOR_RELEASE_ARGS, IFACE_SUBCLASS_ARGS); 182 ADD_MATCHID_OR_RETURN(matches, 230, 183 "usb&" VENDOR_RELEASE_FMT "&" IFACE_CLASS_FMT, 184 VENDOR_RELEASE_ARGS, IFACE_CLASS_ARGS); 185 186 /* Next, interface matches without release number. */ 187 ADD_MATCHID_OR_RETURN(matches, 220, 188 "usb&" VENDOR_PRODUCT_FMT "&" IFACE_PROTOCOL_FMT, 189 VENDOR_PRODUCT_ARGS, IFACE_PROTOCOL_ARGS); 190 ADD_MATCHID_OR_RETURN(matches, 210, 191 "usb&" VENDOR_PRODUCT_FMT "&" IFACE_SUBCLASS_FMT, 192 VENDOR_PRODUCT_ARGS, IFACE_SUBCLASS_ARGS); 193 ADD_MATCHID_OR_RETURN(matches, 200, 194 "usb&" VENDOR_PRODUCT_FMT "&" IFACE_CLASS_FMT, 195 VENDOR_PRODUCT_ARGS, IFACE_CLASS_ARGS); 196 197 /* Finally, interface matches with only vendor. */ 198 ADD_MATCHID_OR_RETURN(matches, 190, 199 "usb&" VENDOR_ONLY_FMT "&" IFACE_PROTOCOL_FMT, 200 VENDOR_ONLY_ARGS, IFACE_PROTOCOL_ARGS); 201 ADD_MATCHID_OR_RETURN(matches, 180, 202 "usb&" VENDOR_ONLY_FMT "&" IFACE_SUBCLASS_FMT, 203 VENDOR_ONLY_ARGS, IFACE_SUBCLASS_ARGS); 204 ADD_MATCHID_OR_RETURN(matches, 170, 205 "usb&" VENDOR_ONLY_FMT "&" IFACE_CLASS_FMT, 206 VENDOR_ONLY_ARGS, IFACE_CLASS_ARGS); 207 } 208 209 /* Now, the same but without any vendor specification. */ 210 ADD_MATCHID_OR_RETURN(matches, 160, 211 "usb&" IFACE_PROTOCOL_FMT, 212 IFACE_PROTOCOL_ARGS); 213 ADD_MATCHID_OR_RETURN(matches, 150, 214 "usb&" IFACE_SUBCLASS_FMT, 215 IFACE_SUBCLASS_ARGS); 216 ADD_MATCHID_OR_RETURN(matches, 140, 217 "usb&" IFACE_CLASS_FMT, 218 IFACE_CLASS_ARGS); 219 220 #undef IFACE_PROTOCOL_FMT 221 #undef IFACE_PROTOCOL_ARGS 222 #undef IFACE_SUBCLASS_FMT 223 #undef IFACE_SUBCLASS_ARGS 224 #undef IFACE_CLASS_FMT 225 #undef IFACE_CLASS_ARGS 226 #undef VENDOR_RELEASE_FMT 227 #undef VENDOR_RELEASE_ARGS 228 #undef VENDOR_PRODUCT_FMT 229 #undef VENDOR_PRODUCT_ARGS 230 #undef VENDOR_ONLY_FMT 231 #undef VENDOR_ONLY_ARGS 232 233 return EOK; 234 } 235 144 236 /** Create DDF match ids from USB device descriptor. 145 237 * … … 148 240 * @return Error code. 149 241 */ 150 int usb_d rv_create_match_ids_from_device_descriptor(151 match_id_list_t *matches,152 const usb_standard_device_descriptor_t *device_descriptor)242 int usb_device_create_match_ids_from_device_descriptor( 243 const usb_standard_device_descriptor_t *device_descriptor, 244 match_id_list_t *matches) 153 245 { 154 int rc;155 156 246 /* 157 247 * Unless the vendor id is 0, the pair idVendor-idProduct … … 160 250 if (device_descriptor->vendor_id != 0) { 161 251 /* First, with release number. */ 162 rc = usb_add_match_id(matches, 100,252 ADD_MATCHID_OR_RETURN(matches, 100, 163 253 "usb&vendor=0x%04x&product=0x%04x&release=" BCD_FMT, 164 254 (int) device_descriptor->vendor_id, 165 255 (int) device_descriptor->product_id, 166 256 BCD_ARGS(device_descriptor->device_version)); 167 if (rc != EOK) {168 return rc;169 }170 257 171 258 /* Next, without release number. */ 172 rc = usb_add_match_id(matches, 90,259 ADD_MATCHID_OR_RETURN(matches, 90, 173 260 "usb&vendor=0x%04x&product=0x%04x", 174 261 (int) device_descriptor->vendor_id, 175 262 (int) device_descriptor->product_id); 176 if (rc != EOK) {177 return rc;178 }179 263 } 180 264 181 265 /* 182 266 * If the device class points to interface we skip adding 183 * class directly .267 * class directly but we add a multi interface device. 184 268 */ 185 269 if (device_descriptor->device_class != USB_CLASS_USE_INTERFACE) { 186 rc = usb_add_match_id(matches, 50, "usb&class=%s",270 ADD_MATCHID_OR_RETURN(matches, 50, "usb&class=%s", 187 271 usb_str_class(device_descriptor->device_class)); 188 if (rc != EOK) { 189 return rc; 190 } 272 } else { 273 ADD_MATCHID_OR_RETURN(matches, 50, "usb&mid"); 191 274 } 192 275 … … 194 277 } 195 278 196 /** Create DDF match ids from USB configuration descriptor.197 * The configuration descriptor is expected to be in the complete form,198 * i.e. including interface, endpoint etc. descriptors.199 *200 * @param matches List of match ids to extend.201 * @param config_descriptor Configuration descriptor returned by given device.202 * @param total_size Size of the @p config_descriptor.203 * @return Error code.204 */205 int usb_drv_create_match_ids_from_configuration_descriptor(206 match_id_list_t *matches,207 const void *config_descriptor, size_t total_size)208 {209 /*210 * Iterate through config descriptor to find the interface211 * descriptors.212 */213 size_t position = sizeof(usb_standard_configuration_descriptor_t);214 while (position + 1 < total_size) {215 uint8_t *current_descriptor216 = ((uint8_t *) config_descriptor) + position;217 uint8_t cur_descr_len = current_descriptor[0];218 uint8_t cur_descr_type = current_descriptor[1];219 220 if (cur_descr_len == 0) {221 return ENOENT;222 }223 224 position += cur_descr_len;225 226 if (cur_descr_type != USB_DESCTYPE_INTERFACE) {227 continue;228 }229 230 /*231 * Finally, we found an interface descriptor.232 */233 usb_standard_interface_descriptor_t *interface234 = (usb_standard_interface_descriptor_t *)235 current_descriptor;236 237 int rc = usb_add_match_id(matches, 50,238 "usb&interface&class=%s",239 usb_str_class(interface->interface_class));240 if (rc != EOK) {241 return rc;242 }243 }244 245 return EOK;246 }247 248 /** Add match ids based on configuration descriptor.249 *250 * @param pipe Control pipe to the device.251 * @param matches Match ids list to add matches to.252 * @param config_count Number of configurations the device has.253 * @return Error code.254 */255 static int usb_add_config_descriptor_match_ids(usb_endpoint_pipe_t *pipe,256 match_id_list_t *matches, int config_count)257 {258 int final_rc = EOK;259 260 int config_index;261 for (config_index = 0; config_index < config_count; config_index++) {262 int rc;263 usb_standard_configuration_descriptor_t config_descriptor;264 rc = usb_request_get_bare_configuration_descriptor(pipe,265 config_index, &config_descriptor);266 if (rc != EOK) {267 final_rc = rc;268 continue;269 }270 271 size_t full_config_descriptor_size;272 void *full_config_descriptor273 = malloc(config_descriptor.total_length);274 rc = usb_request_get_full_configuration_descriptor(pipe,275 config_index,276 full_config_descriptor, config_descriptor.total_length,277 &full_config_descriptor_size);278 if (rc != EOK) {279 final_rc = rc;280 continue;281 }282 if (full_config_descriptor_size283 != config_descriptor.total_length) {284 final_rc = ERANGE;285 continue;286 }287 288 rc = usb_drv_create_match_ids_from_configuration_descriptor(289 matches,290 full_config_descriptor, full_config_descriptor_size);291 if (rc != EOK) {292 final_rc = rc;293 continue;294 }295 296 }297 298 return final_rc;299 }300 279 301 280 /** Create match ids describing attached device. … … 323 302 } 324 303 325 rc = usb_d rv_create_match_ids_from_device_descriptor(matches,326 &device_descriptor );304 rc = usb_device_create_match_ids_from_device_descriptor( 305 &device_descriptor, matches); 327 306 if (rc != EOK) { 328 307 return rc; … … 330 309 331 310 /* 332 * Go through all configurations and add matches333 * based on interface class.334 */335 rc = usb_add_config_descriptor_match_ids(ctrl_pipe, matches,336 device_descriptor.configuration_count);337 if (rc != EOK) {338 return rc;339 }340 341 /*342 311 * As a fallback, provide the simplest match id possible. 343 312 */ 344 rc = usb_add_match_id(matches, 1, "usb&fallback"); 345 if (rc != EOK) { 346 return rc; 347 } 313 ADD_MATCHID_OR_RETURN(matches, 1, "usb&fallback"); 348 314 349 315 return EOK; -
uspace/lib/usb/src/request.c
rfb78ae72 rdeece2f 34 34 */ 35 35 #include <usb/request.h> 36 #include <usb/devreq.h>37 36 #include <errno.h> 38 37 -
uspace/lib/usbvirt/Makefile
rfb78ae72 rdeece2f 30 30 LIBRARY = libusbvirt 31 31 32 EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I include32 EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBDRV_PREFIX)/include -Iinclude 33 33 34 34 SOURCES = \ -
uspace/lib/usbvirt/include/usbvirt/device.h
rfb78ae72 rdeece2f 37 37 38 38 #include <usb/usb.h> 39 #include <usb/request.h> 39 40 #include <usb/descriptor.h> 40 #include <usb/devreq.h>41 41 42 42 /** Request type of a control transfer. */ -
uspace/lib/usbvirt/src/stdreq.c
rfb78ae72 rdeece2f 36 36 #include <stdlib.h> 37 37 #include <mem.h> 38 #include <usb/ devreq.h>38 #include <usb/request.h> 39 39 40 40 #include "private.h"
Note:
See TracChangeset
for help on using the changeset viewer.