Changeset 83fb72e in mainline
- Timestamp:
- 2017-12-20T11:36:13Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9fd8f14
- Parents:
- ba2fc2c
- git-author:
- Ondřej Hlavatý <aearsis@…> (2017-12-20 11:35:57)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2017-12-20 11:36:13)
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hc.h
rba2fc2c r83fb72e 71 71 dma_buffer_t dcbaa_dma; 72 72 dma_buffer_t scratchpad_array; 73 dma_buffer_t *scratchpad_buffers;74 73 75 74 /* Command ring management */ -
uspace/drv/bus/usb/xhci/scratchpad.c
rba2fc2c r83fb72e 37 37 #include <usb/debug.h> 38 38 #include "hc.h" 39 #include <align.h> 39 40 #include "hw_struct/regs.h" 40 41 #include "scratchpad.h" … … 57 58 return EOK; 58 59 59 if (dma_buffer_alloc(&hc->scratchpad_array, num_bufs * sizeof(uint64_t))) 60 const unsigned array_size = ALIGN_UP(num_bufs * sizeof(uint64_t), PAGE_SIZE); 61 const size_t size = array_size + num_bufs * PAGE_SIZE; 62 63 if (dma_buffer_alloc(&hc->scratchpad_array, size)) 60 64 return ENOMEM; 61 uint64_t *phys_array = hc->scratchpad_array.virt; 65 66 memset(hc->scratchpad_array.virt, 0, size); 67 68 uint64_t phys_begin = hc->scratchpad_array.phys + array_size; 69 uint64_t *array = hc->scratchpad_array.virt; 70 71 for (unsigned i = 0; i < num_bufs; ++i) 72 array[i] = host2xhci(64, phys_begin + i * PAGE_SIZE); 62 73 63 74 hc->dcbaa[0] = host2xhci(64, hc->scratchpad_array.phys); 64 65 hc->scratchpad_buffers = calloc(num_bufs, sizeof(dma_buffer_t));66 if (!hc->scratchpad_buffers)67 goto err_dma;68 69 for (unsigned i = 0; i < num_bufs; ++i) {70 dma_buffer_t *cur = &hc->scratchpad_buffers[i];71 if (dma_buffer_alloc(cur, PAGE_SIZE))72 goto err_buffers;73 74 memset(cur->virt, 0, PAGE_SIZE);75 phys_array[i] = host2xhci(64, cur->phys);76 }77 78 75 79 76 usb_log_debug2("Allocated %d scratchpad buffers.", num_bufs); 80 77 81 78 return EOK; 82 83 err_buffers:84 for (unsigned i = 0; i < num_bufs; ++i)85 dma_buffer_free(&hc->scratchpad_buffers[i]);86 free(hc->scratchpad_buffers);87 err_dma:88 hc->dcbaa[0] = 0;89 dma_buffer_free(&hc->scratchpad_array);90 return ENOMEM;91 79 } 92 80 … … 100 88 hc->dcbaa[0] = 0; 101 89 dma_buffer_free(&hc->scratchpad_array); 102 for (unsigned i = 0; i < num_bufs; ++i)103 dma_buffer_free(&hc->scratchpad_buffers[i]);104 free(hc->scratchpad_buffers);105 90 return; 106 91 }
Note:
See TracChangeset
for help on using the changeset viewer.