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