Changeset 6e3b9a58 in mainline for uspace/lib
- Timestamp:
- 2011-03-18T14:17:27Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bb41b85
- Parents:
- a8def7d (diff), 4f66cc7b (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/lib
- Files:
-
- 3 added
- 8 edited
-
block/libblock.c (modified) (2 diffs)
-
drv/generic/remote_usbhc.c (modified) (3 diffs)
-
drv/include/usbhc_iface.h (modified) (2 diffs)
-
usb/Makefile (modified) (1 diff)
-
usb/include/usb/devdrv.h (added)
-
usb/include/usb/pipes.h (modified) (2 diffs)
-
usb/src/devdrv.c (added)
-
usb/src/devpoll.c (added)
-
usb/src/hub.c (modified) (1 diff)
-
usb/src/pipesinit.c (modified) (2 diffs)
-
usb/src/recognise.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/libblock.c
ra8def7d r6e3b9a58 411 411 l = hash_table_find(&cache->block_hash, &key); 412 412 if (l) { 413 found: 413 414 /* 414 415 * We found the block in the cache. … … 493 494 fibril_mutex_unlock(&b->lock); 494 495 goto retry; 496 } 497 l = hash_table_find(&cache->block_hash, &key); 498 if (l) { 499 /* 500 * Someone else must have already 501 * instantiated the block while we were 502 * not holding the cache lock. 503 * Leave the recycled block on the 504 * freelist and continue as if we 505 * found the block of interest during 506 * the first try. 507 */ 508 fibril_mutex_unlock(&b->lock); 509 goto found; 495 510 } 496 511 -
uspace/lib/drv/generic/remote_usbhc.c
ra8def7d r6e3b9a58 55 55 static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 56 56 static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 57 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 58 static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 57 59 //static void remote_usbhc(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 58 60 … … 73 75 74 76 remote_usbhc_control_write, 75 remote_usbhc_control_read 77 remote_usbhc_control_read, 78 79 remote_usbhc_register_endpoint, 80 remote_usbhc_unregister_endpoint 76 81 }; 77 82 … … 522 527 523 528 529 void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface, 530 ipc_callid_t callid, ipc_call_t *call) 531 { 532 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 533 534 if (!usb_iface->register_endpoint) { 535 async_answer_0(callid, ENOTSUP); 536 return; 537 } 538 539 #define INIT_FROM_HIGH_DATA(type, var, arg_no) \ 540 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / 256 541 #define INIT_FROM_LOW_DATA(type, var, arg_no) \ 542 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % 256 543 544 INIT_FROM_HIGH_DATA(usb_address_t, address, 1); 545 INIT_FROM_LOW_DATA(usb_endpoint_t, endpoint, 1); 546 INIT_FROM_HIGH_DATA(usb_transfer_type_t, transfer_type, 2); 547 INIT_FROM_LOW_DATA(usb_direction_t, direction, 2); 548 549 #undef INIT_FROM_HIGH_DATA 550 #undef INIT_FROM_LOW_DATA 551 552 size_t max_packet_size = (size_t) DEV_IPC_GET_ARG3(*call); 553 unsigned int interval = (unsigned int) DEV_IPC_GET_ARG4(*call); 554 555 int rc = usb_iface->register_endpoint(fun, address, endpoint, 556 transfer_type, direction, max_packet_size, interval); 557 558 async_answer_0(callid, rc); 559 } 560 561 562 void remote_usbhc_unregister_endpoint(ddf_fun_t *fun, void *iface, 563 ipc_callid_t callid, ipc_call_t *call) 564 { 565 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 566 567 if (!usb_iface->unregister_endpoint) { 568 async_answer_0(callid, ENOTSUP); 569 return; 570 } 571 572 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 573 usb_endpoint_t endpoint = (usb_endpoint_t) DEV_IPC_GET_ARG2(*call); 574 usb_direction_t direction = (usb_direction_t) DEV_IPC_GET_ARG3(*call); 575 576 int rc = usb_iface->unregister_endpoint(fun, 577 address, endpoint, direction); 578 579 async_answer_0(callid, rc); 580 } 581 524 582 525 583 /** -
uspace/lib/drv/include/usbhc_iface.h
ra8def7d r6e3b9a58 167 167 IPC_M_USBHC_CONTROL_READ, 168 168 169 /* IPC_M_USB_ */ 169 /** Register endpoint attributes at host controller. 170 * This is used to reserve portion of USB bandwidth. 171 * Parameters: 172 * - USB address + endpoint number (ADDR * 256 + EP) 173 * - transfer type + direction (TYPE * 256 + DIR) 174 * - maximum packet size 175 * - interval (in milliseconds) 176 * Answer: 177 * - EOK - reservation successful 178 * - ELIMIT - not enough bandwidth to satisfy the request 179 */ 180 IPC_M_USBHC_REGISTER_ENDPOINT, 181 182 /** Revert endpoint registration. 183 * Parameters: 184 * - USB address 185 * - endpoint number 186 * - data direction 187 * Answer: 188 * - EOK - endpoint unregistered 189 * - ENOENT - unknown endpoint 190 */ 191 IPC_M_USBHC_UNREGISTER_ENDPOINT 170 192 } usbhc_iface_funcs_t; 171 193 … … 200 222 int (*release_address)(ddf_fun_t *, usb_address_t); 201 223 224 int (*register_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t, 225 usb_transfer_type_t, usb_direction_t, size_t, unsigned int); 226 int (*unregister_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t, 227 usb_direction_t); 228 202 229 usbhc_iface_transfer_out_t interrupt_out; 203 230 usbhc_iface_transfer_in_t interrupt_in; -
uspace/lib/usb/Makefile
ra8def7d r6e3b9a58 37 37 src/ddfiface.c \ 38 38 src/debug.c \ 39 src/devdrv.c \ 40 src/devpoll.c \ 39 41 src/dp.c \ 40 42 src/dump.c \ -
uspace/lib/usb/include/usb/pipes.h
ra8def7d r6e3b9a58 106 106 const usb_endpoint_description_t *description; 107 107 /** Interface number the endpoint must belong to (-1 for any). */ 108 constint interface_no;108 int interface_no; 109 109 /** Found descriptor fitting the description. */ 110 110 usb_standard_endpoint_descriptor_t *descriptor; … … 129 129 int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *, 130 130 usb_device_connection_t *); 131 int usb_endpoint_pipe_probe_default_control(usb_endpoint_pipe_t *); 131 132 int usb_endpoint_pipe_initialize_from_configuration(usb_endpoint_mapping_t *, 132 133 size_t, uint8_t *, size_t, usb_device_connection_t *); 133 134 int usb_endpoint_pipe_register(usb_endpoint_pipe_t *, unsigned int, 135 usb_hc_connection_t *); 136 int usb_endpoint_pipe_unregister(usb_endpoint_pipe_t *, usb_hc_connection_t *); 134 137 135 138 int usb_endpoint_pipe_start_session(usb_endpoint_pipe_t *); -
uspace/lib/usb/src/hub.c
ra8def7d r6e3b9a58 235 235 goto leave_release_default_address; 236 236 } 237 rc = usb_endpoint_pipe_probe_default_control(&ctrl_pipe); 238 if (rc != EOK) { 239 rc = ENOTCONN; 240 goto leave_release_default_address; 241 } 237 242 238 243 rc = usb_endpoint_pipe_start_session(&ctrl_pipe); -
uspace/lib/usb/src/pipesinit.c
ra8def7d r6e3b9a58 37 37 #include <usb/pipes.h> 38 38 #include <usb/dp.h> 39 #include <usb/request.h> 40 #include <usbhc_iface.h> 39 41 #include <errno.h> 40 42 #include <assert.h> 43 44 #define CTRL_PIPE_MIN_PACKET_SIZE 8 45 #define DEV_DESCR_MAX_PACKET_SIZE_OFFSET 7 41 46 42 47 … … 369 374 370 375 int rc = usb_endpoint_pipe_initialize(pipe, connection, 371 0, USB_TRANSFER_CONTROL, 8, USB_DIRECTION_BOTH); 376 0, USB_TRANSFER_CONTROL, CTRL_PIPE_MIN_PACKET_SIZE, 377 USB_DIRECTION_BOTH); 372 378 373 379 return rc; 380 } 381 382 /** Probe default control pipe for max packet size. 383 * 384 * The function tries to get the correct value of max packet size several 385 * time before giving up. 386 * 387 * The session on the pipe shall not be started. 388 * 389 * @param pipe Default control pipe. 390 * @return Error code. 391 */ 392 int usb_endpoint_pipe_probe_default_control(usb_endpoint_pipe_t *pipe) 393 { 394 assert(pipe); 395 assert(DEV_DESCR_MAX_PACKET_SIZE_OFFSET < CTRL_PIPE_MIN_PACKET_SIZE); 396 397 if ((pipe->direction != USB_DIRECTION_BOTH) || 398 (pipe->transfer_type != USB_TRANSFER_CONTROL) || 399 (pipe->endpoint_no != 0)) { 400 return EINVAL; 401 } 402 403 #define TRY_LOOP(attempt_var) \ 404 for (attempt_var = 0; attempt_var < 3; attempt_var++) 405 406 size_t failed_attempts; 407 int rc; 408 409 TRY_LOOP(failed_attempts) { 410 rc = usb_endpoint_pipe_start_session(pipe); 411 if (rc == EOK) { 412 break; 413 } 414 } 415 if (rc != EOK) { 416 return rc; 417 } 418 419 420 uint8_t dev_descr_start[CTRL_PIPE_MIN_PACKET_SIZE]; 421 size_t transferred_size; 422 TRY_LOOP(failed_attempts) { 423 rc = usb_request_get_descriptor(pipe, USB_REQUEST_TYPE_STANDARD, 424 USB_REQUEST_RECIPIENT_DEVICE, USB_DESCTYPE_DEVICE, 425 0, 0, dev_descr_start, CTRL_PIPE_MIN_PACKET_SIZE, 426 &transferred_size); 427 if (rc == EOK) { 428 if (transferred_size != CTRL_PIPE_MIN_PACKET_SIZE) { 429 rc = ELIMIT; 430 continue; 431 } 432 break; 433 } 434 } 435 usb_endpoint_pipe_end_session(pipe); 436 if (rc != EOK) { 437 return rc; 438 } 439 440 pipe->max_packet_size 441 = dev_descr_start[DEV_DESCR_MAX_PACKET_SIZE_OFFSET]; 442 443 return EOK; 444 } 445 446 /** Register endpoint with the host controller. 447 * 448 * @param pipe Pipe to be registered. 449 * @param interval Polling interval. 450 * @param hc_connection Connection to the host controller (must be opened). 451 * @return Error code. 452 */ 453 int usb_endpoint_pipe_register(usb_endpoint_pipe_t *pipe, 454 unsigned int interval, 455 usb_hc_connection_t *hc_connection) 456 { 457 assert(pipe); 458 assert(hc_connection); 459 460 if (!usb_hc_connection_is_opened(hc_connection)) { 461 return EBADF; 462 } 463 464 #define _PACK(high, low) ((high) * 256 + (low)) 465 466 return async_req_5_0(hc_connection->hc_phone, 467 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_REGISTER_ENDPOINT, 468 _PACK(pipe->wire->address, pipe->endpoint_no), 469 _PACK(pipe->transfer_type, pipe->direction), 470 pipe->max_packet_size, interval); 471 472 #undef _PACK 473 } 474 475 /** Revert endpoint registration with the host controller. 476 * 477 * @param pipe Pipe to be unregistered. 478 * @param hc_connection Connection to the host controller (must be opened). 479 * @return Error code. 480 */ 481 int usb_endpoint_pipe_unregister(usb_endpoint_pipe_t *pipe, 482 usb_hc_connection_t *hc_connection) 483 { 484 assert(pipe); 485 assert(hc_connection); 486 487 if (!usb_hc_connection_is_opened(hc_connection)) { 488 return EBADF; 489 } 490 491 return async_req_4_0(hc_connection->hc_phone, 492 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_UNREGISTER_ENDPOINT, 493 pipe->wire->address, pipe->endpoint_no, pipe->direction); 374 494 } 375 495 -
uspace/lib/usb/src/recognise.c
ra8def7d r6e3b9a58 369 369 goto failure; 370 370 } 371 rc = usb_endpoint_pipe_probe_default_control(&ctrl_pipe); 372 if (rc != EOK) { 373 goto failure; 374 } 371 375 372 376 /* … … 374 378 * naming etc., something more descriptive could be created. 375 379 */ 376 rc = asprintf(&child_name, "usbdev%02zu", this_device_name_index); 380 rc = asprintf(&child_name, "usb%02zu_a%d", 381 this_device_name_index, address); 377 382 if (rc < 0) { 378 383 goto failure;
Note:
See TracChangeset
for help on using the changeset viewer.
