|
| 1 | +/* |
| 2 | + * ion.h |
| 3 | + * |
| 4 | + * Copyright (C) 2011 Google, Inc. |
| 5 | + * |
| 6 | + * This software is licensed under the terms of the GNU General Public |
| 7 | + * License version 2, as published by the Free Software Foundation, and |
| 8 | + * may be copied, distributed, and modified under those terms. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + */ |
| 16 | + |
| 17 | +/* This file is copied from drivers/staging/android/uapi/ion.h |
| 18 | + * This local copy is required for the selftest to pass, when build |
| 19 | + * outside the kernel source tree. |
| 20 | + * Please keep this file in sync with its original file until the |
| 21 | + * ion driver is moved outside the staging tree. |
| 22 | + */ |
| 23 | + |
| 24 | +#ifndef _UAPI_LINUX_ION_H |
| 25 | +#define _UAPI_LINUX_ION_H |
| 26 | + |
| 27 | +#include <linux/ioctl.h> |
| 28 | +#include <linux/types.h> |
| 29 | + |
| 30 | +/** |
| 31 | + * enum ion_heap_types - list of all possible types of heaps |
| 32 | + * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc |
| 33 | + * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc |
| 34 | + * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved |
| 35 | + * carveout heap, allocations are physically |
| 36 | + * contiguous |
| 37 | + * @ION_HEAP_TYPE_DMA: memory allocated via DMA API |
| 38 | + * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask |
| 39 | + * is used to identify the heaps, so only 32 |
| 40 | + * total heap types are supported |
| 41 | + */ |
| 42 | +enum ion_heap_type { |
| 43 | + ION_HEAP_TYPE_SYSTEM, |
| 44 | + ION_HEAP_TYPE_SYSTEM_CONTIG, |
| 45 | + ION_HEAP_TYPE_CARVEOUT, |
| 46 | + ION_HEAP_TYPE_CHUNK, |
| 47 | + ION_HEAP_TYPE_DMA, |
| 48 | + ION_HEAP_TYPE_CUSTOM, /* |
| 49 | + * must be last so device specific heaps always |
| 50 | + * are at the end of this enum |
| 51 | + */ |
| 52 | +}; |
| 53 | + |
| 54 | +#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) |
| 55 | + |
| 56 | +/** |
| 57 | + * allocation flags - the lower 16 bits are used by core ion, the upper 16 |
| 58 | + * bits are reserved for use by the heaps themselves. |
| 59 | + */ |
| 60 | + |
| 61 | +/* |
| 62 | + * mappings of this buffer should be cached, ion will do cache maintenance |
| 63 | + * when the buffer is mapped for dma |
| 64 | + */ |
| 65 | +#define ION_FLAG_CACHED 1 |
| 66 | + |
| 67 | +/** |
| 68 | + * DOC: Ion Userspace API |
| 69 | + * |
| 70 | + * create a client by opening /dev/ion |
| 71 | + * most operations handled via following ioctls |
| 72 | + * |
| 73 | + */ |
| 74 | + |
| 75 | +/** |
| 76 | + * struct ion_allocation_data - metadata passed from userspace for allocations |
| 77 | + * @len: size of the allocation |
| 78 | + * @heap_id_mask: mask of heap ids to allocate from |
| 79 | + * @flags: flags passed to heap |
| 80 | + * @handle: pointer that will be populated with a cookie to use to |
| 81 | + * refer to this allocation |
| 82 | + * |
| 83 | + * Provided by userspace as an argument to the ioctl |
| 84 | + */ |
| 85 | +struct ion_allocation_data { |
| 86 | + __u64 len; |
| 87 | + __u32 heap_id_mask; |
| 88 | + __u32 flags; |
| 89 | + __u32 fd; |
| 90 | + __u32 unused; |
| 91 | +}; |
| 92 | + |
| 93 | +#define MAX_HEAP_NAME 32 |
| 94 | + |
| 95 | +/** |
| 96 | + * struct ion_heap_data - data about a heap |
| 97 | + * @name - first 32 characters of the heap name |
| 98 | + * @type - heap type |
| 99 | + * @heap_id - heap id for the heap |
| 100 | + */ |
| 101 | +struct ion_heap_data { |
| 102 | + char name[MAX_HEAP_NAME]; |
| 103 | + __u32 type; |
| 104 | + __u32 heap_id; |
| 105 | + __u32 reserved0; |
| 106 | + __u32 reserved1; |
| 107 | + __u32 reserved2; |
| 108 | +}; |
| 109 | + |
| 110 | +/** |
| 111 | + * struct ion_heap_query - collection of data about all heaps |
| 112 | + * @cnt - total number of heaps to be copied |
| 113 | + * @heaps - buffer to copy heap data |
| 114 | + */ |
| 115 | +struct ion_heap_query { |
| 116 | + __u32 cnt; /* Total number of heaps to be copied */ |
| 117 | + __u32 reserved0; /* align to 64bits */ |
| 118 | + __u64 heaps; /* buffer to be populated */ |
| 119 | + __u32 reserved1; |
| 120 | + __u32 reserved2; |
| 121 | +}; |
| 122 | + |
| 123 | +#define ION_IOC_MAGIC 'I' |
| 124 | + |
| 125 | +/** |
| 126 | + * DOC: ION_IOC_ALLOC - allocate memory |
| 127 | + * |
| 128 | + * Takes an ion_allocation_data struct and returns it with the handle field |
| 129 | + * populated with the opaque handle for the allocation. |
| 130 | + */ |
| 131 | +#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ |
| 132 | + struct ion_allocation_data) |
| 133 | + |
| 134 | +/** |
| 135 | + * DOC: ION_IOC_HEAP_QUERY - information about available heaps |
| 136 | + * |
| 137 | + * Takes an ion_heap_query structure and populates information about |
| 138 | + * available Ion heaps. |
| 139 | + */ |
| 140 | +#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \ |
| 141 | + struct ion_heap_query) |
| 142 | + |
| 143 | +#endif /* _UAPI_LINUX_ION_H */ |
0 commit comments