Changeset c21e6a5 in mainline for uspace/drv/bus/usb/uhci/uhci_batch.c
- Timestamp:
- 2018-02-05T00:54:08Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- af16ebe
- Parents:
- 65c059f
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-02-05 00:27:40)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-02-05 00:54:08)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/uhci_batch.c
r65c059f rc21e6a5 61 61 { 62 62 assert(uhci_batch); 63 free32(uhci_batch->device_buffer);63 dma_buffer_free(&uhci_batch->uhci_dma_buffer); 64 64 free(uhci_batch); 65 65 } … … 110 110 111 111 const size_t total_size = (sizeof(td_t) * uhci_batch->td_count) 112 + sizeof(qh_t) + setup_size + usb_batch->buffer_size;113 uhci_batch->device_buffer = malloc32(total_size); 114 if ( !uhci_batch->device_buffer) {112 + sizeof(qh_t) + setup_size; 113 114 if (dma_buffer_alloc(&uhci_batch->uhci_dma_buffer, total_size)) { 115 115 usb_log_error("Failed to allocate UHCI buffer."); 116 116 return ENOMEM; 117 117 } 118 memset(uhci_batch->device_buffer, 0, total_size); 119 120 uhci_batch->tds = uhci_batch->device_buffer; 121 uhci_batch->qh = 122 (uhci_batch->device_buffer + (sizeof(td_t) * uhci_batch->td_count)); 118 memset(uhci_batch->uhci_dma_buffer.virt, 0, total_size); 119 120 uhci_batch->tds = uhci_batch->uhci_dma_buffer.virt; 121 uhci_batch->qh = (qh_t *) &uhci_batch->tds[uhci_batch->td_count]; 123 122 124 123 qh_init(uhci_batch->qh); 125 124 qh_set_element_td(uhci_batch->qh, &uhci_batch->tds[0]); 126 125 127 void *dest = 128 uhci_batch->device_buffer + (sizeof(td_t) * uhci_batch->td_count) 129 + sizeof(qh_t); 126 void *setup_buffer = uhci_transfer_batch_setup_buffer(uhci_batch); 127 assert(setup_buffer == (void *) (uhci_batch->qh + 1)); 130 128 /* Copy SETUP packet data to the device buffer */ 131 memcpy(dest, usb_batch->setup.buffer, setup_size); 132 dest += setup_size; 133 /* Copy generic data unless they are provided by the device */ 134 if (usb_batch->dir != USB_DIRECTION_IN) { 135 memcpy(dest, usb_batch->buffer, usb_batch->buffer_size); 136 } 129 memcpy(setup_buffer, usb_batch->setup.buffer, setup_size); 130 137 131 usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT 138 132 " memory structures ready.", usb_batch, … … 196 190 } 197 191 198 if (batch->dir == USB_DIRECTION_IN) { 199 assert(batch->transferred_size <= batch->buffer_size); 200 memcpy(batch->buffer, 201 uhci_transfer_batch_data_buffer(uhci_batch), 202 batch->transferred_size); 203 } 192 assert(batch->transferred_size <= batch->buffer_size); 204 193 205 194 return true;
Note:
See TracChangeset
for help on using the changeset viewer.