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 /* 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.
24 #ifndef _UAPI_LINUX_ION_H
25 #define _UAPI_LINUX_ION_H
27 #include <linux/ioctl.h>
28 #include <linux/types.h>
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
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
44 ION_HEAP_TYPE_SYSTEM_CONTIG
,
45 ION_HEAP_TYPE_CARVEOUT
,
48 ION_HEAP_TYPE_CUSTOM
, /*
49 * must be last so device specific heaps always
50 * are at the end of this enum
54 #define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8)
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.
62 * mappings of this buffer should be cached, ion will do cache maintenance
63 * when the buffer is mapped for dma
65 #define ION_FLAG_CACHED 1
68 * DOC: Ion Userspace API
70 * create a client by opening /dev/ion
71 * most operations handled via following ioctls
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
83 * Provided by userspace as an argument to the ioctl
85 struct ion_allocation_data
{
93 #define MAX_HEAP_NAME 32
96 * struct ion_heap_data - data about a heap
97 * @name - first 32 characters of the heap name
99 * @heap_id - heap id for the heap
101 struct ion_heap_data
{
102 char name
[MAX_HEAP_NAME
];
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
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 */
123 #define ION_IOC_MAGIC 'I'
126 * DOC: ION_IOC_ALLOC - allocate memory
128 * Takes an ion_allocation_data struct and returns it with the handle field
129 * populated with the opaque handle for the allocation.
131 #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
132 struct ion_allocation_data)
135 * DOC: ION_IOC_HEAP_QUERY - information about available heaps
137 * Takes an ion_heap_query structure and populates information about
138 * available Ion heaps.
140 #define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \
141 struct ion_heap_query)
143 #endif /* _UAPI_LINUX_ION_H */