Changes in / [e099f26:31b568e] in mainline
- Location:
- uspace
- Files:
-
- 1 added
- 7 edited
-
drv/uhci-hcd/transfer_list.c (modified) (4 diffs)
-
drv/uhci-hcd/transfers.c (added)
-
drv/uhci-hcd/uhci_hc.c (modified) (1 diff)
-
drv/uhci-hcd/uhci_struct/link_pointer.h (modified) (1 diff)
-
drv/uhci-hcd/uhci_struct/queue_head.h (modified) (3 diffs)
-
drv/uhci-hcd/uhci_struct/transfer_descriptor.c (modified) (3 diffs)
-
drv/uhci-hcd/utils/malloc32.h (modified) (1 diff)
-
lib/usb/src/host/device_keeper.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/transfer_list.c
re099f26 r31b568e 79 79 if (!instance->queue_head) 80 80 return; 81 /* Set both queue_head.next to point to the follower*/81 /* Set both next and element to point to the same QH */ 82 82 qh_set_next_qh(instance->queue_head, next->queue_head_pa); 83 qh_set_element_qh(instance->queue_head, next->queue_head_pa); 83 84 } 84 85 /*----------------------------------------------------------------------------*/ … … 97 98 usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, batch); 98 99 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 99 107 fibril_mutex_lock(&instance->guard); 100 108 101 qh_t *last_qh = NULL;102 109 /* Add to the hardware queue. */ 103 110 if (list_empty(&instance->batch_list)) { 104 111 /* 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); 106 115 } else { 107 116 /* There is something scheduled */ 108 117 usb_transfer_batch_t *last = list_get_instance( 109 118 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 } 119 121 /* Add to the driver list */ 120 122 list_append(&batch->link, &instance->batch_list); … … 172 174 { 173 175 fibril_mutex_lock(&instance->guard); 174 while ( !list_empty(&instance->batch_list)) {176 while (list_empty(&instance->batch_list)) { 175 177 link_t *current = instance->batch_list.next; 176 178 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link); … … 195 197 assert(batch); 196 198 assert(batch_qh(batch)); 197 assert(fibril_mutex_is_locked(&instance->guard));198 199 199 usb_log_debug2( 200 200 "Queue %s: removing batch(%p).\n", instance->name, batch); 201 201 202 const char * qpos = NULL;202 const char * pos = NULL; 203 203 /* Remove from the hardware queue */ 204 if ( instance->batch_list.next == &batch->link) {204 if (batch->link.prev == &instance->batch_list) { 205 205 /* 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"; 210 208 } else { 211 209 usb_transfer_batch_t *prev = 212 210 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 */ 219 215 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", 221 217 batch, pos, instance->name, batch_qh(batch)->next); 222 218 } -
uspace/drv/uhci-hcd/uhci_hc.c
re099f26 r31b568e 125 125 } 126 126 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); 130 129 131 130 return EOK; -
uspace/drv/uhci-hcd/uhci_struct/link_pointer.h
re099f26 r31b568e 49 49 ((address & LINK_POINTER_ADDRESS_MASK) | LINK_POINTER_QUEUE_HEAD_FLAG) 50 50 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 57 51 #endif 58 52 /** -
uspace/drv/uhci-hcd/uhci_struct/queue_head.h
re099f26 r31b568e 72 72 /* Address is valid and not terminal */ 73 73 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; 75 76 } else { 76 instance->next = LINK_POINTER_TERM;77 instance->next = 0 | LINK_POINTER_TERMINATE_FLAG; 77 78 } 78 79 } … … 90 91 /* Address is valid and not terminal */ 91 92 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; 93 95 } else { 94 instance->element = LINK_POINTER_TERM;96 instance->element = 0 | LINK_POINTER_TERMINATE_FLAG; 95 97 } 96 98 } … … 107 109 { 108 110 if (pa && ((pa & LINK_POINTER_TERMINATE_FLAG) == 0)) { 109 instance->element = LINK_POINTER_TD(pa);111 instance->element = (pa & LINK_POINTER_ADDRESS_MASK); 110 112 } else { 111 instance->element = LINK_POINTER_TERM;113 instance->element = 0 | LINK_POINTER_TERMINATE_FLAG; 112 114 } 113 115 } -
uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c
re099f26 r31b568e 69 69 || (pid == USB_PID_OUT)); 70 70 71 const uint32_t next_pa = addr_to_phys(next);72 assert((next_pa & LINK_POINTER_ADDRESS_MASK) == next_pa);73 74 71 instance->next = 0 75 72 | LINK_POINTER_VERTICAL_FLAG 76 | ( next_pa ? next_pa: LINK_POINTER_TERMINATE_FLAG);73 | ((next != NULL) ? addr_to_phys(next) : LINK_POINTER_TERMINATE_FLAG); 77 74 78 75 instance->status = 0 … … 93 90 | ((pid & TD_DEVICE_PID_MASK) << TD_DEVICE_PID_POS); 94 91 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 } 96 97 97 98 usb_log_debug2("Created TD(%p): %X:%X:%X:%X(%p).\n", … … 114 115 assert(instance); 115 116 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; 119 119 120 /* CRC or timeout error, like device not present or bad data,121 * it won't be reported unless err count reached zero */122 120 if ((instance->status & TD_STATUS_ERROR_CRC) != 0) 123 121 return EBADCHECKSUM; 124 122 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 126 129 if ((instance->status & TD_STATUS_ERROR_NAK) != 0) 127 130 return EAGAIN; 128 131 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; 141 134 142 135 return EOK; -
uspace/drv/uhci-hcd/utils/malloc32.h
re099f26 r31b568e 50 50 static inline uintptr_t addr_to_phys(void *addr) 51 51 { 52 if (addr == NULL)53 return 0;54 55 52 uintptr_t result; 56 53 int ret = as_get_physical_mapping(addr, &result); -
uspace/lib/usb/src/host/device_keeper.c
re099f26 r31b568e 214 214 fibril_mutex_lock(&instance->guard); 215 215 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) { 221 218 if (new_address == instance->last_address) { 222 219 fibril_mutex_unlock(&instance->guard); 223 220 return ENOSPC; 224 221 } 225 } while (instance->devices[new_address].occupied); 222 if (new_address == USB11_ADDRESS_MAX) 223 new_address = 1; 224 ++new_address; 225 } 226 226 227 227 assert(new_address != USB_ADDRESS_DEFAULT);
Note:
See TracChangeset
for help on using the changeset viewer.
