Changes in / [67b6fc5:e0df6c2] in mainline
- Location:
- uspace
- Files:
-
- 2 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/info.c
r67b6fc5 re0df6c2 39 39 #include <usb/usbdrv.h> 40 40 #include <usb/pipes.h> 41 #include <usb/recognise.h>42 41 #include <usb/request.h> 43 42 #include "usbinfo.h" … … 48 47 usb_device_connection_t wire; 49 48 usb_endpoint_pipe_t ctrl_pipe; 49 ctrl_pipe.hc_phone = -1; 50 51 int hc_phone = devman_device_connect(hc_handle, 0); 52 if (hc_phone < 0) { 53 fprintf(stderr, 54 NAME ": failed to connect to host controller (%zu): %s.\n", 55 (size_t) hc_handle, str_error(hc_phone)); 56 return hc_phone; 57 } 58 59 /* 60 * Dump information about possible match ids. 61 */ 62 match_id_list_t match_id_list; 63 init_match_ids(&match_id_list); 64 rc = usb_drv_create_device_match_ids(hc_phone, &match_id_list, address); 65 if (rc != EOK) { 66 fprintf(stderr, 67 NAME ": failed to fetch match ids of the device: %s.\n", 68 str_error(rc)); 69 goto leave; 70 } 71 dump_match_ids(&match_id_list); 50 72 51 73 /* … … 73 95 goto leave; 74 96 } 75 76 /*77 * Dump information about possible match ids.78 */79 match_id_list_t match_id_list;80 init_match_ids(&match_id_list);81 rc = usb_device_create_match_ids(&ctrl_pipe, &match_id_list);82 if (rc != EOK) {83 fprintf(stderr,84 NAME ": failed to fetch match ids of the device: %s.\n",85 str_error(rc));86 goto leave;87 }88 dump_match_ids(&match_id_list);89 97 90 98 /* … … 133 141 leave: 134 142 /* Ignoring errors here. */ 143 async_hangup(hc_phone); 135 144 usb_endpoint_pipe_end_session(&ctrl_pipe); 136 145 -
uspace/drv/uhci-hcd/uhci.h
r67b6fc5 re0df6c2 72 72 73 73 #define UHCI_FRAME_LIST_COUNT 1024 74 #define UHCI_CLEANER_TIMEOUT 10000 74 #define UHCI_CLEANER_TIMEOUT 1000000 75 75 #define UHCI_DEBUGER_TIMEOUT 5000000 76 76 -
uspace/drv/uhci-rhd/port.c
r67b6fc5 re0df6c2 33 33 */ 34 34 #include <errno.h> 35 #include <str_error.h>36 35 37 36 #include <usb/usb.h> /* usb_address_t */ 38 37 #include <usb/usbdrv.h> /* usb_drv_* */ 39 38 #include <usb/debug.h> 40 #include <usb/recognise.h>41 39 42 40 #include "port.h" … … 206 204 assert(port->attached_device == 0); 207 205 208 devman_handle_t hc_handle; 209 ret = usb_drv_find_hc(port->rh, &hc_handle); 210 if (ret != EOK) { 211 usb_log_error("Failed to get handle of host controller: %s.\n", 212 str_error(ret)); 213 uhci_port_set_enabled(port, false); 214 return ENOMEM; 215 } 216 217 ret = usb_device_register_child_in_devman(usb_address, hc_handle, 218 port->rh, &port->attached_device); 206 ret = usb_drv_register_child_in_devman(port->hc_phone, port->rh, 207 usb_address, &port->attached_device); 208 219 209 if (ret != EOK) { /* something went wrong */ 220 210 usb_log_error("Failed(%d) in usb_drv_register_child.\n", ret); -
uspace/drv/usbhid/main.c
r67b6fc5 re0df6c2 45 45 #include <str_error.h> 46 46 #include <fibril.h> 47 #include <usb/debug.h>48 #include <usb/classes/classes.h>49 47 #include <usb/classes/hid.h> 50 48 #include <usb/classes/hidparser.h> … … 63 61 #define GUESSED_POLL_ENDPOINT 1 64 62 65 /** Keyboard polling endpoint description for boot protocol class. */66 static usb_endpoint_description_t poll_endpoint_description = {67 .transfer_type = USB_TRANSFER_INTERRUPT,68 .direction = USB_DIRECTION_IN,69 .interface_class = USB_CLASS_HID,70 .interface_subclass = USB_HID_SUBCLASS_BOOT,71 .interface_protocol = USB_HID_PROTOCOL_KEYBOARD,72 .flags = 073 };74 75 63 static void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *); 76 64 static device_ops_t keyboard_ops = { … … 342 330 } 343 331 344 /*345 * Initialize the interrupt in endpoint.346 */347 usb_endpoint_mapping_t endpoint_mapping[1] = {348 {349 .pipe = &kbd_dev->poll_pipe,350 .description = &poll_endpoint_description351 }352 };353 rc = usb_endpoint_pipe_initialize_from_configuration(354 endpoint_mapping, 1,355 descriptors, config_desc.total_length,356 &kbd_dev->wire);357 if (rc != EOK) {358 usb_log_error("Failed to initialize poll pipe: %s.\n",359 str_error(rc));360 return rc;361 }362 if (!endpoint_mapping[0].present) {363 usb_log_warning("Not accepting device, " \364 "not boot-protocol keyboard.\n");365 return EREFUSED;366 }367 368 369 370 371 332 kbd_dev->conf = (usb_hid_configuration_t *)calloc(1, 372 333 sizeof(usb_hid_configuration_t)); … … 376 337 } 377 338 378 /*rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf);339 rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf); 379 340 free(descriptors); 380 341 if (rc != EOK) { … … 383 344 } 384 345 385 // get and report descriptors */346 // get and report descriptors 386 347 rc = usbkbd_get_report_descriptor(kbd_dev); 387 348 if (rc != EOK) { … … 400 361 * as the endpoint for polling 401 362 */ 402 363 403 364 return EOK; 404 365 } … … 435 396 if (rc != EOK) { 436 397 printf("Failed to initialize default control pipe: %s.\n", 398 str_error(rc)); 399 goto error_leave; 400 } 401 402 rc = usb_endpoint_pipe_initialize(&kbd_dev->poll_pipe, &kbd_dev->wire, 403 GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, USB_DIRECTION_IN); 404 if (rc != EOK) { 405 printf("Failed to initialize interrupt in pipe: %s.\n", 437 406 str_error(rc)); 438 407 goto error_leave; … … 449 418 usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe); 450 419 //usb_request_set_configuration(&kbd_dev->ctrl_pipe, 1); 451 rc =usbkbd_process_descriptors(kbd_dev);420 usbkbd_process_descriptors(kbd_dev); 452 421 usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe); 453 if (rc != EOK) {454 goto error_leave;455 }456 422 457 423 return kbd_dev; … … 611 577 int main(int argc, char *argv[]) 612 578 { 613 usb_log_enable(USB_LOG_LEVEL_INFO, "usbhid");614 579 return driver_main(&kbd_driver); 615 580 } -
uspace/drv/usbhub/usbhub.c
r67b6fc5 re0df6c2 36 36 #include <bool.h> 37 37 #include <errno.h> 38 #include <str_error.h>39 38 40 39 #include <usb_iface.h> 41 40 #include <usb/usbdrv.h> 42 41 #include <usb/descriptor.h> 43 #include <usb/recognise.h>44 42 #include <usb/devreq.h> 45 43 #include <usb/classes/hub.h> … … 319 317 } 320 318 321 devman_handle_t hc_handle;322 opResult = usb_drv_find_hc(hub->device, &hc_handle);323 if (opResult != EOK) {324 usb_log_error("Failed to get handle of host controller: %s.\n",325 str_error(opResult));326 return;327 }328 329 319 devman_handle_t child_handle; 330 opResult = usb_device_register_child_in_devman(new_device_address,331 hc_handle, hub->device, &child_handle);320 opResult = usb_drv_register_child_in_devman(hc, hub->device, 321 new_device_address, &child_handle); 332 322 if (opResult != EOK) { 333 323 dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device"); -
uspace/drv/vhc/hub.c
r67b6fc5 re0df6c2 41 41 #include <driver.h> 42 42 #include <usb/usbdrv.h> 43 #include <usb/recognise.h>44 43 45 44 #include "hub.h" … … 94 93 95 94 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); 95 usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle); 99 96 usb_drv_bind_address(hc, hub_address, hub_handle); 100 97 -
uspace/lib/usb/Makefile
r67b6fc5 re0df6c2 44 44 src/localdrv.c \ 45 45 src/pipes.c \ 46 src/pipesinit.c \47 46 src/recognise.c \ 48 47 src/remotedrv.c \ -
uspace/lib/usb/include/usb/classes/hid.h
r67b6fc5 re0df6c2 50 50 USB_HIDREQ_SET_PROTOCOL = 11 51 51 } usb_hid_request_t; 52 53 /** USB/HID subclass constants. */54 typedef enum {55 USB_HID_SUBCLASS_NONE = 0,56 USB_HID_SUBCLASS_BOOT = 157 } usb_hid_subclass_t;58 52 59 53 /** USB/HID interface protocols. */ -
uspace/lib/usb/include/usb/pipes.h
r67b6fc5 re0df6c2 38 38 #include <sys/types.h> 39 39 #include <usb/usb.h> 40 #include <usb/descriptor.h>41 40 #include <ipc/devman.h> 42 41 #include <driver.h> … … 74 73 usb_direction_t direction; 75 74 76 /** Maximum packet size for the endpoint. */77 size_t max_packet_size;78 79 75 /** Phone to the host controller. 80 76 * Negative when no session is active. … … 83 79 } usb_endpoint_pipe_t; 84 80 85 86 /** Description of endpoint characteristics. */87 typedef struct {88 /** Transfer type (e.g. control or interrupt). */89 usb_transfer_type_t transfer_type;90 /** Transfer direction (to or from a device). */91 usb_direction_t direction;92 /** Interface class this endpoint belongs to (-1 for any). */93 int interface_class;94 /** Interface subclass this endpoint belongs to (-1 for any). */95 int interface_subclass;96 /** Interface protocol this endpoint belongs to (-1 for any). */97 int interface_protocol;98 /** Extra endpoint flags. */99 unsigned int flags;100 } usb_endpoint_description_t;101 102 /** Mapping of endpoint pipes and endpoint descriptions. */103 typedef struct {104 /** Endpoint pipe. */105 usb_endpoint_pipe_t *pipe;106 /** Endpoint description. */107 const usb_endpoint_description_t *description;108 /** Found descriptor fitting the description. */109 usb_standard_endpoint_descriptor_t *descriptor;110 /** Interface the endpoint belongs to. */111 usb_standard_interface_descriptor_t *interface;112 /** Whether the endpoint was actually found. */113 bool present;114 } usb_endpoint_mapping_t;115 81 116 82 int usb_device_connection_initialize_from_device(usb_device_connection_t *, … … 121 87 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *, 122 88 usb_device_connection_t *, 123 usb_endpoint_t, usb_transfer_type_t, size_t,usb_direction_t);89 usb_endpoint_t, usb_transfer_type_t, usb_direction_t); 124 90 int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *, 125 91 usb_device_connection_t *); 126 int usb_endpoint_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,127 size_t, uint8_t *, size_t, usb_device_connection_t *);128 92 129 93 -
uspace/lib/usb/include/usb/usbdrv.h
r67b6fc5 re0df6c2 106 106 const void *, size_t); 107 107 108 int usb_drv_create_device_match_ids(int, match_id_list_t *, usb_address_t); 109 int usb_drv_register_child_in_devman(int, device_t *, usb_address_t, 110 devman_handle_t *); 111 108 112 109 113 #endif -
uspace/lib/usb/src/pipes.c
r67b6fc5 re0df6c2 123 123 * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15). 124 124 * @param transfer_type Transfer type (e.g. interrupt or bulk). 125 * @param max_packet_size Maximum packet size in bytes.126 125 * @param direction Endpoint direction (in/out). 127 126 * @return Error code. … … 129 128 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *pipe, 130 129 usb_device_connection_t *connection, usb_endpoint_t endpoint_no, 131 usb_transfer_type_t transfer_type, size_t max_packet_size, 132 usb_direction_t direction) 130 usb_transfer_type_t transfer_type, usb_direction_t direction) 133 131 { 134 132 assert(pipe); … … 139 137 pipe->endpoint_no = endpoint_no; 140 138 pipe->transfer_type = transfer_type; 141 pipe->max_packet_size = max_packet_size;142 139 pipe->direction = direction; 143 140 … … 159 156 160 157 int rc = usb_endpoint_pipe_initialize(pipe, connection, 161 0, USB_TRANSFER_CONTROL, 8,USB_DIRECTION_BOTH);158 0, USB_TRANSFER_CONTROL, USB_DIRECTION_BOTH); 162 159 163 160 return rc; -
uspace/lib/usb/src/recognise.c
r67b6fc5 re0df6c2 36 36 #include <usb_iface.h> 37 37 #include <usb/usbdrv.h> 38 #include <usb/pipes.h>39 #include <usb/recognise.h>40 #include <usb/request.h>41 38 #include <usb/classes/classes.h> 42 39 #include <stdio.h> 43 40 #include <errno.h> 44 45 static size_t device_name_index = 0;46 static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);47 41 48 42 /** Callback for getting host controller handle. … … 161 155 /* First, with release number. */ 162 156 rc = usb_add_match_id(matches, 100, 163 "usb&vendor= 0x%04x&product=0x%04x&release=" BCD_FMT,157 "usb&vendor=%d&product=%d&release=" BCD_FMT, 164 158 (int) device_descriptor->vendor_id, 165 159 (int) device_descriptor->product_id, … … 170 164 171 165 /* Next, without release number. */ 172 rc = usb_add_match_id(matches, 90, 173 "usb&vendor=0x%04x&product=0x%04x", 166 rc = usb_add_match_id(matches, 90, "usb&vendor=%d&product=%d", 174 167 (int) device_descriptor->vendor_id, 175 168 (int) device_descriptor->product_id); … … 248 241 /** Add match ids based on configuration descriptor. 249 242 * 250 * @param pipe Control pipe to the device.243 * @param hc Open phone to host controller. 251 244 * @param matches Match ids list to add matches to. 245 * @param address USB address of the attached device. 252 246 * @param config_count Number of configurations the device has. 253 247 * @return Error code. 254 248 */ 255 static int usb_add_config_descriptor_match_ids(usb_endpoint_pipe_t *pipe, 256 match_id_list_t *matches, int config_count) 249 static int usb_add_config_descriptor_match_ids(int hc, 250 match_id_list_t *matches, usb_address_t address, 251 int config_count) 257 252 { 258 253 int final_rc = EOK; … … 262 257 int rc; 263 258 usb_standard_configuration_descriptor_t config_descriptor; 264 rc = usb_ request_get_bare_configuration_descriptor(pipe,265 config_index, &config_descriptor);259 rc = usb_drv_req_get_bare_configuration_descriptor(hc, 260 address, config_index, &config_descriptor); 266 261 if (rc != EOK) { 267 262 final_rc = rc; … … 272 267 void *full_config_descriptor 273 268 = malloc(config_descriptor.total_length); 274 rc = usb_ request_get_full_configuration_descriptor(pipe,275 config_index,269 rc = usb_drv_req_get_full_configuration_descriptor(hc, 270 address, config_index, 276 271 full_config_descriptor, config_descriptor.total_length, 277 272 &full_config_descriptor_size); … … 304 299 * function exits with error. 305 300 * 306 * @param ctrl_pipe Control pipe to given device (session must be already 307 * started). 301 * @param hc Open phone to host controller. 308 302 * @param matches Initialized list of match ids. 309 * @return Error code. 310 */ 311 int usb_device_create_match_ids(usb_endpoint_pipe_t *ctrl_pipe, 312 match_id_list_t *matches) 303 * @param address USB address of the attached device. 304 * @return Error code. 305 */ 306 int usb_drv_create_device_match_ids(int hc, match_id_list_t *matches, 307 usb_address_t address) 313 308 { 314 309 int rc; 310 315 311 /* 316 312 * Retrieve device descriptor and add matches from it. … … 318 314 usb_standard_device_descriptor_t device_descriptor; 319 315 320 rc = usb_request_get_device_descriptor(ctrl_pipe, &device_descriptor); 316 rc = usb_drv_req_get_device_descriptor(hc, address, 317 &device_descriptor); 321 318 if (rc != EOK) { 322 319 return rc; 323 320 } 324 321 325 322 rc = usb_drv_create_match_ids_from_device_descriptor(matches, 326 323 &device_descriptor); … … 328 325 return rc; 329 326 } 330 327 331 328 /* 332 329 * Go through all configurations and add matches 333 330 * based on interface class. 334 331 */ 335 rc = usb_add_config_descriptor_match_ids( ctrl_pipe, matches,336 device_descriptor.configuration_count);332 rc = usb_add_config_descriptor_match_ids(hc, matches, 333 address, device_descriptor.configuration_count); 337 334 if (rc != EOK) { 338 335 return rc; … … 350 347 } 351 348 349 352 350 /** Probe for device kind and register it in devman. 353 351 * 352 * @param[in] hc Open phone to the host controller. 353 * @param[in] parent Parent device. 354 354 * @param[in] address Address of the (unknown) attached device. 355 * @param[in] hc_handle Handle of the host controller.356 * @param[in] parent Parent device.357 355 * @param[out] child_handle Handle of the child device. 358 356 * @return Error code. 359 357 */ 360 int usb_device_register_child_in_devman(usb_address_t address, 361 devman_handle_t hc_handle, 362 device_t *parent, devman_handle_t *child_handle) 363 { 358 int usb_drv_register_child_in_devman(int hc, device_t *parent, 359 usb_address_t address, devman_handle_t *child_handle) 360 { 361 static size_t device_name_index = 0; 362 static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex); 363 364 364 size_t this_device_name_index; 365 365 … … 369 369 fibril_mutex_unlock(&device_name_index_mutex); 370 370 371 371 372 device_t *child = NULL; 372 373 char *child_name = NULL; 373 374 int rc; 374 usb_device_connection_t dev_connection;375 usb_endpoint_pipe_t ctrl_pipe;376 377 rc = usb_device_connection_initialize(&dev_connection, hc_handle, address);378 if (rc != EOK) {379 goto failure;380 }381 382 rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe,383 &dev_connection);384 if (rc != EOK) {385 goto failure;386 }387 375 388 376 child = create_device(); … … 403 391 child->name = child_name; 404 392 child->ops = &child_ops; 405 406 rc = usb_endpoint_pipe_start_session(&ctrl_pipe); 407 if (rc != EOK) { 408 goto failure; 409 } 410 411 rc = usb_device_create_match_ids(&ctrl_pipe, &child->match_ids); 412 if (rc != EOK) { 413 goto failure; 414 } 415 416 rc = usb_endpoint_pipe_end_session(&ctrl_pipe); 393 394 rc = usb_drv_create_device_match_ids(hc, &child->match_ids, address); 417 395 if (rc != EOK) { 418 396 goto failure; … … 427 405 *child_handle = child->handle; 428 406 } 429 407 430 408 return EOK; 431 409 … … 441 419 442 420 return rc; 421 443 422 } 444 423
Note:
See TracChangeset
for help on using the changeset viewer.