Changeset d1d7a92 in mainline for uspace/drv/bus/usb/xhci/trb_ring.c
- Timestamp:
- 2017-10-21T10:34:45Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8ea7459
- Parents:
- 1252e81
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/trb_ring.c
r1252e81 rd1d7a92 116 116 fibril_mutex_initialize(&ring->guard); 117 117 118 usb_log_debug ("Initialized new TRB ring.");118 usb_log_debug2("Initialized new TRB ring."); 119 119 120 120 return EOK; … … 156 156 157 157 /** 158 * Enqueue a TDcomposed of TRBs.159 * 160 * This will copy all TRBs chained together into the ring. The cycle flag in161 * TRBs may be changed.162 * 163 * The c hained TRBs must be contiguous in memory, and must not contain Link TRBs.158 * Enqueue TDs composed of TRBs. 159 * 160 * This will copy specified number of TRBs chained together into the ring. The 161 * cycle flag in TRBs may be changed. 162 * 163 * The copied TRBs must be contiguous in memory, and must not contain Link TRBs. 164 164 * 165 165 * We cannot avoid the copying, because the TRB in ring should be updated atomically. 166 166 * 167 * @param td the first TRB of TD 168 * @param phys returns address of the first TRB enqueued 167 * @param first_trb the first TRB 168 * @param trbs number of TRBS to enqueue 169 * @param phys returns address of the last TRB enqueued 169 170 * @return EOK on success, 170 171 * EAGAIN when the ring is too full to fit all TRBs (temporary) 171 172 */ 172 int xhci_trb_ring_enqueue(xhci_trb_ring_t *ring, xhci_trb_t *td, uintptr_t *phys) 173 { 173 int xhci_trb_ring_enqueue_multiple(xhci_trb_ring_t *ring, xhci_trb_t *first_trb, 174 size_t trbs, uintptr_t *phys) 175 { 176 assert(trbs > 0); 174 177 fibril_mutex_lock(&ring->guard); 175 178 … … 183 186 * be full anytime during the transaction. 184 187 */ 185 xhci_trb_t *trb = td;186 do{188 xhci_trb_t *trb = first_trb; 189 for (size_t i = 0; i < trbs; ++i, ++trb) { 187 190 ring->enqueue_trb++; 188 191 … … 192 195 if (trb_ring_enqueue_phys(ring) == ring->dequeue) 193 196 goto err_again; 194 } while (xhci_trb_is_chained(trb++));197 } 195 198 196 199 ring->enqueue_segment = saved_enqueue_segment; 197 200 ring->enqueue_trb = saved_enqueue_trb; 198 if (phys)199 *phys = trb_ring_enqueue_phys(ring);200 201 201 202 /* 202 203 * Now, copy the TRBs without further checking. 203 204 */ 204 trb = td; 205 do { 205 trb = first_trb; 206 for (size_t i = 0; i < trbs; ++i, ++trb) { 207 if (phys && i == trbs - 1) 208 *phys = trb_ring_enqueue_phys(ring); 209 206 210 xhci_trb_set_cycle(trb, ring->pcs); 207 211 xhci_trb_copy(ring->enqueue_trb, trb); … … 221 225 trb_ring_resolve_link(ring); 222 226 } 223 } while (xhci_trb_is_chained(trb++));227 } 224 228 225 229 fibril_mutex_unlock(&ring->guard); … … 234 238 235 239 /** 240 * Enqueue TD composed of a single TRB. See: `xhci_trb_ring_enqueue_multiple` 241 */ 242 int xhci_trb_ring_enqueue(xhci_trb_ring_t *ring, xhci_trb_t *td, uintptr_t *phys) 243 { 244 return xhci_trb_ring_enqueue_multiple(ring, td, 1, phys); 245 } 246 247 /** 236 248 * Initializes an event ring. 237 249 * Even when it fails, the structure needs to be finalized.
Note:
See TracChangeset
for help on using the changeset viewer.