Changeset a752c78c in mainline


Ignore:
Timestamp:
2014-01-25T07:07:54Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
23e5471
Parents:
6602e97
Message:

ehci: Implement batch error checking

Location:
uspace/drv/bus/usb/ehci
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/ehci_batch.c

    r6602e97 ra752c78c  
    206206                    ehci_batch->tds[i]->status, ehci_batch->tds[i]->next,
    207207                    ehci_batch->tds[i]->alternate);
    208 #if 0
     208
    209209                ehci_batch->usb_batch->error = td_error(ehci_batch->tds[i]);
    210210                if (ehci_batch->usb_batch->error == EOK) {
     
    227227                            ehci_batch->usb_batch, i,
    228228                            ehci_batch->tds[i]->status);
    229 
    230                         /* ED should be stopped because of errors */
    231                         assert((ehci_batch->ed->td_head & ED_TDHEAD_HALTED_FLAG) != 0);
    232 
    233                         /* Now we have a problem: we don't know what TD
    234                          * the head pointer points to, the retiring rules
    235                          * described in specs say it should be the one after
    236                          * the failed one so set the tail pointer accordingly.
    237                          * It will be the one TD we leave behind.
    238                          */
    239                         leave_td = i + 1;
    240 
    241                         /* Check TD assumption */
    242                         assert(ed_head_td(ehci_batch->ed) ==
    243                             addr_to_phys(ehci_batch->tds[leave_td]));
    244 
    245                         /* Set tail to the same TD */
    246                         ed_set_tail_td(ehci_batch->ed,
    247                             ehci_batch->tds[leave_td]);
    248 
    249229                        /* Clear possible ED HALT */
    250                         ed_clear_halt(ehci_batch->ed);
     230                        qh_clear_halt(ehci_batch->qh);
    251231                        break;
    252232                }
    253 #endif
    254233        }
    255234
    256235        assert(ehci_batch->usb_batch->transfered_size <=
    257236            ehci_batch->usb_batch->buffer_size);
    258 #if 0
    259         /* Store the remaining TD */
    260         ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ehci_batch->usb_batch->ep);
    261         assert(ehci_ep);
    262         ehci_ep->td = ehci_batch->tds[leave_td];
    263 
    264         /* Make sure that we are leaving the right TD behind */
    265         assert(addr_to_phys(ehci_ep->td) == ed_head_td(ehci_batch->ed));
    266         assert(addr_to_phys(ehci_ep->td) == ed_tail_td(ehci_batch->ed));
    267 #endif
     237        /* Clear TD pointers */
     238        ehci_batch->qh->next = LINK_POINTER_TERM;
     239        ehci_batch->qh->current = LINK_POINTER_TERM;
     240
    268241        return true;
    269242}
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.h

    r6602e97 ra752c78c  
    184184}
    185185
    186 static inline void qh_halt(qh_t *qh)
    187 {
    188         assert(qh);
    189         EHCI_MEM32_SET(qh->status, QH_STATUS_HALTED_FLAG);
     186static inline void qh_clear_halt(qh_t *qh)
     187{
     188        assert(qh);
     189        EHCI_MEM32_CLR(qh->status, QH_STATUS_HALTED_FLAG);
    190190}
    191191
  • uspace/drv/bus/usb/ehci/hw_struct/transfer_descriptor.c

    r6602e97 ra752c78c  
    3434
    3535#include <assert.h>
     36#include <errno.h>
    3637#include <macros.h>
    3738#include <mem.h>
     
    4041
    4142#include "../utils/malloc32.h"
    42 //#include "completion_codes.h"
    4343#include "mem_access.h"
    4444#include "transfer_descriptor.h"
     45
     46
     47int td_error(const td_t *td)
     48{
     49        assert(td);
     50        const uint32_t status = EHCI_MEM32_RD(td->status);
     51        if (status & TD_STATUS_HALTED_FLAG) {
     52                if (status & TD_STATUS_TRANS_ERR_FLAG)
     53                        return EIO;
     54                if (status & TD_STATUS_BABBLE_FLAG)
     55                        return EIO;
     56                if (status & TD_STATUS_BUFF_ERROR_FLAG)
     57                        return EOVERFLOW;
     58                return ESTALL;
     59        }
     60        if (status & TD_STATUS_ACTIVE_FLAG)
     61                return EINPROGRESS;
     62        return EOK;
     63}
    4564
    4665/** USB direction to EHCI TD values translation table */
  • uspace/drv/bus/usb/ehci/hw_struct/transfer_descriptor.h

    r6602e97 ra752c78c  
    7373} td_t;
    7474
     75static inline bool td_active(const td_t *td)
     76{
     77        assert(td);
     78        return (EHCI_MEM32_RD(td->status) & TD_STATUS_HALTED_FLAG) != 0;
     79}
     80
     81static inline size_t td_remain_size(const td_t *td)
     82{
     83        assert(td);
     84        return (EHCI_MEM32_RD(td->status) >> TD_STATUS_TOTAL_SHIFT) &
     85            TD_STATUS_TOTAL_MASK;
     86}
     87
     88int td_error(const td_t *td);
     89
    7590void td_init(td_t *td, const td_t *next, usb_direction_t dir, const void * buf,
    7691    size_t buf_size, int toggle);
Note: See TracChangeset for help on using the changeset viewer.