Changeset 35c37fc in mainline
- Timestamp:
- 2018-01-05T20:15:08Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9e5b162
- Parents:
- b60944b
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-05 16:11:04)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-05 20:15:08)
- Location:
- uspace
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/ehci_batch.c
rb60944b r35c37fc 42 42 #include <usb/usb.h> 43 43 #include <usb/debug.h> 44 #include <usb/host/utils/malloc32.h>45 44 46 45 #include "ehci_batch.h" … … 62 61 { 63 62 assert(ehci_batch); 64 if (ehci_batch->tds) { 65 for (size_t i = 0; i < ehci_batch->td_count; ++i) { 66 free32(ehci_batch->tds[i]); 67 } 68 free(ehci_batch->tds); 69 } 70 free32(ehci_batch->device_buffer); 63 dma_buffer_free(&ehci_batch->dma_buffer); 71 64 free(ehci_batch); 72 65 usb_log_debug2("Batch(%p): disposed", ehci_batch); … … 112 105 const size_t size = ehci_batch->base.buffer_size; 113 106 114 /* Mix setup stage and data together, we have enough space */ 115 if (size + setup_size > 0) { 116 /* Use one buffer for setup and data stage */ 117 ehci_batch->device_buffer = malloc32(size + setup_size); 118 if (!ehci_batch->device_buffer) { 107 /* Add TD left over by the previous transfer */ 108 ehci_batch->qh = ehci_endpoint_get(ehci_batch->base.ep)->qh; 109 110 /* Determine number of TDs needed */ 111 ehci_batch->td_count = (size + EHCI_TD_MAX_TRANSFER - 1) 112 / EHCI_TD_MAX_TRANSFER; 113 114 /* Control transfer need Setup and Status stage */ 115 if (ehci_batch->base.ep->transfer_type == USB_TRANSFER_CONTROL) { 116 ehci_batch->td_count += 2; 117 } 118 119 const size_t tds_size = ehci_batch->td_count * sizeof(td_t); 120 121 /* Mix setup stage, data and TDs together, we have enough space */ 122 if (size + setup_size + tds_size > 0) { 123 if (dma_buffer_alloc(&ehci_batch->dma_buffer, tds_size + setup_size + size)) { 119 124 usb_log_error("Batch %p: Failed to allocate device " 120 125 "buffer", ehci_batch); 121 126 return ENOMEM; 122 127 } 128 /* Clean TDs */ 129 ehci_batch->tds = ehci_batch->dma_buffer.virt; 130 memset(ehci_batch->tds, 0, tds_size); 123 131 /* Copy setup data */ 124 memcpy(ehci_batch->device_buffer, ehci_batch->base.setup.buffer, 125 132 ehci_batch->setup_buffer = ehci_batch->dma_buffer.virt + tds_size; 133 memcpy(ehci_batch->setup_buffer, ehci_batch->base.setup.buffer, setup_size); 126 134 /* Copy generic data */ 135 ehci_batch->data_buffer = ehci_batch->setup_buffer + setup_size; 127 136 if (ehci_batch->base.dir != USB_DIRECTION_IN) 128 memcpy(ehci_batch->device_buffer + setup_size, 129 ehci_batch->base.buffer, ehci_batch->base.buffer_size); 130 } 131 132 /* Add TD left over by the previous transfer */ 133 ehci_batch->qh = ehci_endpoint_get(ehci_batch->base.ep)->qh; 134 135 /* Determine number of TDs needed */ 136 ehci_batch->td_count = (size + EHCI_TD_MAX_TRANSFER - 1) 137 / EHCI_TD_MAX_TRANSFER; 138 139 /* Control transfer need Setup and Status stage */ 140 if (ehci_batch->base.ep->transfer_type == USB_TRANSFER_CONTROL) { 141 ehci_batch->td_count += 2; 142 } 143 144 ehci_batch->tds = calloc(ehci_batch->td_count, sizeof(td_t*)); 145 if (!ehci_batch->tds) { 146 usb_log_error("Batch %p: Failed to allocate EHCI transfer " 147 "descriptors.", ehci_batch); 148 return ENOMEM; 149 } 150 151 for (unsigned i = 0; i < ehci_batch->td_count; ++i) { 152 ehci_batch->tds[i] = malloc32(sizeof(td_t)); 153 if (!ehci_batch->tds[i]) { 154 usb_log_error("Batch %p: Failed to allocate TD %d.", 155 ehci_batch, i); 156 return ENOMEM; 157 } 158 memset(ehci_batch->tds[i], 0, sizeof(td_t)); 137 memcpy(ehci_batch->data_buffer, 138 ehci_batch->base.buffer, 139 ehci_batch->base.buffer_size); 159 140 } 160 141 … … 203 184 /* Check all TDs */ 204 185 for (size_t i = 0; i < ehci_batch->td_count; ++i) { 205 assert(ehci_batch->tds[i] != NULL);206 186 usb_log_debug("Batch %p: TD %zu: %08x:%08x:%08x.", 207 187 ehci_batch, i, 208 ehci_batch->tds[i] ->status, ehci_batch->tds[i]->next,209 ehci_batch->tds[i] ->alternate);210 211 ehci_batch->base.error = td_error( ehci_batch->tds[i]);188 ehci_batch->tds[i].status, ehci_batch->tds[i].next, 189 ehci_batch->tds[i].alternate); 190 191 ehci_batch->base.error = td_error(&ehci_batch->tds[i]); 212 192 if (ehci_batch->base.error == EOK) { 213 193 /* If the TD got all its data through, it will report … … 224 204 */ 225 205 ehci_batch->base.transfered_size 226 -= td_remain_size( ehci_batch->tds[i]);206 -= td_remain_size(&ehci_batch->tds[i]); 227 207 } else { 228 208 usb_log_debug("Batch %p found error TD(%zu):%08x (%d).", 229 209 ehci_batch, i, 230 ehci_batch->tds[i] ->status,210 ehci_batch->tds[i].status, 231 211 ehci_batch->base.error); 232 212 /* Clear possible ED HALT */ … … 238 218 assert(ehci_batch->base.transfered_size <= ehci_batch->base.buffer_size); 239 219 240 const size_t setup_size = (ehci_batch->base.ep->transfer_type == USB_TRANSFER_CONTROL)241 ? USB_SETUP_PACKET_SIZE242 : 0;243 244 220 if (ehci_batch->base.dir == USB_DIRECTION_IN) 245 221 memcpy(ehci_batch->base.buffer, 246 ehci_batch->d evice_buffer + setup_size,222 ehci_batch->data_buffer, 247 223 ehci_batch->base.transfered_size); 248 224 … … 263 239 { 264 240 assert(ehci_batch); 265 qh_set_next_td(ehci_batch->qh, ehci_batch->tds[0]);241 qh_set_next_td(ehci_batch->qh, dma_buffer_phys(&ehci_batch->dma_buffer, &ehci_batch->tds[0])); 266 242 } 267 243 … … 281 257 assert(dir == USB_DIRECTION_IN || dir == USB_DIRECTION_OUT); 282 258 283 usb_log_debug2("Batch %p: Control QH(% "PRIxn"): "259 usb_log_debug2("Batch %p: Control QH(%p): " 284 260 "%08x:%08x:%08x:%08x:%08x:%08x", ehci_batch, 285 addr_to_phys(ehci_batch->qh),261 ehci_batch->qh, 286 262 ehci_batch->qh->ep_char, ehci_batch->qh->ep_cap, 287 263 ehci_batch->qh->status, ehci_batch->qh->current, … … 293 269 294 270 int toggle = 0; 295 const char* buffer = ehci_batch->device_buffer;296 271 const usb_direction_t data_dir = dir; 297 272 const usb_direction_t status_dir = reverse_dir[dir]; 298 273 299 274 /* Setup stage */ 300 td_init(ehci_batch->tds[0], ehci_batch->tds[1], USB_DIRECTION_BOTH, 301 buffer, USB_SETUP_PACKET_SIZE, toggle, false); 275 td_init(&ehci_batch->tds[0], 276 dma_buffer_phys(&ehci_batch->dma_buffer, &ehci_batch->tds[1]), 277 dma_buffer_phys(&ehci_batch->dma_buffer, ehci_batch->setup_buffer), 278 USB_DIRECTION_BOTH, USB_SETUP_PACKET_SIZE, toggle, false); 302 279 usb_log_debug2("Batch %p: Created CONTROL SETUP TD(%"PRIxn"): " 303 280 "%08x:%08x:%08x", ehci_batch, 304 addr_to_phys(ehci_batch->tds[0]), 305 ehci_batch->tds[0]->status, ehci_batch->tds[0]->next, 306 ehci_batch->tds[0]->alternate); 307 buffer += USB_SETUP_PACKET_SIZE; 281 dma_buffer_phys(&ehci_batch->dma_buffer, &ehci_batch->tds[0]), 282 ehci_batch->tds[0].status, ehci_batch->tds[0].next, 283 ehci_batch->tds[0].alternate); 308 284 309 285 /* Data stage */ 310 size_ttd_current = 1;286 unsigned td_current = 1; 311 287 size_t remain_size = ehci_batch->base.buffer_size; 288 uintptr_t buffer = dma_buffer_phys(&ehci_batch->dma_buffer, ehci_batch->data_buffer); 312 289 while (remain_size > 0) { 313 const size_t transfer_size = 314 min(remain_size, EHCI_TD_MAX_TRANSFER); 290 const size_t transfer_size = min(remain_size, EHCI_TD_MAX_TRANSFER); 315 291 toggle = 1 - toggle; 316 292 317 td_init( ehci_batch->tds[td_current],318 ehci_batch->tds[td_current + 1], data_dir, buffer,319 transfer_size, toggle, false);293 td_init(&ehci_batch->tds[td_current], 294 dma_buffer_phys(&ehci_batch->dma_buffer, &ehci_batch->tds[td_current + 1]), 295 buffer, data_dir, transfer_size, toggle, false); 320 296 usb_log_debug2("Batch %p: Created CONTROL DATA TD(%"PRIxn"): " 321 297 "%08x:%08x:%08x", ehci_batch, 322 addr_to_phys(ehci_batch->tds[td_current]),323 ehci_batch->tds[td_current] ->status,324 ehci_batch->tds[td_current] ->next,325 ehci_batch->tds[td_current] ->alternate);298 dma_buffer_phys(&ehci_batch->dma_buffer, &ehci_batch->tds[td_current]), 299 ehci_batch->tds[td_current].status, 300 ehci_batch->tds[td_current].next, 301 ehci_batch->tds[td_current].alternate); 326 302 327 303 buffer += transfer_size; … … 333 309 /* Status stage */ 334 310 assert(td_current == ehci_batch->td_count - 1); 335 td_init( ehci_batch->tds[td_current], NULL, status_dir, NULL, 0, 1, true);336 usb_log_debug2("Batch %p: Created CONTROL STATUS TD (%"PRIxn"): "337 "%08x:%08x:%08x", ehci_batch, 338 addr_to_phys(ehci_batch->tds[td_current]),339 ehci_batch->tds[td_current] ->status,340 ehci_batch->tds[td_current] ->next,341 ehci_batch->tds[td_current] ->alternate);311 td_init(&ehci_batch->tds[td_current], 0, 0, status_dir, 0, 1, true); 312 usb_log_debug2("Batch %p: Created CONTROL STATUS TD %d(%"PRIxn"): " 313 "%08x:%08x:%08x", ehci_batch, td_current, 314 dma_buffer_phys(&ehci_batch->dma_buffer, &ehci_batch->tds[td_current]), 315 ehci_batch->tds[td_current].status, 316 ehci_batch->tds[td_current].next, 317 ehci_batch->tds[td_current].alternate); 342 318 } 343 319 … … 354 330 assert(ehci_batch); 355 331 356 usb_log_debug2("Batch %p: Data QH(% "PRIxn"): "332 usb_log_debug2("Batch %p: Data QH(%p): " 357 333 "%08x:%08x:%08x:%08x:%08x:%08x", ehci_batch, 358 addr_to_phys(ehci_batch->qh),334 ehci_batch->qh, 359 335 ehci_batch->qh->ep_char, ehci_batch->qh->ep_cap, 360 336 ehci_batch->qh->status, ehci_batch->qh->current, … … 363 339 size_t td_current = 0; 364 340 size_t remain_size = ehci_batch->base.buffer_size; 365 char *buffer = ehci_batch->device_buffer;341 uintptr_t buffer = dma_buffer_phys(&ehci_batch->dma_buffer, ehci_batch->data_buffer); 366 342 while (remain_size > 0) { 367 343 const size_t transfer_size = remain_size > EHCI_TD_MAX_TRANSFER … … 369 345 370 346 const bool last = (remain_size == transfer_size); 371 td_init( 372 ehci_batch->tds[td_current], 373 last ? NULL : ehci_batch->tds[td_current + 1], 374 ehci_batch->base.dir, buffer, transfer_size, -1, last); 347 td_init(&ehci_batch->tds[td_current], 348 last ? 0 : dma_buffer_phys(&ehci_batch->dma_buffer, &ehci_batch->tds[td_current + 1]), 349 buffer, ehci_batch->base.dir, transfer_size, -1, last); 375 350 376 351 usb_log_debug2("Batch %p: DATA TD(%"PRIxn": %08x:%08x:%08x", 377 352 ehci_batch, 378 addr_to_phys(ehci_batch->tds[td_current]),379 ehci_batch->tds[td_current] ->status,380 ehci_batch->tds[td_current] ->next,381 ehci_batch->tds[td_current] ->alternate);353 dma_buffer_phys(&ehci_batch->dma_buffer, &ehci_batch->tds[td_current]), 354 ehci_batch->tds[td_current].status, 355 ehci_batch->tds[td_current].next, 356 ehci_batch->tds[td_current].alternate); 382 357 383 358 buffer += transfer_size; -
uspace/drv/bus/usb/ehci/ehci_batch.h
rb60944b r35c37fc 39 39 #include <stdbool.h> 40 40 #include <usb/host/usb_transfer_batch.h> 41 #include <usb/host/dma_buffer.h> 41 42 42 43 #include "hw_struct/queue_head.h" … … 46 47 typedef struct ehci_transfer_batch { 47 48 usb_transfer_batch_t base; 49 /** Number of TDs used by the transfer */ 50 size_t td_count; 48 51 /** Link */ 49 52 link_t link; 50 53 /** Endpoint descriptor of the target endpoint. */ 51 54 qh_t *qh; 52 /** List of TDs needed for the transfer */53 td_t **tds;54 /** Number of TDs used by the transfer */55 size_t td_count;56 55 /** Data buffer, must be accessible by the EHCI hw. */ 57 char *device_buffer; 56 dma_buffer_t dma_buffer; 57 /** List of TDs needed for the transfer - backed by dma_buffer */ 58 td_t *tds; 59 /** Data buffers - backed by dma_buffer */ 60 void *setup_buffer; 61 void *data_buffer; 58 62 /** Generic USB transfer structure */ 59 63 usb_transfer_batch_t *usb_batch; -
uspace/drv/bus/usb/ehci/ehci_bus.c
rb60944b r35c37fc 36 36 #include <assert.h> 37 37 #include <stdlib.h> 38 #include <usb/host/utils/malloc32.h>39 38 #include <usb/host/bandwidth.h> 40 39 #include <usb/debug.h> … … 90 89 91 90 // TODO: extract USB2 information from desc 91 92 if (dma_buffer_alloc(&ehci_ep->dma_buffer, sizeof(qh_t))) 93 return NULL; 92 94 93 ehci_ep->qh = malloc32(sizeof(qh_t)); 94 if (ehci_ep->qh == NULL) { 95 free(ehci_ep); 96 return NULL; 97 } 95 ehci_ep->qh = ehci_ep->dma_buffer.virt; 98 96 99 97 link_initialize(&ehci_ep->link); … … 111 109 ehci_endpoint_t *instance = ehci_endpoint_get(ep); 112 110 113 free32(instance->qh);111 dma_buffer_free(&instance->dma_buffer); 114 112 free(instance); 115 113 } -
uspace/drv/bus/usb/ehci/ehci_bus.h
rb60944b r35c37fc 40 40 #include <usb/host/usb2_bus.h> 41 41 #include <usb/host/endpoint.h> 42 #include <usb/host/dma_buffer.h> 42 43 43 44 #include "hw_struct/queue_head.h" … … 48 49 endpoint_t base; 49 50 50 /** EHCI endpoint descriptor */51 /** EHCI endpoint descriptor, backed by dma_buffer */ 51 52 qh_t *qh; 53 54 dma_buffer_t dma_buffer; 52 55 /** Linked list used by driver software */ 53 56 link_t link; -
uspace/drv/bus/usb/ehci/endpoint_list.c
rb60944b r35c37fc 54 54 assert(instance); 55 55 instance->name = name; 56 instance->list_head = malloc32(sizeof(qh_t)); 57 if (!instance->list_head) { 56 if (dma_buffer_alloc(&instance->dma_buffer, sizeof(qh_t))) { 58 57 usb_log_error("EPL(%p-%s): Failed to allocate list head.", 59 58 instance, name); 60 59 return ENOMEM; 61 60 } 61 instance->list_head = instance->dma_buffer.virt; 62 62 qh_init(instance->list_head, NULL); 63 63 -
uspace/drv/bus/usb/ehci/endpoint_list.h
rb60944b r35c37fc 38 38 #include <assert.h> 39 39 #include <fibril_synch.h> 40 #include <usb/host/utils/malloc32.h>41 40 42 41 #include "ehci_bus.h" … … 49 48 /** EHCI hw structure at the beginning of the queue */ 50 49 qh_t *list_head; 50 dma_buffer_t dma_buffer; 51 51 /** Assigned name, provides nicer debug output */ 52 52 const char *name; … … 64 64 { 65 65 assert(instance); 66 free32(instance->list_head);66 dma_buffer_free(&instance->dma_buffer); 67 67 instance->list_head = NULL; 68 68 } -
uspace/drv/bus/usb/ehci/hc.c
rb60944b r35c37fc 45 45 #include <usb/debug.h> 46 46 #include <usb/usb.h> 47 #include <usb/host/utils/malloc32.h>48 47 49 48 #include "ehci_batch.h" … … 198 197 * @param[in] instance Host controller structure to use. 199 198 */ 200 int hc_gone(hc_device_t *instance) 201 { 202 assert(instance); 203 return EOK; 204 //TODO: stop the hw 205 #if 0 206 endpoint_list_fini(&instance->async_list); 207 endpoint_list_fini(&instance->int_list); 208 return_page(instance->periodic_list_base); 209 #endif 199 int hc_gone(hc_device_t *hcd) 200 { 201 hc_t *hc = hcd_to_hc(hcd); 202 endpoint_list_fini(&hc->async_list); 203 endpoint_list_fini(&hc->int_list); 204 dma_buffer_free(&hc->dma_buffer); 205 return EOK; 210 206 }; 211 207 … … 406 402 407 403 /* Enable periodic list */ 408 assert(instance->periodic_list _base);404 assert(instance->periodic_list); 409 405 uintptr_t phys_base = 410 addr_to_phys((void*)instance->periodic_list _base);406 addr_to_phys((void*)instance->periodic_list); 411 407 assert((phys_base & USB_PERIODIC_LIST_BASE_MASK) == phys_base); 412 408 EHCI_WR(instance->registers->periodiclistbase, phys_base); … … 477 473 478 474 /* Take 1024 periodic list heads, we ignore low mem options */ 479 instance->periodic_list_base = get_page(); 480 if (!instance->periodic_list_base) { 475 if (dma_buffer_alloc(&instance->dma_buffer, PAGE_SIZE)) { 481 476 usb_log_error("HC(%p): Failed to get ISO schedule page.", 482 477 instance); … … 485 480 return ENOMEM; 486 481 } 482 instance->periodic_list = instance->dma_buffer.virt; 487 483 488 484 usb_log_debug2("HC(%p): Initializing Periodic list.", instance); 489 for (unsigned i = 0; 490 i < PAGE_SIZE/sizeof(instance->periodic_list_base[0]); ++i) 485 for (unsigned i = 0; i < PAGE_SIZE/sizeof(link_pointer_t); ++i) 491 486 { 492 487 /* Disable everything for now */ 493 instance->periodic_list _base[i] =488 instance->periodic_list[i] = 494 489 LINK_POINTER_QH(addr_to_phys(instance->int_list.list_head)); 495 490 } -
uspace/drv/bus/usb/ehci/hc.h
rb60944b r35c37fc 63 63 ehci_regs_t *registers; 64 64 65 /** Iso transfer list */ 66 link_pointer_t *periodic_list_base; 65 /** Iso transfer list, backed by dma_buffer */ 66 link_pointer_t *periodic_list; 67 68 dma_buffer_t dma_buffer; 67 69 68 70 /** CONTROL and BULK schedules */ -
uspace/drv/bus/usb/ehci/hw_struct/queue_head.h
rb60944b r35c37fc 193 193 } 194 194 195 static inline void qh_set_next_td(qh_t *qh, td_t *td)195 static inline void qh_set_next_td(qh_t *qh, uintptr_t td) 196 196 { 197 197 assert(qh); 198 198 assert(td); 199 EHCI_MEM32_WR(qh->next, LINK_POINTER_TD( addr_to_phys(td)));199 EHCI_MEM32_WR(qh->next, LINK_POINTER_TD(td)); 200 200 } 201 201 -
uspace/drv/bus/usb/ehci/hw_struct/transfer_descriptor.c
rb60944b r35c37fc 39 39 40 40 #include <usb/usb.h> 41 #include <usb/host/utils/malloc32.h>42 41 43 42 #include "mem_access.h" … … 70 69 }; 71 70 71 #include <usb/debug.h> 72 72 73 /** 73 74 * Initialize EHCI TD. 74 75 * @param instance TD structure to initialize. 75 * @param next Next TD in ED list.76 * @param next_phys Next TD in ED list. 76 77 * @param direction Used to determine PID, BOTH means setup PID. 77 78 * @param buffer Pointer to the first byte of transferred data. … … 80 81 * any other value means that ED toggle will be used. 81 82 */ 82 void td_init(td_t *instance, const td_t *next, 83 usb_direction_t direction, const void *buffer, size_t size, int toggle, 84 bool ioc) 83 void td_init(td_t *instance, uintptr_t next_phys, uintptr_t buffer, 84 usb_direction_t direction, size_t size, int toggle, bool ioc) 85 85 { 86 86 assert(instance); … … 98 98 } 99 99 100 if (buffer != NULL) {100 if (buffer != 0) { 101 101 assert(size != 0); 102 102 for (unsigned i = 0; (i < ARRAY_SIZE(instance->buffer_pointer)) 103 103 && size; ++i) { 104 const uintptr_t page = 105 (addr_to_phys(buffer) & TD_BUFFER_POINTER_MASK); 106 const size_t offset = 107 ((uintptr_t)buffer & TD_BUFFER_POINTER_OFFSET_MASK); 104 const uintptr_t offset = buffer & TD_BUFFER_POINTER_OFFSET_MASK; 108 105 assert(offset == 0 || i == 0); 109 size -= min((4096 - offset), size);110 buffer += min((4096 - offset), size);111 EHCI_MEM32_WR(instance->buffer_pointer[i],112 page | offset);106 const size_t this_size = min(size, 4096 - offset); 107 EHCI_MEM32_WR(instance->buffer_pointer[i], buffer); 108 size -= this_size; 109 buffer += this_size; 113 110 } 114 111 } 115 112 116 EHCI_MEM32_WR(instance->next, next ?117 LINK_POINTER_TD( addr_to_phys(next)) : LINK_POINTER_TERM);113 EHCI_MEM32_WR(instance->next, next_phys ? 114 LINK_POINTER_TD(next_phys) : LINK_POINTER_TERM); 118 115 119 116 EHCI_MEM32_WR(instance->alternate, LINK_POINTER_TERM); -
uspace/drv/bus/usb/ehci/hw_struct/transfer_descriptor.h
rb60944b r35c37fc 37 37 #include <stddef.h> 38 38 #include <stdint.h> 39 #include <macros.h> 39 40 #include "link_pointer.h" 40 41 #include "mem_access.h" … … 75 76 /* 64 bit struct only */ 76 77 volatile uint32_t extended_bp[5]; 77 } td_t; 78 79 /* TDs must be 32-byte aligned */ 80 PADD32 [3]; 81 82 } __attribute__((packed)) td_t; 83 84 static_assert(sizeof(td_t) % 32 == 0); 78 85 79 86 static inline bool td_active(const td_t *td) … … 92 99 int td_error(const td_t *td); 93 100 94 void td_init(td_t *td, const td_t *next, usb_direction_t dir, const void * buf,101 void td_init(td_t *td, uintptr_t next_phys, uintptr_t buf, usb_direction_t dir, 95 102 size_t buf_size, int toggle, bool ioc); 96 103 -
uspace/lib/usbhost/include/usb/host/dma_buffer.h
rb60944b r35c37fc 60 60 extern int dma_buffer_alloc_policy(dma_buffer_t *, size_t, dma_policy_t); 61 61 extern void dma_buffer_free(dma_buffer_t *); 62 extern uintptr_t dma_buffer_phys(const dma_buffer_t *, void *); 62 63 63 64 static inline int dma_buffer_is_set(dma_buffer_t *db) -
uspace/lib/usbhost/src/dma_buffer.c
rb60944b r35c37fc 105 105 } 106 106 107 /** Convert a pointer inside a buffer to physical address. 108 * 109 * @param[in] db Buffer at which virt is pointing 110 * @param[in] virt Pointer somewhere inside db 111 */ 112 uintptr_t dma_buffer_phys(const dma_buffer_t *db, void *virt) 113 { 114 return db->phys + (virt - db->virt); 115 } 116 107 117 /** 108 118 * @}
Note:
See TracChangeset
for help on using the changeset viewer.