Changeset 15d3b54 in mainline for uspace/drv/uhci-hcd/batch.c
- Timestamp:
- 2011-03-14T21:24:02Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fcf07e6
- Parents:
- c69209d (diff), 9370884 (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
-
uspace/drv/uhci-hcd/batch.c
rc69209d r15d3b54 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup usb28 /** @addtogroup drvusbuhcihc 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver 32 * @brief UHCI driver USB transaction structure 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);48 46 49 47 static void batch_control(batch_t *instance, … … 54 52 static void batch_call_in_and_dispose(batch_t *instance); 55 53 static void batch_call_out_and_dispose(batch_t *instance); 56 static void batch_dispose(batch_t *instance); 57 58 59 /** Allocates memory and initializes internal data structures. 54 55 56 /** Allocate memory and initialize internal data structure. 60 57 * 61 58 * @param[in] fun DDF function to pass to callback. … … 72 69 * @param[in] arg additional parameter to func_in or func_out 73 70 * @param[in] manager Pointer to toggle management structure. 74 * @return False, if there is an active TD, true otherwise. 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. 75 77 */ 76 78 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target, … … 151 153 } 152 154 /*----------------------------------------------------------------------------*/ 153 /** Check sbatch TDs for activity.155 /** Check batch TDs for activity. 154 156 * 155 157 * @param[in] instance Batch structure to use. 156 158 * @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 be 161 * processed). Stop with true if an error is found. Return true if the last TS 162 * is reached. 157 163 */ 158 164 bool batch_is_complete(batch_t *instance) … … 193 199 * 194 200 * @param[in] instance Batch structure to use. 201 * 202 * Uses genercir control function with pids OUT and IN. 195 203 */ 196 204 void batch_control_write(batch_t *instance) 197 205 { 198 206 assert(instance); 199 /* we are data out, we are supposed to provide data */207 /* We are data out, we are supposed to provide data */ 200 208 memcpy(instance->transport_buffer, instance->buffer, 201 209 instance->buffer_size); … … 203 211 instance->next_step = batch_call_out_and_dispose; 204 212 usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance); 205 batch_schedule(instance);206 213 } 207 214 /*----------------------------------------------------------------------------*/ … … 209 216 * 210 217 * @param[in] instance Batch structure to use. 218 * 219 * Uses generic control with pids IN and OUT. 211 220 */ 212 221 void batch_control_read(batch_t *instance) … … 216 225 instance->next_step = batch_call_in_and_dispose; 217 226 usb_log_debug("Batch(%p) CONTROL READ initialized.\n", instance); 218 batch_schedule(instance); 219 } 220 /*----------------------------------------------------------------------------*/ 221 /** Prepares interrupt in transaction. 222 * 223 * @param[in] instance Batch structure to use. 227 } 228 /*----------------------------------------------------------------------------*/ 229 /** Prepare interrupt in transaction. 230 * 231 * @param[in] instance Batch structure to use. 232 * 233 * Data transaction with PID_IN. 224 234 */ 225 235 void batch_interrupt_in(batch_t *instance) … … 229 239 instance->next_step = batch_call_in_and_dispose; 230 240 usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance); 231 batch_schedule(instance); 232 } 233 /*----------------------------------------------------------------------------*/ 234 /** Prepares interrupt out transaction. 235 * 236 * @param[in] instance Batch structure to use. 241 } 242 /*----------------------------------------------------------------------------*/ 243 /** Prepare interrupt out transaction. 244 * 245 * @param[in] instance Batch structure to use. 246 * 247 * Data transaction with PID_OUT. 237 248 */ 238 249 void batch_interrupt_out(batch_t *instance) 239 250 { 240 251 assert(instance); 241 /* we are data out, we are supposed to provide data */252 /* We are data out, we are supposed to provide data */ 242 253 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 243 254 batch_data(instance, USB_PID_OUT); 244 255 instance->next_step = batch_call_out_and_dispose; 245 256 usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance); 246 batch_schedule(instance); 247 } 248 /*----------------------------------------------------------------------------*/ 249 /** Prepares bulk in transaction. 250 * 251 * @param[in] instance Batch structure to use. 257 } 258 /*----------------------------------------------------------------------------*/ 259 /** Prepare bulk in transaction. 260 * 261 * @param[in] instance Batch structure to use. 262 * 263 * Data transaction with PID_IN. 252 264 */ 253 265 void batch_bulk_in(batch_t *instance) … … 257 269 instance->next_step = batch_call_in_and_dispose; 258 270 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); 259 batch_schedule(instance); 260 } 261 /*----------------------------------------------------------------------------*/ 262 /** Prepares bulk out transaction. 263 * 264 * @param[in] instance Batch structure to use. 271 } 272 /*----------------------------------------------------------------------------*/ 273 /** Prepare bulk out transaction. 274 * 275 * @param[in] instance Batch structure to use. 276 * 277 * Data transaction with PID_OUT. 265 278 */ 266 279 void batch_bulk_out(batch_t *instance) 267 280 { 268 281 assert(instance); 282 /* We are data out, we are supposed to provide data */ 269 283 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 270 284 batch_data(instance, USB_PID_OUT); 271 285 instance->next_step = batch_call_out_and_dispose; 272 286 usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance); 273 batch_schedule(instance); 274 } 275 /*----------------------------------------------------------------------------*/ 276 /** Prepares generic data transaction 287 } 288 /*----------------------------------------------------------------------------*/ 289 /** Prepare generic data transaction 277 290 * 278 291 * @param[in] instance Batch structure to use. 279 292 * @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. 280 296 */ 281 297 void batch_data(batch_t *instance, usb_packet_id pid) … … 318 334 } 319 335 /*----------------------------------------------------------------------------*/ 320 /** Prepare sgeneric control transaction336 /** Prepare generic control transaction 321 337 * 322 338 * @param[in] instance Batch structure to use. 323 339 * @param[in] data_stage to use for data packets. 324 340 * @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. 325 346 */ 326 347 void batch_control(batch_t *instance, … … 371 392 } 372 393 /*----------------------------------------------------------------------------*/ 373 /** Prepares data, gets error status and calls callback in. 374 * 375 * @param[in] instance Batch structure to use. 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. 376 399 */ 377 400 void batch_call_in(batch_t *instance) … … 380 403 assert(instance->callback_in); 381 404 382 /* we are data in, we need data */405 /* We are data in, we need data */ 383 406 memcpy(instance->buffer, instance->transport_buffer, 384 407 instance->buffer_size); … … 393 416 } 394 417 /*----------------------------------------------------------------------------*/ 395 /** Get s error status and callscallback out.418 /** Get error status and call callback out. 396 419 * 397 420 * @param[in] instance Batch structure to use. … … 409 432 } 410 433 /*----------------------------------------------------------------------------*/ 411 /** Prepares data, gets error status, calls callback in and dispose.434 /** Helper function calls callback and correctly disposes of batch structure. 412 435 * 413 436 * @param[in] instance Batch structure to use. … … 420 443 } 421 444 /*----------------------------------------------------------------------------*/ 422 /** Gets error status, calls callback out and dispose.445 /** Helper function calls callback and correctly disposes of batch structure. 423 446 * 424 447 * @param[in] instance Batch structure to use. … … 431 454 } 432 455 /*----------------------------------------------------------------------------*/ 433 /** Correctly dispose sall used data structures.456 /** Correctly dispose all used data structures. 434 457 * 435 458 * @param[in] instance Batch structure to use. … … 446 469 free(instance); 447 470 } 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 }456 471 /** 457 472 * @}
Note:
See TracChangeset
for help on using the changeset viewer.