Changes in uspace/drv/uhci-hcd/batch.c [17ceb72:a9f91cd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/batch.c
r17ceb72 ra9f91cd 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver USB transaction structure32 * @brief UHCI driver 33 33 */ 34 34 #include <errno.h> … … 44 44 45 45 #define DEFAULT_ERROR_COUNT 3 46 47 static int batch_schedule(batch_t *instance); 46 48 47 49 static void batch_control(batch_t *instance, … … 52 54 static void batch_call_in_and_dispose(batch_t *instance); 53 55 static void batch_call_out_and_dispose(batch_t *instance); 54 55 56 /** Allocate memory and initialize internal data structure. 56 static void batch_dispose(batch_t *instance); 57 58 59 /** Allocates memory and initializes internal data structures. 57 60 * 58 61 * @param[in] fun DDF function to pass to callback. … … 69 72 * @param[in] arg additional parameter to func_in or func_out 70 73 * @param[in] manager Pointer to toggle management structure. 71 * @return Valid pointer if all substructures were successfully created, 72 * NULL otherwise. 73 * 74 * Determines the number of needed packets (TDs). Prepares a transport buffer 75 * (that is accessible by the hardware). Initializes parameters needed for the 76 * transaction and callback. 74 * @return False, if there is an active TD, true otherwise. 77 75 */ 78 76 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target, … … 153 151 } 154 152 /*----------------------------------------------------------------------------*/ 155 /** Check batch TDs for activity.153 /** Checks batch TDs for activity. 156 154 * 157 155 * @param[in] instance Batch structure to use. 158 156 * @return False, if there is an active TD, true otherwise. 159 *160 * Walk all TDs. Stop with false if there is an active one (it is to be161 * processed). Stop with true if an error is found. Return true if the last TS162 * is reached.163 157 */ 164 158 bool batch_is_complete(batch_t *instance) … … 199 193 * 200 194 * @param[in] instance Batch structure to use. 201 *202 * Uses genercir control function with pids OUT and IN.203 195 */ 204 196 void batch_control_write(batch_t *instance) 205 197 { 206 198 assert(instance); 207 /* We are data out, we are supposed to provide data */199 /* we are data out, we are supposed to provide data */ 208 200 memcpy(instance->transport_buffer, instance->buffer, 209 201 instance->buffer_size); … … 211 203 instance->next_step = batch_call_out_and_dispose; 212 204 usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance); 205 batch_schedule(instance); 213 206 } 214 207 /*----------------------------------------------------------------------------*/ … … 216 209 * 217 210 * @param[in] instance Batch structure to use. 218 *219 * Uses generic control with pids IN and OUT.220 211 */ 221 212 void batch_control_read(batch_t *instance) … … 225 216 instance->next_step = batch_call_in_and_dispose; 226 217 usb_log_debug("Batch(%p) CONTROL READ initialized.\n", instance); 227 } 228 /*----------------------------------------------------------------------------*/ 229 /** Prepare interrupt in transaction. 230 * 231 * @param[in] instance Batch structure to use. 232 * 233 * Data transaction with PID_IN. 218 batch_schedule(instance); 219 } 220 /*----------------------------------------------------------------------------*/ 221 /** Prepares interrupt in transaction. 222 * 223 * @param[in] instance Batch structure to use. 234 224 */ 235 225 void batch_interrupt_in(batch_t *instance) … … 239 229 instance->next_step = batch_call_in_and_dispose; 240 230 usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance); 241 } 242 /*----------------------------------------------------------------------------*/ 243 /** Prepare interrupt out transaction. 244 * 245 * @param[in] instance Batch structure to use. 246 * 247 * Data transaction with PID_OUT. 231 batch_schedule(instance); 232 } 233 /*----------------------------------------------------------------------------*/ 234 /** Prepares interrupt out transaction. 235 * 236 * @param[in] instance Batch structure to use. 248 237 */ 249 238 void batch_interrupt_out(batch_t *instance) 250 239 { 251 240 assert(instance); 252 /* We are data out, we are supposed to provide data */241 /* we are data out, we are supposed to provide data */ 253 242 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 254 243 batch_data(instance, USB_PID_OUT); 255 244 instance->next_step = batch_call_out_and_dispose; 256 245 usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance); 257 } 258 /*----------------------------------------------------------------------------*/ 259 /** Prepare bulk in transaction. 260 * 261 * @param[in] instance Batch structure to use. 262 * 263 * Data transaction with PID_IN. 246 batch_schedule(instance); 247 } 248 /*----------------------------------------------------------------------------*/ 249 /** Prepares bulk in transaction. 250 * 251 * @param[in] instance Batch structure to use. 264 252 */ 265 253 void batch_bulk_in(batch_t *instance) … … 269 257 instance->next_step = batch_call_in_and_dispose; 270 258 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); 271 } 272 /*----------------------------------------------------------------------------*/ 273 /** Prepare bulk out transaction. 274 * 275 * @param[in] instance Batch structure to use. 276 * 277 * Data transaction with PID_OUT. 259 batch_schedule(instance); 260 } 261 /*----------------------------------------------------------------------------*/ 262 /** Prepares bulk out transaction. 263 * 264 * @param[in] instance Batch structure to use. 278 265 */ 279 266 void batch_bulk_out(batch_t *instance) 280 267 { 281 268 assert(instance); 282 /* We are data out, we are supposed to provide data */283 269 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 284 270 batch_data(instance, USB_PID_OUT); 285 271 instance->next_step = batch_call_out_and_dispose; 286 272 usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance); 287 } 288 /*----------------------------------------------------------------------------*/ 289 /** Prepare generic data transaction 273 batch_schedule(instance); 274 } 275 /*----------------------------------------------------------------------------*/ 276 /** Prepares generic data transaction 290 277 * 291 278 * @param[in] instance Batch structure to use. 292 279 * @param[in] pid to use for data packets. 293 *294 * Packets with alternating toggle bit and supplied pid value.295 * The last packet is marked with IOC flag.296 280 */ 297 281 void batch_data(batch_t *instance, usb_packet_id pid) … … 334 318 } 335 319 /*----------------------------------------------------------------------------*/ 336 /** Prepare generic control transaction320 /** Prepares generic control transaction 337 321 * 338 322 * @param[in] instance Batch structure to use. 339 323 * @param[in] data_stage to use for data packets. 340 324 * @param[in] status_stage to use for data packets. 341 *342 * Setup stage with toggle 0 and USB_PID_SETUP.343 * Data stage with alternating toggle and pid supplied by parameter.344 * Status stage with toggle 1 and pid supplied by parameter.345 * The last packet is marked with IOC.346 325 */ 347 326 void batch_control(batch_t *instance, … … 392 371 } 393 372 /*----------------------------------------------------------------------------*/ 394 /** Prepare data, get error status and call callback in. 395 * 396 * @param[in] instance Batch structure to use. 397 * Copies data from transport buffer, and calls callback with appropriate 398 * parameters. 373 /** Prepares data, gets error status and calls callback in. 374 * 375 * @param[in] instance Batch structure to use. 399 376 */ 400 377 void batch_call_in(batch_t *instance) … … 403 380 assert(instance->callback_in); 404 381 405 /* We are data in, we need data */382 /* we are data in, we need data */ 406 383 memcpy(instance->buffer, instance->transport_buffer, 407 384 instance->buffer_size); … … 416 393 } 417 394 /*----------------------------------------------------------------------------*/ 418 /** Get error status and callcallback out.395 /** Gets error status and calls callback out. 419 396 * 420 397 * @param[in] instance Batch structure to use. … … 432 409 } 433 410 /*----------------------------------------------------------------------------*/ 434 /** Helper function calls callback and correctly disposes of batch structure.411 /** Prepares data, gets error status, calls callback in and dispose. 435 412 * 436 413 * @param[in] instance Batch structure to use. … … 443 420 } 444 421 /*----------------------------------------------------------------------------*/ 445 /** Helper function calls callback and correctly disposes of batch structure.422 /** Gets error status, calls callback out and dispose. 446 423 * 447 424 * @param[in] instance Batch structure to use. … … 454 431 } 455 432 /*----------------------------------------------------------------------------*/ 456 /** Correctly dispose all used data structures.433 /** Correctly disposes all used data structures. 457 434 * 458 435 * @param[in] instance Batch structure to use. … … 469 446 free(instance); 470 447 } 448 /*----------------------------------------------------------------------------*/ 449 int batch_schedule(batch_t *instance) 450 { 451 assert(instance); 452 uhci_hc_t *hc = fun_to_uhci_hc(instance->fun); 453 assert(hc); 454 return uhci_hc_schedule(hc, instance); 455 } 471 456 /** 472 457 * @}
Note:
See TracChangeset
for help on using the changeset viewer.