Changeset f97717d9 in mainline for uspace/drv/uhci-hcd/batch.c
- Timestamp:
- 2011-03-25T16:22:14Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- da3dafc, e6223239
- Parents:
- d8421c4 (diff), f08c560 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified uspace/drv/uhci-hcd/batch.c ¶
rd8421c4 rf97717d9 40 40 #include "batch.h" 41 41 #include "transfer_list.h" 42 #include " uhci_hc.h"42 #include "hw_struct/transfer_descriptor.h" 43 43 #include "utils/malloc32.h" 44 #include "uhci_struct/transfer_descriptor.h"45 44 46 45 #define DEFAULT_ERROR_COUNT 3 … … 49 48 qh_t *qh; 50 49 td_t *tds; 51 size_t packets;50 size_t transfers; 52 51 usb_device_keeper_t *manager; 53 52 } uhci_batch_t; … … 65 64 * @param[in] target Device and endpoint target of the transaction. 66 65 * @param[in] transfer_type Interrupt, Control or Bulk. 67 * @param[in] max_packet_size maximum allowed size of data packets.66 * @param[in] max_packet_size maximum allowed size of data transfers. 68 67 * @param[in] speed Speed of the transaction. 69 68 * @param[in] buffer Data source/destination. … … 78 77 * NULL otherwise. 79 78 * 80 * Determines the number of needed packets (TDs). Prepares a transport buffer79 * Determines the number of needed transfers (TDs). Prepares a transport buffer 81 80 * (that is accessible by the hardware). Initializes parameters needed for the 82 81 * transaction and callback. … … 118 117 instance->private_data = data; 119 118 120 data-> packets = (buffer_size + max_packet_size - 1) / max_packet_size;119 data->transfers = (buffer_size + max_packet_size - 1) / max_packet_size; 121 120 if (transfer_type == USB_TRANSFER_CONTROL) { 122 data-> packets += 2;123 } 124 125 data->tds = malloc32(sizeof(td_t) * data-> packets);121 data->transfers += 2; 122 } 123 124 data->tds = malloc32(sizeof(td_t) * data->transfers); 126 125 CHECK_NULL_DISPOSE_RETURN( 127 126 data->tds, "Failed to allocate transfer descriptors.\n"); 128 bzero(data->tds, sizeof(td_t) * data-> packets);127 bzero(data->tds, sizeof(td_t) * data->transfers); 129 128 130 129 data->qh = malloc32(sizeof(qh_t)); … … 167 166 assert(data); 168 167 169 usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",170 instance, data-> packets);168 usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n", 169 instance, data->transfers); 171 170 instance->transfered_size = 0; 172 171 size_t i = 0; 173 for (;i < data-> packets; ++i) {172 for (;i < data->transfers; ++i) { 174 173 if (td_is_active(&data->tds[i])) { 175 174 return false; … … 299 298 * 300 299 * @param[in] instance Batch structure to use. 301 * @param[in] pid to use for data packets.300 * @param[in] pid Pid to use for data transfers. 302 301 * 303 302 * Packets with alternating toggle bit and supplied pid value. 304 * The last packetis marked with IOC flag.303 * The last transfer is marked with IOC flag. 305 304 */ 306 305 void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid) … … 315 314 assert(toggle == 0 || toggle == 1); 316 315 317 size_t packet= 0;316 size_t transfer = 0; 318 317 size_t remain_size = instance->buffer_size; 319 318 while (remain_size > 0) { … … 326 325 remain_size : instance->max_packet_size; 327 326 328 td_t *next_ packet = (packet + 1 < data->packets)329 ? &data->tds[ packet+ 1] : NULL;330 331 assert( packet < data->packets);327 td_t *next_transfer = (transfer + 1 < data->transfers) 328 ? &data->tds[transfer + 1] : NULL; 329 330 assert(transfer < data->transfers); 332 331 assert(packet_size <= remain_size); 333 332 334 333 td_init( 335 &data->tds[ packet], DEFAULT_ERROR_COUNT, packet_size,334 &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size, 336 335 toggle, false, low_speed, instance->target, pid, trans_data, 337 next_ packet);336 next_transfer); 338 337 339 338 340 339 toggle = 1 - toggle; 341 340 remain_size -= packet_size; 342 ++ packet;343 } 344 td_set_ioc(&data->tds[ packet- 1]);341 ++transfer; 342 } 343 td_set_ioc(&data->tds[transfer - 1]); 345 344 usb_device_keeper_set_toggle(data->manager, instance->target, 346 345 instance->direction, toggle); … … 350 349 * 351 350 * @param[in] instance Batch structure to use. 352 * @param[in] data_stage to use for data packets.353 * @param[in] status_stage to use for data packets.351 * @param[in] data_stage Pid to use for data transfers. 352 * @param[in] status_stage Pid to use for data transfers. 354 353 * 355 354 * Setup stage with toggle 0 and USB_PID_SETUP. 356 355 * Data stage with alternating toggle and pid supplied by parameter. 357 356 * Status stage with toggle 1 and pid supplied by parameter. 358 * The last packetis marked with IOC.357 * The last transfer is marked with IOC. 359 358 */ 360 359 void batch_control(usb_transfer_batch_t *instance, … … 364 363 uhci_batch_t *data = instance->private_data; 365 364 assert(data); 366 assert(data-> packets >= 2);365 assert(data->transfers >= 2); 367 366 368 367 const bool low_speed = instance->speed == USB_SPEED_LOW; … … 375 374 376 375 /* data stage */ 377 size_t packet= 1;376 size_t transfer = 1; 378 377 size_t remain_size = instance->buffer_size; 379 378 while (remain_size > 0) { … … 389 388 390 389 td_init( 391 &data->tds[ packet], DEFAULT_ERROR_COUNT, packet_size,390 &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size, 392 391 toggle, false, low_speed, instance->target, data_stage, 393 control_data, &data->tds[ packet+ 1]);394 395 ++ packet;396 assert( packet < data->packets);392 control_data, &data->tds[transfer + 1]); 393 394 ++transfer; 395 assert(transfer < data->transfers); 397 396 assert(packet_size <= remain_size); 398 397 remain_size -= packet_size; … … 400 399 401 400 /* status stage */ 402 assert( packet == data->packets - 1);401 assert(transfer == data->transfers - 1); 403 402 404 403 td_init( 405 &data->tds[ packet], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,404 &data->tds[transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed, 406 405 instance->target, status_stage, NULL, NULL); 407 td_set_ioc(&data->tds[ packet]);406 td_set_ioc(&data->tds[transfer]); 408 407 409 408 usb_log_debug2("Control last TD status: %x.\n", 410 data->tds[ packet].status);409 data->tds[transfer].status); 411 410 } 412 411 /*----------------------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.