Changeset 3bacee1 in mainline for uspace/drv/bus/usb/ehci/ehci_batch.c
- Timestamp:
- 2018-04-12T16:27:17Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3cf22f9
- Parents:
- 76d0981d
- git-author:
- Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/ehci_batch.c
r76d0981d r3bacee1 53 53 #define EHCI_TD_MAX_TRANSFER (16 * 1024) 54 54 55 static void (*const batch_setup[])(ehci_transfer_batch_t *);55 static void (*const batch_setup[])(ehci_transfer_batch_t *); 56 56 57 57 /** Safely destructs ehci_transfer_batch_t structure … … 74 74 * 75 75 */ 76 ehci_transfer_batch_t * 76 ehci_transfer_batch_t *ehci_transfer_batch_create(endpoint_t *ep) 77 77 { 78 78 assert(ep); … … 99 99 assert(ehci_batch); 100 100 101 const size_t setup_size = (ehci_batch->base.ep->transfer_type == USB_TRANSFER_CONTROL) 102 ? USB_SETUP_PACKET_SIZE103 :0;101 const size_t setup_size = (ehci_batch->base.ep->transfer_type == USB_TRANSFER_CONTROL) ? 102 USB_SETUP_PACKET_SIZE : 103 0; 104 104 105 105 const size_t size = ehci_batch->base.size; … … 109 109 110 110 /* Determine number of TDs needed */ 111 ehci_batch->td_count = (size + EHCI_TD_MAX_TRANSFER - 1) 112 /EHCI_TD_MAX_TRANSFER;111 ehci_batch->td_count = (size + EHCI_TD_MAX_TRANSFER - 1) / 112 EHCI_TD_MAX_TRANSFER; 113 113 114 114 /* Control transfer need Setup and Status stage */ … … 173 173 ehci_batch->qh->next, ehci_batch->qh->alternate); 174 174 175 if (!qh_halted(ehci_batch->qh) && (qh_transfer_pending(ehci_batch->qh) 176 ||qh_transfer_active(ehci_batch->qh)))175 if (!qh_halted(ehci_batch->qh) && (qh_transfer_pending(ehci_batch->qh) || 176 qh_transfer_active(ehci_batch->qh))) 177 177 return false; 178 178 … … 204 204 * we leave the very last(unused) TD behind. 205 205 */ 206 ehci_batch->base.transferred_size 207 -=td_remain_size(&ehci_batch->tds[i]);206 ehci_batch->base.transferred_size -= 207 td_remain_size(&ehci_batch->tds[i]); 208 208 } else { 209 209 usb_log_debug("Batch %p found error TD(%zu):%08x: %s.", … … 274 274 dma_buffer_phys(&ehci_batch->ehci_dma_buffer, ehci_batch->setup_buffer), 275 275 USB_DIRECTION_BOTH, USB_SETUP_PACKET_SIZE, toggle, false); 276 usb_log_debug2("Batch %p: Created CONTROL SETUP TD(%" PRIxn"): "276 usb_log_debug2("Batch %p: Created CONTROL SETUP TD(%" PRIxn "): " 277 277 "%08x:%08x:%08x", ehci_batch, 278 278 dma_buffer_phys(&ehci_batch->ehci_dma_buffer, &ehci_batch->tds[0]), … … 292 292 dma_buffer_phys(&ehci_batch->ehci_dma_buffer, &ehci_batch->tds[td_current + 1]), 293 293 buffer, data_dir, transfer_size, toggle, false); 294 usb_log_debug2("Batch %p: Created CONTROL DATA TD(%" PRIxn"): "294 usb_log_debug2("Batch %p: Created CONTROL DATA TD(%" PRIxn "): " 295 295 "%08x:%08x:%08x", ehci_batch, 296 296 dma_buffer_phys(&ehci_batch->ehci_dma_buffer, &ehci_batch->tds[td_current]), … … 308 308 assert(td_current == ehci_batch->td_count - 1); 309 309 td_init(&ehci_batch->tds[td_current], 0, 0, status_dir, 0, 1, true); 310 usb_log_debug2("Batch %p: Created CONTROL STATUS TD %d(%" PRIxn"): "310 usb_log_debug2("Batch %p: Created CONTROL STATUS TD %d(%" PRIxn "): " 311 311 "%08x:%08x:%08x", ehci_batch, td_current, 312 312 dma_buffer_phys(&ehci_batch->ehci_dma_buffer, &ehci_batch->tds[td_current]), … … 340 340 ehci_batch->data_buffer); 341 341 while (remain_size > 0) { 342 const size_t transfer_size = remain_size > EHCI_TD_MAX_TRANSFER 343 ?EHCI_TD_MAX_TRANSFER : remain_size;342 const size_t transfer_size = remain_size > EHCI_TD_MAX_TRANSFER ? 343 EHCI_TD_MAX_TRANSFER : remain_size; 344 344 345 345 const bool last = (remain_size == transfer_size); 346 346 td_init(&ehci_batch->tds[td_current], 347 347 last ? 0 : dma_buffer_phys(&ehci_batch->ehci_dma_buffer, 348 348 &ehci_batch->tds[td_current + 1]), 349 349 buffer, ehci_batch->base.dir, transfer_size, -1, last); 350 350 351 usb_log_debug2("Batch %p: DATA TD(%" PRIxn": %08x:%08x:%08x",351 usb_log_debug2("Batch %p: DATA TD(%" PRIxn ": %08x:%08x:%08x", 352 352 ehci_batch, 353 353 dma_buffer_phys(&ehci_batch->ehci_dma_buffer, 354 354 &ehci_batch->tds[td_current]), 355 355 ehci_batch->tds[td_current].status, 356 356 ehci_batch->tds[td_current].next, … … 365 365 366 366 /** Transfer setup table. */ 367 static void (*const batch_setup[])(ehci_transfer_batch_t *) =368 {367 static void (*const batch_setup[])(ehci_transfer_batch_t *) = 368 { 369 369 [USB_TRANSFER_CONTROL] = batch_control, 370 370 [USB_TRANSFER_BULK] = batch_data,
Note:
See TracChangeset
for help on using the changeset viewer.