Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset d1e580a in mainline for uspace/drv/bus/usb/ohci/ohci_batch.c


Ignore:
Timestamp:
2012-07-29T03:07:52Z (9 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master
Children:
10334c2e
Parents:
d7c8e39f (diff), b2ba418 (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.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/ohci_batch.c

    rd7c8e39f rd1e580a  
    4444
    4545static void (*const batch_setup[])(ohci_transfer_batch_t*, usb_direction_t);
    46 /*----------------------------------------------------------------------------*/
     46
    4747/** Safely destructs ohci_transfer_batch_t structure
    4848 *
     
    6767        free(ohci_batch);
    6868}
    69 /*----------------------------------------------------------------------------*/
     69
    7070/** Finishes usb_transfer_batch and destroys the structure.
    7171 *
     
    8080        ohci_transfer_batch_dispose(ohci_batch);
    8181}
    82 /*----------------------------------------------------------------------------*/
     82
    8383/** Allocate memory and initialize internal data structure.
    8484 *
     
    158158#undef CHECK_NULL_DISPOSE_RET
    159159}
    160 /*----------------------------------------------------------------------------*/
     160
    161161/** Check batch TDs' status.
    162162 *
     
    199199                    ohci_batch->tds[i]->next, ohci_batch->tds[i]->be);
    200200
    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 
    215201                ohci_batch->usb_batch->error = td_error(ohci_batch->tds[i]);
    216                 if (ohci_batch->usb_batch->error != EOK) {
     202                if (ohci_batch->usb_batch->error == EOK) {
     203                        /* If the TD got all its data through, it will report
     204                         * 0 bytes remain, the sole exception is INPUT with
     205                         * data rounding flag (short), i.e. every INPUT.
     206                         * Nice thing is that short packets will correctly
     207                         * report remaining data, thus making this computation
     208                         * correct (short packets need to be produced by the
     209                         * last TD)
     210                         * NOTE: This also works for CONTROL transfer as
     211                         * the first TD will return 0 remain.
     212                         * NOTE: Short packets don't break the assumption that
     213                         * we leave the very last(unused) TD behind.
     214                         */
     215                        ohci_batch->usb_batch->transfered_size
     216                            -= td_remain_size(ohci_batch->tds[i]);
     217                } else {
    217218                        usb_log_debug("Batch %p found error TD(%zu):%08x.\n",
    218219                            ohci_batch->usb_batch, i,
     
    231232
    232233                        /* 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 
     234                        assert(ed_head_td(ohci_batch->ed) ==
     235                            addr_to_phys(ohci_batch->tds[leave_td]));
     236
     237                        /* Set tail to the same TD */
    238238                        ed_set_tail_td(ohci_batch->ed,
    239239                            ohci_batch->tds[leave_td]);
    240240
    241241                        /* Clear possible ED HALT */
    242                         ohci_batch->ed->td_head &= ~ED_TDHEAD_HALTED_FLAG;
     242                        ed_clear_halt(ohci_batch->ed);
    243243                        break;
    244244                }
     
    253253
    254254        /* 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));
     255        assert(addr_to_phys(ohci_ep->td) == ed_head_td(ohci_batch->ed));
     256        assert(addr_to_phys(ohci_ep->td) == ed_tail_td(ohci_batch->ed));
    258257
    259258        return true;
    260259}
    261 /*----------------------------------------------------------------------------*/
     260
    262261/** Starts execution of the TD list
    263262 *
     
    269268        ed_set_tail_td(ohci_batch->ed, ohci_batch->tds[ohci_batch->td_count]);
    270269}
    271 /*----------------------------------------------------------------------------*/
     270
    272271/** Prepare generic control transfer
    273272 *
     
    345344            USB_TRANSFER_BATCH_ARGS(*ohci_batch->usb_batch));
    346345}
    347 /*----------------------------------------------------------------------------*/
     346
    348347/** Prepare generic data transfer
    349348 *
     
    392391            USB_TRANSFER_BATCH_ARGS(*ohci_batch->usb_batch));
    393392}
    394 /*----------------------------------------------------------------------------*/
     393
    395394/** Transfer setup table. */
    396395static void (*const batch_setup[])(ohci_transfer_batch_t*, usb_direction_t) =
Note: See TracChangeset for help on using the changeset viewer.