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