Changeset cc63815 in mainline for uspace/lib/usb/include
- Timestamp:
- 2018-02-05T00:54:08Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fdc2253b
- Parents:
- 5c69377
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-02-02 14:35:14)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-02-05 00:54:08)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/dma_buffer.h
r5c69377 rcc63815 32 32 * @brief USB host controller library: DMA buffer helpers 33 33 * 34 * Simplifies usage of bounce buffers 34 * Simplifies handling of buffers accessible to hardware. Defines properties of 35 * such buffer, which can be communicated through IPC to allow higher layers to 36 * allocate a buffer that is ready to be passed to HW right away (after being 37 * shared through IPC). 35 38 * 36 * Currently the minimum size allocated is a page, which is wasteful. Could be 37 * extended to support memory pools, which will enable smaller units of 38 * allocation. 39 * Note that although allocated memory is always page-aligned, the buffer itself 40 * may be only a part of it, justifying the existence of page-alignment and 41 * page-crossing flags. 42 * 43 * Also, currently the buffers that are allocated are always contiguous and 44 * page-aligned, regardless of whether the policy requires it. We blindly 45 * believe this fact in dma_buffer_phys, which will yield wrong results if the 46 * buffer is not contiguous. 39 47 */ 40 48 #ifndef LIB_USB_DMA_BUFFER … … 43 51 #include <stdint.h> 44 52 #include <stdlib.h> 53 #include <usbhc_iface.h> 45 54 #include <errno.h> 46 55 47 typedef const struct dma_policy { 48 unsigned flags; 56 #define DMA_POLICY_4GiB (1<<0) /**< Must use only 32-bit addresses */ 57 #define DMA_POLICY_PAGE_ALIGNED (1<<1) /**< The first pointer must be page-aligned */ 58 #define DMA_POLICY_CONTIGUOUS (1<<2) /**< Pages must follow each other physically */ 59 #define DMA_POLICY_NOT_CROSSING (1<<3) /**< Buffer must not cross page boundary. (Implies buffer is no larger than page). */ 49 60 50 #define DMA_POLICY_F_4GiB (1<<0) /**< Must use only 32-bit addresses */ 51 #define DMA_POLICY_F_CONTIGUOUS (1<<1) /**< Pages must follow each other physically */ 52 } dma_policy_t; 61 #define DMA_POLICY_STRICT (-1U) 62 #define DMA_POLICY_DEFAULT DMA_POLICY_STRICT 53 63 54 64 typedef struct dma_buffer { … … 57 67 } dma_buffer_t; 58 68 59 extern int dma_buffer_alloc(dma_buffer_t *db, size_t size);60 extern int dma_buffer_alloc_policy(dma_buffer_t *, size_t, dma_policy_t *);69 extern errno_t dma_buffer_alloc(dma_buffer_t *db, size_t size); 70 extern errno_t dma_buffer_alloc_policy(dma_buffer_t *, size_t, dma_policy_t); 61 71 extern void dma_buffer_free(dma_buffer_t *); 62 72 extern uintptr_t dma_buffer_phys(const dma_buffer_t *, void *); 63 73 64 extern bool dma_buffer_check_policy(const void *, size_t, dma_policy_t *); 74 extern bool dma_buffer_check_policy(const void *, size_t, const dma_policy_t); 75 76 extern errno_t dma_buffer_lock(dma_buffer_t *, void *, size_t); 77 extern void dma_buffer_unlock(dma_buffer_t *, size_t); 65 78 66 79 static inline int dma_buffer_is_set(dma_buffer_t *db)
Note:
See TracChangeset
for help on using the changeset viewer.