Changeset 910ca3f in mainline
- Timestamp:
- 2011-04-12T11:43:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2cc6e97, 4deca9b
- Parents:
- c4e3b1f7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/batch.c
rc4e3b1f7 r910ca3f 30 30 */ 31 31 /** @file 32 * @brief UHCI driver USB trans actionstructure32 * @brief UHCI driver USB transfer structure 33 33 */ 34 34 #include <errno.h> … … 61 61 * 62 62 * @param[in] fun DDF function to pass to callback. 63 * @param[in] target Device and endpoint target of the transaction. 64 * @param[in] transfer_type Interrupt, Control or Bulk. 65 * @param[in] max_packet_size maximum allowed size of data transactions. 66 * @param[in] speed Speed of the transaction. 63 * @param[in] ep Communication target 67 64 * @param[in] buffer Data source/destination. 68 65 * @param[in] size Size of the buffer. 69 66 * @param[in] setup_buffer Setup data source (if not NULL) 70 67 * @param[in] setup_size Size of setup_buffer (should be always 8) 71 * @param[in] func_in function to call on inbound trans actioncompletion72 * @param[in] func_out function to call on outbound trans actioncompletion68 * @param[in] func_in function to call on inbound transfer completion 69 * @param[in] func_out function to call on outbound transfer completion 73 70 * @param[in] arg additional parameter to func_in or func_out 74 * @param[in] ep Pointer to endpoint toggle management structure.75 71 * @return Valid pointer if all substructures were successfully created, 76 72 * NULL otherwise. … … 78 74 * Determines the number of needed transfer descriptors (TDs). 79 75 * Prepares a transport buffer (that is accessible by the hardware). 80 * Initializes parameters needed for the trans actionand callback.76 * Initializes parameters needed for the transfer and callback. 81 77 */ 82 78 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep, … … 154 150 * 155 151 * Walk all TDs. Stop with false if there is an active one (it is to be 156 * processed). Stop with true if an error is found. Return true if the last T S152 * processed). Stop with true if an error is found. Return true if the last TD 157 153 * is reached. 158 154 */ … … 177 173 instance, i, data->tds[i].status); 178 174 td_print_status(&data->tds[i]); 175 179 176 assert(instance->ep != NULL); 180 181 177 endpoint_toggle_set(instance->ep, 182 178 td_toggle(&data->tds[i])); … … 195 191 } 196 192 /*----------------------------------------------------------------------------*/ 197 /** Prepares control write trans action.198 * 199 * @param[in] instance Batch structure to use. 200 * 201 * Uses gener circontrol function with pids OUT and IN.193 /** Prepares control write transfer. 194 * 195 * @param[in] instance Batch structure to use. 196 * 197 * Uses generic control function with pids OUT and IN. 202 198 */ 203 199 void batch_control_write(usb_transfer_batch_t *instance) … … 211 207 } 212 208 /*----------------------------------------------------------------------------*/ 213 /** Prepares control read trans action.209 /** Prepares control read transfer. 214 210 * 215 211 * @param[in] instance Batch structure to use. … … 225 221 } 226 222 /*----------------------------------------------------------------------------*/ 227 /** Prepare interrupt in trans action.228 * 229 * @param[in] instance Batch structure to use. 230 * 231 * Data trans actionwith PID_IN.223 /** Prepare interrupt in transfer. 224 * 225 * @param[in] instance Batch structure to use. 226 * 227 * Data transfer with PID_IN. 232 228 */ 233 229 void batch_interrupt_in(usb_transfer_batch_t *instance) 234 230 { 235 231 assert(instance); 236 // instance->direction = USB_DIRECTION_IN;237 232 batch_data(instance, USB_PID_IN); 238 233 instance->next_step = batch_call_in_and_dispose; … … 240 235 } 241 236 /*----------------------------------------------------------------------------*/ 242 /** Prepare interrupt out trans action.243 * 244 * @param[in] instance Batch structure to use. 245 * 246 * Data trans actionwith PID_OUT.237 /** Prepare interrupt out transfer. 238 * 239 * @param[in] instance Batch structure to use. 240 * 241 * Data transfer with PID_OUT. 247 242 */ 248 243 void batch_interrupt_out(usb_transfer_batch_t *instance) … … 256 251 } 257 252 /*----------------------------------------------------------------------------*/ 258 /** Prepare bulk in trans action.259 * 260 * @param[in] instance Batch structure to use. 261 * 262 * Data trans actionwith PID_IN.253 /** Prepare bulk in transfer. 254 * 255 * @param[in] instance Batch structure to use. 256 * 257 * Data transfer with PID_IN. 263 258 */ 264 259 void batch_bulk_in(usb_transfer_batch_t *instance) … … 270 265 } 271 266 /*----------------------------------------------------------------------------*/ 272 /** Prepare bulk out trans action.273 * 274 * @param[in] instance Batch structure to use. 275 * 276 * Data trans actionwith PID_OUT.267 /** Prepare bulk out transfer. 268 * 269 * @param[in] instance Batch structure to use. 270 * 271 * Data transfer with PID_OUT. 277 272 */ 278 273 void batch_bulk_out(usb_transfer_batch_t *instance) … … 280 275 assert(instance); 281 276 /* We are data out, we are supposed to provide data */ 282 memcpy(instance->data_buffer, instance->buffer, 283 instance->buffer_size); 277 memcpy(instance->data_buffer, instance->buffer, instance->buffer_size); 284 278 batch_data(instance, USB_PID_OUT); 285 279 instance->next_step = batch_call_out_and_dispose; … … 287 281 } 288 282 /*----------------------------------------------------------------------------*/ 289 /** Prepare generic data trans action283 /** Prepare generic data transfer 290 284 * 291 285 * @param[in] instance Batch structure to use. 292 286 * @param[in] pid Pid to use for data transactions. 293 287 * 294 * Packets with alternating toggle bit and supplied pid value.288 * Transactions with alternating toggle bit and supplied pid value. 295 289 * The last transfer is marked with IOC flag. 296 290 */ … … 307 301 size_t td = 0; 308 302 size_t remain_size = instance->buffer_size; 303 char *buffer = instance->data_buffer; 309 304 while (remain_size > 0) { 310 char *trans_data =311 instance->data_buffer + instance->buffer_size312 - remain_size;313 314 305 const size_t packet_size = 315 306 (instance->ep->max_packet_size > remain_size) ? … … 319 310 ? &data->tds[td + 1] : NULL; 320 311 321 assert(td < data->td_count); 322 assert(packet_size <= remain_size); 312 323 313 usb_target_t target = 324 314 { instance->ep->address, instance->ep->endpoint }; 325 315 316 assert(td < data->td_count); 326 317 td_init( 327 318 &data->tds[td], DEFAULT_ERROR_COUNT, packet_size, 328 toggle, false, low_speed, target, pid, trans_data, next_td);329 330 319 toggle, false, low_speed, target, pid, buffer, next_td); 320 321 ++td; 331 322 toggle = 1 - toggle; 323 buffer += packet_size; 324 assert(packet_size <= remain_size); 332 325 remain_size -= packet_size; 333 ++td;334 326 } 335 327 td_set_ioc(&data->tds[td - 1]); … … 337 329 } 338 330 /*----------------------------------------------------------------------------*/ 339 /** Prepare generic control trans action331 /** Prepare generic control transfer 340 332 * 341 333 * @param[in] instance Batch structure to use. … … 357 349 358 350 const bool low_speed = instance->ep->speed == USB_SPEED_LOW; 359 int toggle = 0;360 351 const usb_target_t target = 361 352 { instance->ep->address, instance->ep->endpoint }; … … 363 354 /* setup stage */ 364 355 td_init( 365 data->tds, DEFAULT_ERROR_COUNT, instance->setup_size, toggle, false,356 data->tds, DEFAULT_ERROR_COUNT, instance->setup_size, 0, false, 366 357 low_speed, target, USB_PID_SETUP, instance->setup_buffer, 367 358 &data->tds[1]); … … 369 360 /* data stage */ 370 361 size_t td = 1; 362 unsigned toggle = 1; 371 363 size_t remain_size = instance->buffer_size; 364 char *buffer = instance->data_buffer; 372 365 while (remain_size > 0) { 373 char *control_data =374 instance->data_buffer + instance->buffer_size375 - remain_size;376 377 toggle = 1 - toggle;378 379 366 const size_t packet_size = 380 367 (instance->ep->max_packet_size > remain_size) ? … … 384 371 &data->tds[td], DEFAULT_ERROR_COUNT, packet_size, 385 372 toggle, false, low_speed, target, data_stage, 386 control_data, &data->tds[td + 1]);373 buffer, &data->tds[td + 1]); 387 374 388 375 ++td; 376 toggle = 1 - toggle; 377 buffer += packet_size; 389 378 assert(td < data->td_count); 390 379 assert(packet_size <= remain_size); … … 412 401 } 413 402 /*----------------------------------------------------------------------------*/ 414 /** Helper function calls callback and correctly disposes ofbatch structure.403 /** Helper function, calls callback and correctly destroys batch structure. 415 404 * 416 405 * @param[in] instance Batch structure to use. … … 423 412 } 424 413 /*----------------------------------------------------------------------------*/ 425 /** Helper function calls callback and correctly d isposes ofbatch structure.414 /** Helper function calls callback and correctly destroys batch structure. 426 415 * 427 416 * @param[in] instance Batch structure to use.
Note:
See TracChangeset
for help on using the changeset viewer.