Changes in / [e099f26:31b568e] in mainline


Ignore:
Location:
uspace
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/transfer_list.c

    re099f26 r31b568e  
    7979        if (!instance->queue_head)
    8080                return;
    81         /* Set both queue_head.next to point to the follower */
     81        /* Set both next and element to point to the same QH */
    8282        qh_set_next_qh(instance->queue_head, next->queue_head_pa);
     83        qh_set_element_qh(instance->queue_head, next->queue_head_pa);
    8384}
    8485/*----------------------------------------------------------------------------*/
     
    9798        usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, batch);
    9899
     100        const uint32_t pa = addr_to_phys(batch_qh(batch));
     101        assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
     102
     103        /* New batch will be added to the end of the current list
     104         * so set the link accordingly */
     105        qh_set_next_qh(batch_qh(batch), instance->queue_head->next);
     106
    99107        fibril_mutex_lock(&instance->guard);
    100108
    101         qh_t *last_qh = NULL;
    102109        /* Add to the hardware queue. */
    103110        if (list_empty(&instance->batch_list)) {
    104111                /* There is nothing scheduled */
    105                 last_qh = instance->queue_head;
     112                qh_t *qh = instance->queue_head;
     113                assert(qh->element == qh->next);
     114                qh_set_element_qh(qh, pa);
    106115        } else {
    107116                /* There is something scheduled */
    108117                usb_transfer_batch_t *last = list_get_instance(
    109118                    instance->batch_list.prev, usb_transfer_batch_t, link);
    110                 last_qh = batch_qh(last);
    111         }
    112         const uint32_t pa = addr_to_phys(batch->qh);
    113         assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
    114 
    115         /* keep link */
    116         batch_qh(batch)->next = last_qh->next;
    117         qh_set_next_qh(last_qh, pa);
    118 
     119                qh_set_next_qh(batch_qh(last), pa);
     120        }
    119121        /* Add to the driver list */
    120122        list_append(&batch->link, &instance->batch_list);
     
    172174{
    173175        fibril_mutex_lock(&instance->guard);
    174         while (!list_empty(&instance->batch_list)) {
     176        while (list_empty(&instance->batch_list)) {
    175177                link_t *current = instance->batch_list.next;
    176178                usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link);
     
    195197        assert(batch);
    196198        assert(batch_qh(batch));
    197         assert(fibril_mutex_is_locked(&instance->guard));
    198 
    199199        usb_log_debug2(
    200200            "Queue %s: removing batch(%p).\n", instance->name, batch);
    201201
    202         const char *qpos = NULL;
     202        const char * pos = NULL;
    203203        /* Remove from the hardware queue */
    204         if (instance->batch_list.next == &batch->link) {
     204        if (batch->link.prev == &instance->batch_list) {
    205205                /* I'm the first one here */
    206                 assert((instance->queue_head->next & LINK_POINTER_ADDRESS_MASK)
    207                     == addr_to_phys(bathc_qh(batch)));
    208                 instance->queue_head->next = batch_qh(batch)->next;
    209                 qpos = "FIRST";
     206                qh_set_element_qh(instance->queue_head, batch_qh(batch)->next);
     207                pos = "FIRST";
    210208        } else {
    211209                usb_transfer_batch_t *prev =
    212210                    list_get_instance(batch->link.prev, usb_transfer_batch_t, link);
    213                 assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK)
    214                     == addr_to_phys(batch_qh(batch)));
    215                 batch_qh(prev)->next = batch_qh(batch)->next;
    216                 qpos = "NOT FIRST";
    217         }
    218         /* Remove from the batch list */
     211                qh_set_next_qh(batch_qh(prev), batch_qh(batch)->next);
     212                pos = "NOT FIRST";
     213        }
     214        /* Remove from the driver list */
    219215        list_remove(&batch->link);
    220         usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n",
     216        usb_log_debug("Batch(%p) removed (%s) from %s, next element %x.\n",
    221217            batch, pos, instance->name, batch_qh(batch)->next);
    222218}
  • uspace/drv/uhci-hcd/uhci_hc.c

    re099f26 r31b568e  
    125125        }
    126126
    127         instance->debug_checker =
    128             fibril_create(uhci_hc_debug_checker, instance);
    129 //      fibril_add_ready(instance->debug_checker);
     127        instance->debug_checker = fibril_create(uhci_hc_debug_checker, instance);
     128        fibril_add_ready(instance->debug_checker);
    130129
    131130        return EOK;
  • uspace/drv/uhci-hcd/uhci_struct/link_pointer.h

    re099f26 r31b568e  
    4949        ((address & LINK_POINTER_ADDRESS_MASK) | LINK_POINTER_QUEUE_HEAD_FLAG)
    5050
    51 #define LINK_POINTER_TD(address) \
    52         (address & LINK_POINTER_ADDRESS_MASK)
    53 
    54 #define LINK_POINTER_TERM \
    55         ((link_pointer_t)LINK_POINTER_TERMINATE_FLAG)
    56 
    5751#endif
    5852/**
  • uspace/drv/uhci-hcd/uhci_struct/queue_head.h

    re099f26 r31b568e  
    7272        /* Address is valid and not terminal */
    7373        if (pa && ((pa & LINK_POINTER_TERMINATE_FLAG) == 0)) {
    74                 instance->next = LINK_POINTER_QH(pa);
     74                instance->next = (pa & LINK_POINTER_ADDRESS_MASK)
     75                    | LINK_POINTER_QUEUE_HEAD_FLAG;
    7576        } else {
    76                 instance->next = LINK_POINTER_TERM;
     77                instance->next = 0 | LINK_POINTER_TERMINATE_FLAG;
    7778        }
    7879}
     
    9091        /* Address is valid and not terminal */
    9192        if (pa && ((pa & LINK_POINTER_TERMINATE_FLAG) == 0)) {
    92                 instance->element = LINK_POINTER_QH(pa);
     93                instance->element = (pa & LINK_POINTER_ADDRESS_MASK)
     94                    | LINK_POINTER_QUEUE_HEAD_FLAG;
    9395        } else {
    94                 instance->element = LINK_POINTER_TERM;
     96                instance->element = 0 | LINK_POINTER_TERMINATE_FLAG;
    9597        }
    9698}
     
    107109{
    108110        if (pa && ((pa & LINK_POINTER_TERMINATE_FLAG) == 0)) {
    109                 instance->element = LINK_POINTER_TD(pa);
     111                instance->element = (pa & LINK_POINTER_ADDRESS_MASK);
    110112        } else {
    111                 instance->element = LINK_POINTER_TERM;
     113                instance->element = 0 | LINK_POINTER_TERMINATE_FLAG;
    112114        }
    113115}
  • uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c

    re099f26 r31b568e  
    6969            || (pid == USB_PID_OUT));
    7070
    71         const uint32_t next_pa = addr_to_phys(next);
    72         assert((next_pa & LINK_POINTER_ADDRESS_MASK) == next_pa);
    73 
    7471        instance->next = 0
    7572            | LINK_POINTER_VERTICAL_FLAG
    76             | (next_pa ? next_pa : LINK_POINTER_TERMINATE_FLAG);
     73            | ((next != NULL) ? addr_to_phys(next) : LINK_POINTER_TERMINATE_FLAG);
    7774
    7875        instance->status = 0
     
    9390            | ((pid & TD_DEVICE_PID_MASK) << TD_DEVICE_PID_POS);
    9491
    95         instance->buffer_ptr = addr_to_phys(buffer);
     92        instance->buffer_ptr = 0;
     93
     94        if (size) {
     95                instance->buffer_ptr = (uintptr_t)addr_to_phys(buffer);
     96        }
    9697
    9798        usb_log_debug2("Created TD(%p): %X:%X:%X:%X(%p).\n",
     
    114115        assert(instance);
    115116
    116         /* this is hc internal error it should never be reported */
    117         if ((instance->status & TD_STATUS_ERROR_BIT_STUFF) != 0)
    118                 return EAGAIN;
     117        if ((instance->status & TD_STATUS_ERROR_STALLED) != 0)
     118                return ESTALL;
    119119
    120         /* CRC or timeout error, like device not present or bad data,
    121          * it won't be reported unless err count reached zero */
    122120        if ((instance->status & TD_STATUS_ERROR_CRC) != 0)
    123121                return EBADCHECKSUM;
    124122
    125         /* hc does not end transaction on these, it should never be reported */
     123        if ((instance->status & TD_STATUS_ERROR_BUFFER) != 0)
     124                return EAGAIN;
     125
     126        if ((instance->status & TD_STATUS_ERROR_BABBLE) != 0)
     127                return EIO;
     128
    126129        if ((instance->status & TD_STATUS_ERROR_NAK) != 0)
    127130                return EAGAIN;
    128131
    129         /* buffer overrun or underrun */
    130         if ((instance->status & TD_STATUS_ERROR_BUFFER) != 0)
    131                 return ERANGE;
    132 
    133         /* device babble is something serious */
    134         if ((instance->status & TD_STATUS_ERROR_BABBLE) != 0)
    135                 return EIO;
    136 
    137         /* stall might represent err count reaching zero or stall response from
    138          * the device, is err count reached zero, one of the above is reported*/
    139         if ((instance->status & TD_STATUS_ERROR_STALLED) != 0)
    140                 return ESTALL;
     132        if ((instance->status & TD_STATUS_ERROR_BIT_STUFF) != 0)
     133                return EAGAIN;
    141134
    142135        return EOK;
  • uspace/drv/uhci-hcd/utils/malloc32.h

    re099f26 r31b568e  
    5050static inline uintptr_t addr_to_phys(void *addr)
    5151{
    52         if (addr == NULL)
    53                 return 0;
    54 
    5552        uintptr_t result;
    5653        int ret = as_get_physical_mapping(addr, &result);
  • uspace/lib/usb/src/host/device_keeper.c

    re099f26 r31b568e  
    214214        fibril_mutex_lock(&instance->guard);
    215215
    216         usb_address_t new_address = instance->last_address;
    217         do {
    218                 ++new_address;
    219                 if (new_address > USB11_ADDRESS_MAX)
    220                         new_address = 1;
     216        usb_address_t new_address = instance->last_address + 1;
     217        while (instance->devices[new_address].occupied) {
    221218                if (new_address == instance->last_address) {
    222219                        fibril_mutex_unlock(&instance->guard);
    223220                        return ENOSPC;
    224221                }
    225         } while (instance->devices[new_address].occupied);
     222                if (new_address == USB11_ADDRESS_MAX)
     223                        new_address = 1;
     224                ++new_address;
     225        }
    226226
    227227        assert(new_address != USB_ADDRESS_DEFAULT);
Note: See TracChangeset for help on using the changeset viewer.