root/tools/testing/selftests/android/ion/ion.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


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

/* [<][>][^][v][top][bottom][index][help] */