MLIR-AIE
ion.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * drivers/staging/android/uapi/ion.h
4 *
5 * Copyright (C) 2011 Google, Inc.
6 */
7
8#ifndef _UAPI_LINUX_ION_H
9#define _UAPI_LINUX_ION_H
10
11#include <linux/ioctl.h>
12#include <linux/types.h>
13
14/// enum ion_heap_types - list of all possible types of heaps
16 ION_HEAP_TYPE_SYSTEM, ///< memory allocated via vmalloc
17 ION_HEAP_TYPE_SYSTEM_CONTIG, ///< memory allocated via kmalloc
18 ION_HEAP_TYPE_CARVEOUT, ///< memory allocated from a prereserved carveout
19 ///< heap, allocations are physically contiguous
21 ION_HEAP_TYPE_DMA, ///< memory allocated via DMA API
22 ION_HEAP_TYPE_CUSTOM, ///< must be last so device specific heaps always are at
23 ///< the end of this enum
24};
25
26#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8)
27
28/**
29 * allocation flags - the lower 16 bits are used by core ion, the upper 16
30 * bits are reserved for use by the heaps themselves.
31 */
32
33/*
34 * mappings of this buffer should be cached, ion will do cache maintenance
35 * when the buffer is mapped for dma
36 */
37#define ION_FLAG_CACHED 1
38
39/**
40 * DOC: Ion Userspace API
41 *
42 * create a client by opening /dev/ion
43 * most operations handled via following ioctls
44 *
45 */
46
47/**
48 * struct ion_allocation_data - metadata passed from userspace for allocations
49 *
50 * Provided by userspace as an argument to the ioctl
51 */
53 __u64 len; ///< size of the allocation
54 __u32 heap_id_mask; ///< mask of heap ids to allocate from
55 __u32 flags; ///< flags passed to heap
56 __u32 fd; ///< file descriptor for this allocation
57 __u32 unused; ///< unused field
58};
59
60#define MAX_HEAP_NAME 32
61
62/**
63 * struct ion_heap_data - data about a heap
64 */
66 char name[MAX_HEAP_NAME]; ///< first 32 characters of the heap name
67 __u32 type; ///< heap type
68 __u32 heap_id; ///< heap id for the heap
69 __u32 reserved0; ///< reserved field
70 __u32 reserved1; ///< reserved field
71 __u32 reserved2; ///< reserved field
72};
73
74/**
75 * struct ion_heap_query - collection of data about all heaps
76 */
78 __u32 cnt; ///< Total number of heaps to be copied
79 __u32 reserved0; ///< align to 64bits
80 __u64 heaps; ///< buffer to be populated
81 __u32 reserved1; ///< reserved field
82 __u32 reserved2; ///< reserved field
83};
84
85#define ION_IOC_MAGIC 'I'
86
87/**
88 * DOC: ION_IOC_ALLOC - allocate memory
89 *
90 * Takes an ion_allocation_data struct and returns it with the handle field
91 * populated with the opaque handle for the allocation.
92 */
93#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, struct ion_allocation_data)
94
95/**
96 * DOC: ION_IOC_HEAP_QUERY - information about available heaps
97 *
98 * Takes an ion_heap_query structure and populates information about
99 * available Ion heaps.
100 */
101#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, struct ion_heap_query)
102
103#endif /* _UAPI_LINUX_ION_H */
#define MAX_HEAP_NAME
Definition ion.h:60
ion_heap_type
enum ion_heap_types - list of all possible types of heaps
Definition ion.h:15
@ ION_HEAP_TYPE_SYSTEM_CONTIG
memory allocated via kmalloc
Definition ion.h:17
@ ION_HEAP_TYPE_CARVEOUT
memory allocated from a prereserved carveout heap, allocations are physically contiguous
Definition ion.h:18
@ ION_HEAP_TYPE_CHUNK
Definition ion.h:20
@ ION_HEAP_TYPE_DMA
memory allocated via DMA API
Definition ion.h:21
@ ION_HEAP_TYPE_CUSTOM
must be last so device specific heaps always are at the end of this enum
Definition ion.h:22
@ ION_HEAP_TYPE_SYSTEM
memory allocated via vmalloc
Definition ion.h:16
DOC: Ion Userspace API.
Definition ion.h:52
__u32 heap_id_mask
mask of heap ids to allocate from
Definition ion.h:54
__u32 fd
file descriptor for this allocation
Definition ion.h:56
__u32 flags
flags passed to heap
Definition ion.h:55
__u32 unused
unused field
Definition ion.h:57
__u64 len
size of the allocation
Definition ion.h:53
struct ion_heap_data - data about a heap
Definition ion.h:65
__u32 type
heap type
Definition ion.h:67
__u32 reserved2
reserved field
Definition ion.h:71
__u32 reserved1
reserved field
Definition ion.h:70
__u32 reserved0
reserved field
Definition ion.h:69
char name[MAX_HEAP_NAME]
first 32 characters of the heap name
Definition ion.h:66
__u32 heap_id
heap id for the heap
Definition ion.h:68
struct ion_heap_query - collection of data about all heaps
Definition ion.h:77
__u64 heaps
buffer to be populated
Definition ion.h:80
__u32 reserved0
align to 64bits
Definition ion.h:79
__u32 reserved1
reserved field
Definition ion.h:81
__u32 cnt
Total number of heaps to be copied.
Definition ion.h:78
__u32 reserved2
reserved field
Definition ion.h:82