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