Changeset 1998bcd in mainline
- Timestamp:
- 2011-04-08T22:25:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 98064795
- Parents:
- 297341b
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ehci-hcd/hc_iface.c
r297341b r1998bcd 123 123 * @param[in] fun Device function the action was invoked on. 124 124 * @param[in] address USB address of the device. 125 * @param[in] speed Endpoint speed (invalid means to use device one). 125 126 * @param[in] endpoint Endpoint number. 126 127 * @param[in] transfer_type USB transfer type. … … 131 132 */ 132 133 static int register_endpoint(ddf_fun_t *fun, 133 usb_address_t address, usb_ endpoint_t endpoint,134 usb_address_t address, usb_speed_t speed, usb_endpoint_t endpoint, 134 135 usb_transfer_type_t transfer_type, usb_direction_t direction, 135 136 size_t max_packet_size, unsigned int interval) -
uspace/drv/ohci/iface.c
r297341b r1998bcd 139 139 * @param[in] fun Device function the action was invoked on. 140 140 * @param[in] address USB address of the device. 141 * @param[in] ep_speed Endpoint speed (invalid means to use device one). 141 142 * @param[in] endpoint Endpoint number. 142 143 * @param[in] transfer_type USB transfer type. … … 146 147 * @return Error code. 147 148 */ 148 static int register_endpoint( 149 ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint,149 static int register_endpoint(ddf_fun_t *fun, 150 usb_address_t address, usb_speed_t ep_speed, usb_endpoint_t endpoint, 150 151 usb_transfer_type_t transfer_type, usb_direction_t direction, 151 152 size_t max_packet_size, unsigned int interval) … … 156 157 if (address == hc->rh.address) 157 158 return EOK; 158 const usb_speed_t speed = 159 usb_device_keeper_get_speed(&hc->manager, address); 159 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, address); 160 if (speed >= USB_SPEED_MAX) { 161 speed = ep_speed; 162 } 160 163 const size_t size = max_packet_size; 161 164 usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n", … … 183 186 usb_log_debug("Unregister endpoint %d:%d %d.\n", 184 187 address, endpoint, direction); 188 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 189 address, endpoint, direction, NULL); 190 if (ep != NULL) { 191 usb_device_keeper_del_ep(&hc->manager, address, ep); 192 } 185 193 return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address, 186 194 endpoint, direction); -
uspace/drv/uhci-hcd/iface.c
r297341b r1998bcd 74 74 name, target.address, target.endpoint, size, ep->max_packet_size); 75 75 76 assert(ep->speed ==77 usb_device_keeper_get_speed(&(*hc)->manager, target.address));76 // assert(ep->speed == 77 // usb_device_keeper_get_speed(&(*hc)->manager, target.address)); 78 78 // assert(ep->max_packet_size == max_packet_size); 79 79 // assert(ep->transfer_type == USB_TRANSFER_CONTROL); … … 198 198 /*----------------------------------------------------------------------------*/ 199 199 static int register_endpoint( 200 ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint, 200 ddf_fun_t *fun, usb_address_t address, usb_speed_t ep_speed, 201 usb_endpoint_t endpoint, 201 202 usb_transfer_type_t transfer_type, usb_direction_t direction, 202 203 size_t max_packet_size, unsigned int interval) … … 204 205 hc_t *hc = fun_to_hc(fun); 205 206 assert(hc); 206 const usb_speed_t speed = 207 usb_device_keeper_get_speed(&hc->manager, address); 207 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, address); 208 if (speed >= USB_SPEED_MAX) { 209 speed = ep_speed; 210 } 208 211 const size_t size = 209 212 (transfer_type == USB_TRANSFER_INTERRUPT … … 243 246 usb_log_debug("Unregister endpoint %d:%d %d.\n", 244 247 address, endpoint, direction); 248 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 249 address, endpoint, direction, NULL); 250 if (ep != NULL) { 251 usb_device_keeper_del_ep(&hc->manager, address, ep); 252 } 245 253 return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address, 246 254 endpoint, direction); -
uspace/lib/drv/generic/remote_usbhc.c
r297341b r1998bcd 533 533 } 534 534 535 #define INIT_FROM_HIGH_DATA(type, var, arg_no) \ 536 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / 256 537 #define INIT_FROM_LOW_DATA(type, var, arg_no) \ 538 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % 256 539 540 INIT_FROM_HIGH_DATA(usb_address_t, address, 1); 541 INIT_FROM_LOW_DATA(usb_endpoint_t, endpoint, 1); 542 INIT_FROM_HIGH_DATA(usb_transfer_type_t, transfer_type, 2); 543 INIT_FROM_LOW_DATA(usb_direction_t, direction, 2); 544 545 #undef INIT_FROM_HIGH_DATA 546 #undef INIT_FROM_LOW_DATA 547 548 size_t max_packet_size = (size_t) DEV_IPC_GET_ARG3(*call); 549 unsigned int interval = (unsigned int) DEV_IPC_GET_ARG4(*call); 550 551 int rc = usb_iface->register_endpoint(fun, address, endpoint, 535 #define _INIT_FROM_HIGH_DATA2(type, var, arg_no) \ 536 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / (1 << 16) 537 #define _INIT_FROM_LOW_DATA2(type, var, arg_no) \ 538 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % (1 << 16) 539 #define _INIT_FROM_HIGH_DATA3(type, var, arg_no) \ 540 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / (1 << 16) 541 #define _INIT_FROM_MIDDLE_DATA3(type, var, arg_no) \ 542 type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) / (1 << 8)) % (1 << 8) 543 #define _INIT_FROM_LOW_DATA3(type, var, arg_no) \ 544 type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % (1 << 8) 545 546 _INIT_FROM_HIGH_DATA2(usb_address_t, address, 1); 547 _INIT_FROM_LOW_DATA2(usb_endpoint_t, endpoint, 1); 548 549 _INIT_FROM_HIGH_DATA3(usb_speed_t, speed, 2); 550 _INIT_FROM_MIDDLE_DATA3(usb_transfer_type_t, transfer_type, 2); 551 _INIT_FROM_LOW_DATA3(usb_direction_t, direction, 2); 552 553 _INIT_FROM_HIGH_DATA2(size_t, max_packet_size, 3); 554 _INIT_FROM_LOW_DATA2(unsigned int, interval, 3); 555 556 #undef _INIT_FROM_HIGH_DATA2 557 #undef _INIT_FROM_LOW_DATA2 558 #undef _INIT_FROM_HIGH_DATA3 559 #undef _INIT_FROM_MIDDLE_DATA3 560 #undef _INIT_FROM_LOW_DATA3 561 562 int rc = usb_iface->register_endpoint(fun, address, speed, endpoint, 552 563 transfer_type, direction, max_packet_size, interval); 553 564 -
uspace/lib/drv/include/usbhc_iface.h
r297341b r1998bcd 168 168 /** Register endpoint attributes at host controller. 169 169 * This is used to reserve portion of USB bandwidth. 170 * When speed is invalid, speed of the device is used. 170 171 * Parameters: 171 * - USB address + endpoint number (ADDR * 256 + EP) 172 * - transfer type + direction (TYPE * 256 + DIR) 173 * - maximum packet size 174 * - interval (in milliseconds) 172 * - USB address + endpoint number 173 * - packed as ADDR << 16 + EP 174 * - speed + transfer type + direction 175 * - packed as ( SPEED << 8 + TYPE ) << 8 + DIR 176 * - maximum packet size + interval (in milliseconds) 177 * - packed as MPS << 16 + INT 175 178 * Answer: 176 179 * - EOK - reservation successful … … 221 224 int (*release_address)(ddf_fun_t *, usb_address_t); 222 225 223 int (*register_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t, 226 int (*register_endpoint)(ddf_fun_t *, 227 usb_address_t, usb_speed_t, usb_endpoint_t, 224 228 usb_transfer_type_t, usb_direction_t, size_t, unsigned int); 225 229 int (*unregister_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t, -
uspace/lib/usb/include/usb/host/device_keeper.h
r297341b r1998bcd 73 73 void usb_device_keeper_add_ep( 74 74 usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep); 75 void usb_device_keeper_del_ep( 76 usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep); 75 77 76 78 void usb_device_keeper_reserve_default_address( -
uspace/lib/usb/include/usb/pipes.h
r297341b r1998bcd 134 134 int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *, 135 135 size_t, uint8_t *, size_t, usb_device_connection_t *); 136 int usb_pipe_register_with_speed(usb_pipe_t *, usb_speed_t, 137 unsigned int, usb_hc_connection_t *); 136 138 int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *); 137 139 int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *); -
uspace/lib/usb/src/host/device_keeper.c
r297341b r1998bcd 56 56 instance->devices[i].control_used = 0; 57 57 instance->devices[i].handle = 0; 58 instance->devices[i].speed = USB_SPEED_MAX; 58 59 list_initialize(&instance->devices[i].endpoints); 59 60 } 61 // TODO: is this hack enough? 62 // (it is needed to allow smooth registration at default address) 63 instance->devices[0].occupied = true; 60 64 } 61 65 /*----------------------------------------------------------------------------*/ … … 67 71 assert(instance->devices[address].occupied); 68 72 list_append(&ep->same_device_eps, &instance->devices[address].endpoints); 73 fibril_mutex_unlock(&instance->guard); 74 } 75 /*----------------------------------------------------------------------------*/ 76 void usb_device_keeper_del_ep( 77 usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep) 78 { 79 assert(instance); 80 fibril_mutex_lock(&instance->guard); 81 assert(instance->devices[address].occupied); 82 list_remove(&ep->same_device_eps); 83 list_initialize(&ep->same_device_eps); 69 84 fibril_mutex_unlock(&instance->guard); 70 85 } -
uspace/lib/usb/src/pipesinit.c
r297341b r1998bcd 461 461 usb_hc_connection_t *hc_connection) 462 462 { 463 return usb_pipe_register_with_speed(pipe, USB_SPEED_MAX + 1, 464 interval, hc_connection); 465 } 466 467 /** Register endpoint with a speed at the host controller. 468 * 469 * You will rarely need to use this function because it is needed only 470 * if the registered endpoint is of address 0 and there is no other way 471 * to tell speed of the device at address 0. 472 * 473 * @param pipe Pipe to be registered. 474 * @param speed Speed of the device 475 * (invalid speed means use previously specified one). 476 * @param interval Polling interval. 477 * @param hc_connection Connection to the host controller (must be opened). 478 * @return Error code. 479 */ 480 int usb_pipe_register_with_speed(usb_pipe_t *pipe, usb_speed_t speed, 481 unsigned int interval, 482 usb_hc_connection_t *hc_connection) 483 { 463 484 assert(pipe); 464 485 assert(hc_connection); … … 468 489 } 469 490 470 #define _PACK(high, low) ((high) * 256 + (low)) 471 472 return async_req_5_0(hc_connection->hc_phone, 491 #define _PACK2(high, low) (((high) << 16) + (low)) 492 #define _PACK3(high, middle, low) (((((high) << 8) + (middle)) << 8) + (low)) 493 494 return async_req_4_0(hc_connection->hc_phone, 473 495 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_REGISTER_ENDPOINT, 474 _PACK(pipe->wire->address, pipe->endpoint_no), 475 _PACK(pipe->transfer_type, pipe->direction), 476 pipe->max_packet_size, interval); 477 478 #undef _PACK 496 _PACK2(pipe->wire->address, pipe->endpoint_no), 497 _PACK3(speed, pipe->transfer_type, pipe->direction), 498 _PACK2(pipe->max_packet_size, interval)); 499 500 #undef _PACK2 501 #undef _PACK3 479 502 } 480 503
Note:
See TracChangeset
for help on using the changeset viewer.