aura  0.1
All Data Structures Functions Variables Modules Pages
ion.h
1 /*
2  * ion.c
3  *
4  * Memory Allocator functions for ion
5  *
6  * Copyright 2011 Google, Inc
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef __SYS_CORE_ION_H
22 #define __SYS_CORE_ION_H
23 
24 #include <sys/types.h>
25 
26 
27 typedef int ion_user_handle_t;
28 
41 enum ion_heap_type {
42  ION_HEAP_TYPE_SYSTEM,
43  ION_HEAP_TYPE_SYSTEM_CONTIG,
44  ION_HEAP_TYPE_CARVEOUT,
45  ION_HEAP_TYPE_CHUNK,
46  ION_HEAP_TYPE_DMA,
47  ION_HEAP_TYPE_CUSTOM, /* must be last so device specific heaps always
48  are at the end of this enum */
49  ION_NUM_HEAPS = 16,
50 };
51 
52 #define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM)
53 #define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG)
54 #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT)
55 #define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA)
56 
57 #define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8)
58 
63 #define ION_FLAG_CACHED 1 /* mappings of this buffer should be
64  cached, ion will do cache
65  maintenance when the buffer is
66  mapped for dma */
67 #define ION_FLAG_CACHED_NEEDS_SYNC 2 /* mappings of this buffer will created
68  at mmap time, if this is set
69  caches must be managed manually */
70 
91  size_t len;
92  size_t align;
93  unsigned int heap_id_mask;
94  unsigned int flags;
95  ion_user_handle_t handle;
96 };
97 
108 struct ion_fd_data {
109  ion_user_handle_t handle;
110  int fd;
111 };
112 
118  ion_user_handle_t handle;
119 };
120 
130  unsigned int cmd;
131  unsigned long arg;
132 };
133 
134 #define ION_IOC_MAGIC 'I'
135 
142 #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
143  struct ion_allocation_data)
144 
150 #define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
151 
160 #define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data)
161 
171 #define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data)
172 
180 #define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
181 
190 #define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data)
191 
198 #define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
199 
200 
201 __BEGIN_DECLS
202 
203 struct ion_handle;
204 
205 int ion_open();
206 int ion_close(int fd);
207 int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask,
208  unsigned int flags, ion_user_handle_t *handle);
209 int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask,
210  unsigned int flags, int *handle_fd);
211 int ion_sync_fd(int fd, int handle_fd);
212 int ion_free(int fd, ion_user_handle_t handle);
213 int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot,
214  int flags, off_t offset, unsigned char **ptr, int *map_fd);
215 int ion_share(int fd, ion_user_handle_t handle, int *share_fd);
216 int ion_import(int fd, int share_fd, ion_user_handle_t *handle);
217 
218 __END_DECLS
219 
220 #endif /* __SYS_CORE_ION_H */