2 * drivers/staging/android/uapi/ion.h
4 * Copyright (C) 2011 Google, Inc.
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.
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.
17 #ifndef _UAPI_LINUX_ION_H
18 #define _UAPI_LINUX_ION_H
20 #include <linux/ioctl.h>
21 #include <linux/types.h>
24 * enum ion_heap_types - list of all possible types of heaps
25 * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc
26 * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc
27 * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved
28 * carveout heap, allocations are physically
30 * @ION_HEAP_TYPE_DMA: memory allocated via DMA API
31 * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask
32 * is used to identify the heaps, so only 32
33 * total heap types are supported
37 ION_HEAP_TYPE_SYSTEM_CONTIG,
38 ION_HEAP_TYPE_CARVEOUT,
41 ION_HEAP_TYPE_CUSTOM, /*
42 * must be last so device specific heaps always
43 * are at the end of this enum
47 #define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8)
50 * allocation flags - the lower 16 bits are used by core ion, the upper 16
51 * bits are reserved for use by the heaps themselves.
55 * mappings of this buffer should be cached, ion will do cache maintenance
56 * when the buffer is mapped for dma
58 #define ION_FLAG_CACHED 1
61 * DOC: Ion Userspace API
63 * create a client by opening /dev/ion
64 * most operations handled via following ioctls
69 * struct ion_allocation_data - metadata passed from userspace for allocations
70 * @len: size of the allocation
71 * @heap_id_mask: mask of heap ids to allocate from
72 * @flags: flags passed to heap
73 * @handle: pointer that will be populated with a cookie to use to
74 * refer to this allocation
76 * Provided by userspace as an argument to the ioctl
78 struct ion_allocation_data {
86 #define MAX_HEAP_NAME 32
89 * struct ion_heap_data - data about a heap
90 * @name - first 32 characters of the heap name
92 * @heap_id - heap id for the heap
94 struct ion_heap_data {
95 char name[MAX_HEAP_NAME];
104 * struct ion_heap_query - collection of data about all heaps
105 * @cnt - total number of heaps to be copied
106 * @heaps - buffer to copy heap data
108 struct ion_heap_query {
109 __u32 cnt; /* Total number of heaps to be copied */
110 __u32 reserved0; /* align to 64bits */
111 __u64 heaps; /* buffer to be populated */
116 #define ION_IOC_MAGIC 'I'
119 * DOC: ION_IOC_ALLOC - allocate memory
121 * Takes an ion_allocation_data struct and returns it with the handle field
122 * populated with the opaque handle for the allocation.
124 #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
125 struct ion_allocation_data)
128 * DOC: ION_IOC_HEAP_QUERY - information about available heaps
130 * Takes an ion_heap_query structure and populates information about
131 * available Ion heaps.
133 #define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \
134 struct ion_heap_query)
136 #endif /* _UAPI_LINUX_ION_H */