Changes in uspace/drv/bus/usb/ohci/ohci_batch.c [549ff23:11cb0565] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/ohci_batch.c
r549ff23 r11cb0565 34 34 #include <errno.h> 35 35 #include <str_error.h> 36 #include <macros.h> 36 37 37 38 #include <usb/usb.h> … … 53 54 return; 54 55 if (ohci_batch->tds) { 56 const ohci_endpoint_t *ohci_ep = 57 ohci_endpoint_get(ohci_batch->usb_batch->ep); 58 assert(ohci_ep); 55 59 for (unsigned i = 0; i < ohci_batch->td_count; ++i) { 56 if ( i != ohci_batch->leave_td)60 if (ohci_batch->tds[i] != ohci_ep->td) 57 61 free32(ohci_batch->tds[i]); 58 62 } … … 64 68 } 65 69 /*----------------------------------------------------------------------------*/ 70 /** Finishes usb_transfer_batch and destroys the structure. 71 * 72 * @param[in] uhci_batch Instance to finish and destroy. 73 */ 66 74 void ohci_transfer_batch_finish_dispose(ohci_transfer_batch_t *ohci_batch) 67 75 { … … 69 77 assert(ohci_batch->usb_batch); 70 78 usb_transfer_batch_finish(ohci_batch->usb_batch, 71 ohci_batch->device_buffer + ohci_batch->usb_batch->setup_size, 72 ohci_batch->usb_batch->buffer_size); 79 ohci_batch->device_buffer + ohci_batch->usb_batch->setup_size); 73 80 ohci_transfer_batch_dispose(ohci_batch); 74 81 } 75 82 /*----------------------------------------------------------------------------*/ 83 /** Allocate memory and initialize internal data structure. 84 * 85 * @param[in] usb_batch Pointer to generic USB batch structure. 86 * @return Valid pointer if all structures were successfully created, 87 * NULL otherwise. 88 * 89 * Determines the number of needed transfer descriptors (TDs). 90 * Prepares a transport buffer (that is accessible by the hardware). 91 * Initializes parameters needed for the transfer and callback. 92 */ 76 93 ohci_transfer_batch_t * ohci_transfer_batch_get(usb_transfer_batch_t *usb_batch) 77 94 { … … 105 122 ohci_batch->ed = ohci_endpoint_get(usb_batch->ep)->ed; 106 123 ohci_batch->tds[0] = ohci_endpoint_get(usb_batch->ep)->td; 107 ohci_batch->leave_td = 0;108 124 109 125 for (unsigned i = 1; i <= ohci_batch->td_count; ++i) { … … 152 168 * completes with the last TD. 153 169 */ 154 bool ohci_transfer_batch_is_complete( ohci_transfer_batch_t *ohci_batch)170 bool ohci_transfer_batch_is_complete(const ohci_transfer_batch_t *ohci_batch) 155 171 { 156 172 assert(ohci_batch); … … 174 190 175 191 /* Assume we will leave the last(unused) TD behind */ 176 ohci_batch->leave_td = ohci_batch->td_count;192 unsigned leave_td = ohci_batch->td_count; 177 193 178 194 /* Check all TDs */ … … 212 228 * It will be the one TD we leave behind. 213 229 */ 214 ohci_batch->leave_td = i + 1;230 leave_td = i + 1; 215 231 216 232 /* Check TD assumption */ 217 const uint32_t pa = addr_to_phys(218 ohci_batch->tds[ohci_batch->leave_td]);219 assert((ohci_batch->ed->td_head & ED_TD TAIL_PTR_MASK)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) 220 236 == pa); 221 237 222 238 ed_set_tail_td(ohci_batch->ed, 223 ohci_batch->tds[ ohci_batch->leave_td]);239 ohci_batch->tds[leave_td]); 224 240 225 241 /* Clear possible ED HALT */ … … 234 250 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ohci_batch->usb_batch->ep); 235 251 assert(ohci_ep); 236 ohci_ep->td = ohci_batch->tds[ ohci_batch->leave_td];252 ohci_ep->td = ohci_batch->tds[leave_td]; 237 253 238 254 /* Make sure that we are leaving the right TD behind */ … … 248 264 * @param[in] ohci_batch Batch structure to use 249 265 */ 250 void ohci_transfer_batch_commit( ohci_transfer_batch_t *ohci_batch)266 void ohci_transfer_batch_commit(const ohci_transfer_batch_t *ohci_batch) 251 267 { 252 268 assert(ohci_batch); … … 295 311 while (remain_size > 0) { 296 312 const size_t transfer_size = 297 remain_size > OHCI_TD_MAX_TRANSFER ? 298 OHCI_TD_MAX_TRANSFER : remain_size; 313 min(remain_size, OHCI_TD_MAX_TRANSFER); 299 314 toggle = 1 - toggle; 300 315 … … 378 393 } 379 394 /*----------------------------------------------------------------------------*/ 395 /** Transfer setup table. */ 380 396 static void (*const batch_setup[])(ohci_transfer_batch_t*, usb_direction_t) = 381 397 {
Note:
See TracChangeset
for help on using the changeset viewer.