Changeset 508a0ca in mainline
- Timestamp:
- 2011-04-12T10:23:03Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f324635
- Parents:
- d017cea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/batch.c
rd017cea r508a0ca 48 48 qh_t *qh; 49 49 td_t *tds; 50 size_t t ransfers;50 size_t td_count; 51 51 } uhci_batch_t; 52 52 … … 63 63 * @param[in] target Device and endpoint target of the transaction. 64 64 * @param[in] transfer_type Interrupt, Control or Bulk. 65 * @param[in] max_packet_size maximum allowed size of data trans fers.65 * @param[in] max_packet_size maximum allowed size of data transactions. 66 66 * @param[in] speed Speed of the transaction. 67 67 * @param[in] buffer Data source/destination. … … 76 76 * NULL otherwise. 77 77 * 78 * Determines the number of needed transfer s (TDs). Prepares a transport buffer79 * (that is accessible by the hardware). Initializes parameters needed for the80 * transaction and callback.78 * Determines the number of needed transfer descriptors (TDs). 79 * Prepares a transport buffer (that is accessible by the hardware). 80 * Initializes parameters needed for the transaction and callback. 81 81 */ 82 82 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep, … … 113 113 instance->private_data = data; 114 114 115 data->t ransfers=115 data->td_count = 116 116 (buffer_size + ep->max_packet_size - 1) / ep->max_packet_size; 117 117 if (ep->transfer_type == USB_TRANSFER_CONTROL) { 118 data->t ransfers+= 2;119 } 120 121 data->tds = malloc32(sizeof(td_t) * data->t ransfers);118 data->td_count += 2; 119 } 120 121 data->tds = malloc32(sizeof(td_t) * data->td_count); 122 122 CHECK_NULL_DISPOSE_RETURN( 123 123 data->tds, "Failed to allocate transfer descriptors.\n"); 124 bzero(data->tds, sizeof(td_t) * data->t ransfers);124 bzero(data->tds, sizeof(td_t) * data->td_count); 125 125 126 126 data->qh = malloc32(sizeof(qh_t)); … … 164 164 165 165 usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n", 166 instance, data->t ransfers);166 instance, data->td_count); 167 167 instance->transfered_size = 0; 168 168 size_t i = 0; 169 for (;i < data->t ransfers; ++i) {169 for (;i < data->td_count; ++i) { 170 170 if (td_is_active(&data->tds[i])) { 171 171 return false; … … 290 290 * 291 291 * @param[in] instance Batch structure to use. 292 * @param[in] pid Pid to use for data trans fers.292 * @param[in] pid Pid to use for data transactions. 293 293 * 294 294 * Packets with alternating toggle bit and supplied pid value. … … 305 305 assert(toggle == 0 || toggle == 1); 306 306 307 size_t t ransfer= 0;307 size_t td = 0; 308 308 size_t remain_size = instance->buffer_size; 309 309 while (remain_size > 0) { … … 316 316 remain_size : instance->ep->max_packet_size; 317 317 318 td_t *next_t ransfer = (transfer + 1 < data->transfers)319 ? &data->tds[t ransfer+ 1] : NULL;320 321 assert(t ransfer < data->transfers);318 td_t *next_td = (td + 1 < data->td_count) 319 ? &data->tds[td + 1] : NULL; 320 321 assert(td < data->td_count); 322 322 assert(packet_size <= remain_size); 323 323 usb_target_t target = … … 325 325 326 326 td_init( 327 &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size, 328 toggle, false, low_speed, target, pid, trans_data, 329 next_transfer); 327 &data->tds[td], DEFAULT_ERROR_COUNT, packet_size, 328 toggle, false, low_speed, target, pid, trans_data, next_td); 330 329 331 330 332 331 toggle = 1 - toggle; 333 332 remain_size -= packet_size; 334 ++t ransfer;335 } 336 td_set_ioc(&data->tds[t ransfer- 1]);333 ++td; 334 } 335 td_set_ioc(&data->tds[td - 1]); 337 336 endpoint_toggle_set(instance->ep, toggle); 338 337 } … … 341 340 * 342 341 * @param[in] instance Batch structure to use. 343 * @param[in] data_stage Pid to use for data t ransfers.344 * @param[in] status_stage Pid to use for data t ransfers.342 * @param[in] data_stage Pid to use for data tds. 343 * @param[in] status_stage Pid to use for data tds. 345 344 * 346 345 * Setup stage with toggle 0 and USB_PID_SETUP. … … 355 354 uhci_batch_t *data = instance->private_data; 356 355 assert(data); 357 assert(data->t ransfers>= 2);356 assert(data->td_count >= 2); 358 357 359 358 const bool low_speed = instance->ep->speed == USB_SPEED_LOW; … … 369 368 370 369 /* data stage */ 371 size_t t ransfer= 1;370 size_t td = 1; 372 371 size_t remain_size = instance->buffer_size; 373 372 while (remain_size > 0) { … … 383 382 384 383 td_init( 385 &data->tds[t ransfer], DEFAULT_ERROR_COUNT, packet_size,384 &data->tds[td], DEFAULT_ERROR_COUNT, packet_size, 386 385 toggle, false, low_speed, target, data_stage, 387 control_data, &data->tds[t ransfer+ 1]);388 389 ++t ransfer;390 assert(t ransfer < data->transfers);386 control_data, &data->tds[td + 1]); 387 388 ++td; 389 assert(td < data->td_count); 391 390 assert(packet_size <= remain_size); 392 391 remain_size -= packet_size; … … 394 393 395 394 /* status stage */ 396 assert(t ransfer == data->transfers- 1);395 assert(td == data->td_count - 1); 397 396 398 397 td_init( 399 &data->tds[t ransfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,398 &data->tds[td], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed, 400 399 target, status_stage, NULL, NULL); 401 td_set_ioc(&data->tds[t ransfer]);400 td_set_ioc(&data->tds[td]); 402 401 403 402 usb_log_debug2("Control last TD status: %x.\n", 404 data->tds[t ransfer].status);403 data->tds[td].status); 405 404 } 406 405 /*----------------------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.