Changeset 63adb18 in mainline for uspace/drv/bus/usb/xhci/transfers.c
- Timestamp:
- 2017-10-11T18:53:03Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7e74911
- Parents:
- eaf5e86
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/transfers.c
reaf5e86 r63adb18 292 292 return EOK; 293 293 } 294 295 xhci_transfer_block_t* xhci_transfer_block_alloc(size_t buffer_size) 296 { 297 assert(buffer_size); 298 299 xhci_transfer_block_t *block = malloc(sizeof(xhci_transfer_block_t)); 300 block->buffer = (uintptr_t) malloc32(buffer_size); 301 block->total_size = buffer_size; 302 block->filled_size = 0; 303 304 return block; 305 } 306 307 void xhci_transfer_block_fini(xhci_transfer_block_t* block) 308 { 309 assert(block); 310 311 free32((void*) block->buffer); 312 free(block); 313 } 314 315 int xhci_dequeue_transfer_block(xhci_hc_t* hc, size_t size, xhci_transfer_block_t** block) 316 { 317 // TODO: obtain block from some global structure at HC 318 319 *block = xhci_transfer_block_alloc(size); 320 return EOK; 321 } 322 323 int xhci_free_transfer_block(xhci_hc_t* hc, xhci_transfer_block_t* block) 324 { 325 assert(block); 326 327 // TODO: check if the block is not used? 328 // TODO: recycle block in some global structure at HC 329 xhci_transfer_block_fini(block); 330 331 return EOK; 332 } 333 334 int xhci_schedule_transfer_block(xhci_hc_t* hc, xhci_transfer_block_t* block) 335 { 336 usb_transfer_batch_t* batch = block->transfer->batch; 337 uint8_t slot_id = batch->ep->hc_data.slot_id; 338 xhci_trb_ring_t* ring = hc->dcbaa_virt[slot_id].trs[batch->ep->endpoint]; 339 340 xhci_trb_t trb; 341 memset(&trb, 0, sizeof(xhci_trb_t)); 342 trb.parameter = block->buffer; 343 344 TRB_CTRL_SET_XFER_LEN(trb, block->filled_size); 345 // FIXME: TD size 4.11.2.4 346 TRB_CTRL_SET_TD_SIZE(trb, 1); 347 348 // we want an interrupt after this td is done 349 TRB_CTRL_SET_IOC(trb, 1); 350 TRB_CTRL_SET_TRB_TYPE(trb, XHCI_TRB_TYPE_NORMAL); 351 xhci_trb_ring_enqueue(ring, &trb, &block->transfer->interrupt_trb_phys); 352 353 // FIXME: Check return from xhci_trb_ring_enqueue. 354 355 hc_ring_doorbell(hc, slot_id, 1); 356 return EOK; 357 }
Note:
See TracChangeset
for help on using the changeset viewer.