Changes in uspace/drv/bus/usb/ohci/ohci_batch.c [9d58539:0d4b110] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/ohci_batch.c
r9d58539 r0d4b110 32 32 * @brief OHCI driver USB transaction structure 33 33 */ 34 35 #include <assert.h> 34 36 #include <errno.h> 35 #include <str_error.h>36 37 #include <macros.h> 38 #include <mem.h> 39 #include <stdbool.h> 37 40 38 41 #include <usb/usb.h> … … 44 47 45 48 static void (*const batch_setup[])(ohci_transfer_batch_t*, usb_direction_t); 46 /*----------------------------------------------------------------------------*/ 49 47 50 /** Safely destructs ohci_transfer_batch_t structure 48 51 * … … 67 70 free(ohci_batch); 68 71 } 69 /*----------------------------------------------------------------------------*/ 72 70 73 /** Finishes usb_transfer_batch and destroys the structure. 71 74 * … … 80 83 ohci_transfer_batch_dispose(ohci_batch); 81 84 } 82 /*----------------------------------------------------------------------------*/ 85 83 86 /** Allocate memory and initialize internal data structure. 84 87 * … … 158 161 #undef CHECK_NULL_DISPOSE_RET 159 162 } 160 /*----------------------------------------------------------------------------*/ 163 161 164 /** Check batch TDs' status. 162 165 * … … 199 202 ohci_batch->tds[i]->next, ohci_batch->tds[i]->be); 200 203 201 /* If the TD got all its data through, it will report 0 bytes202 * remain, the sole exception is INPUT with data rounding flag203 * (short), i.e. every INPUT. Nice thing is that short packets204 * will correctly report remaining data, thus making205 * this computation correct (short packets need to be produced206 * by the last TD)207 * NOTE: This also works for CONTROL transfer as208 * the first TD will return 0 remain.209 * NOTE: Short packets don't break the assumption that210 * we leave the very last(unused) TD behind.211 */212 ohci_batch->usb_batch->transfered_size213 -= td_remain_size(ohci_batch->tds[i]);214 215 204 ohci_batch->usb_batch->error = td_error(ohci_batch->tds[i]); 216 if (ohci_batch->usb_batch->error != EOK) { 205 if (ohci_batch->usb_batch->error == EOK) { 206 /* If the TD got all its data through, it will report 207 * 0 bytes remain, the sole exception is INPUT with 208 * data rounding flag (short), i.e. every INPUT. 209 * Nice thing is that short packets will correctly 210 * report remaining data, thus making this computation 211 * correct (short packets need to be produced by the 212 * last TD) 213 * NOTE: This also works for CONTROL transfer as 214 * the first TD will return 0 remain. 215 * NOTE: Short packets don't break the assumption that 216 * we leave the very last(unused) TD behind. 217 */ 218 ohci_batch->usb_batch->transfered_size 219 -= td_remain_size(ohci_batch->tds[i]); 220 } else { 217 221 usb_log_debug("Batch %p found error TD(%zu):%08x.\n", 218 222 ohci_batch->usb_batch, i, … … 231 235 232 236 /* Check TD assumption */ 233 const uint32_t pa = 234 addr_to_phys(ohci_batch->tds[leave_td]); 235 assert((ohci_batch->ed->td_head & ED_TDHEAD_PTR_MASK) 236 == pa); 237 237 assert(ed_head_td(ohci_batch->ed) == 238 addr_to_phys(ohci_batch->tds[leave_td])); 239 240 /* Set tail to the same TD */ 238 241 ed_set_tail_td(ohci_batch->ed, 239 242 ohci_batch->tds[leave_td]); 240 243 241 244 /* Clear possible ED HALT */ 242 ohci_batch->ed->td_head &= ~ED_TDHEAD_HALTED_FLAG;245 ed_clear_halt(ohci_batch->ed); 243 246 break; 244 247 } … … 253 256 254 257 /* Make sure that we are leaving the right TD behind */ 255 const uint32_t pa = addr_to_phys(ohci_ep->td); 256 assert(pa == (ohci_batch->ed->td_head & ED_TDHEAD_PTR_MASK)); 257 assert(pa == (ohci_batch->ed->td_tail & ED_TDTAIL_PTR_MASK)); 258 assert(addr_to_phys(ohci_ep->td) == ed_head_td(ohci_batch->ed)); 259 assert(addr_to_phys(ohci_ep->td) == ed_tail_td(ohci_batch->ed)); 258 260 259 261 return true; 260 262 } 261 /*----------------------------------------------------------------------------*/ 263 262 264 /** Starts execution of the TD list 263 265 * … … 269 271 ed_set_tail_td(ohci_batch->ed, ohci_batch->tds[ohci_batch->td_count]); 270 272 } 271 /*----------------------------------------------------------------------------*/ 273 272 274 /** Prepare generic control transfer 273 275 * … … 345 347 USB_TRANSFER_BATCH_ARGS(*ohci_batch->usb_batch)); 346 348 } 347 /*----------------------------------------------------------------------------*/ 349 348 350 /** Prepare generic data transfer 349 351 * … … 392 394 USB_TRANSFER_BATCH_ARGS(*ohci_batch->usb_batch)); 393 395 } 394 /*----------------------------------------------------------------------------*/ 396 395 397 /** Transfer setup table. */ 396 398 static void (*const batch_setup[])(ohci_transfer_batch_t*, usb_direction_t) =
Note:
See TracChangeset
for help on using the changeset viewer.