2 * Copyright (C) 2010, 2012-2014, 2016 ARM Limited. All rights reserved.
4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
7 * A copy of the licence is included with the program, and can also be obtained from Free Software
8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 * @file ump_uk_types.h
13 * Defines the types and constants used in the user-kernel interface
16 #ifndef __UMP_UK_TYPES_H__
17 #define __UMP_UK_TYPES_H__
23 /* Helpers for API version handling */
24 #define MAKE_VERSION_ID(x) (((x) << 16UL) | (x))
25 #define IS_VERSION_ID(x) (((x) & 0xFFFF) == (((x) >> 16UL) & 0xFFFF))
26 #define GET_VERSION(x) (((x) >> 16UL) & 0xFFFF)
27 #define IS_API_MATCH(x, y) (IS_VERSION_ID((x)) && IS_VERSION_ID((y)) && (GET_VERSION((x)) == GET_VERSION((y))))
31 * Indicates the version of the kernel API
32 * The version is a 16bit integer incremented on each API change.
33 * The 16bit integer is stored twice in a 32bit integer
34 * So for version 1 the value would be 0x00010001
36 #define UMP_IOCTL_API_VERSION MAKE_VERSION_ID(3)
40 _UMP_IOC_QUERY_API_VERSION = 1,
44 _UMP_IOC_MAP_MEM, /* not used in Linux */
45 _UMP_IOC_UNMAP_MEM, /* not used in Linux */
47 _UMP_IOC_CACHE_OPERATIONS_CONTROL,
48 _UMP_IOC_SWITCH_HW_USAGE,
51 _UMP_IOC_DMABUF_IMPORT,
56 UMP_REF_DRV_UK_CONSTRAINT_NONE = 0,
57 UMP_REF_DRV_UK_CONSTRAINT_PHYSICALLY_LINEAR = 1,
58 UMP_REF_DRV_UK_CONSTRAINT_USE_CACHE = 4,
59 } ump_uk_alloc_constraints;
63 _UMP_UK_MSYNC_CLEAN = 0,
64 _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE = 1,
65 _UMP_UK_MSYNC_INVALIDATE = 2,
66 _UMP_UK_MSYNC_FLUSH_L1 = 3,
67 _UMP_UK_MSYNC_READOUT_CACHE_ENABLED = 128,
72 _UMP_UK_CACHE_OP_START = 0,
73 _UMP_UK_CACHE_OP_FINISH = 1,
74 } ump_uk_cache_op_control;
79 _UMP_UK_READ_WRITE = 3,
84 _UMP_UK_USED_BY_CPU = 0,
85 _UMP_UK_USED_BY_MALI = 1,
86 _UMP_UK_USED_BY_UNKNOWN_DEVICE = 100,
90 * Get API version ([in,out] u32 api_version, [out] u32 compatible)
92 typedef struct _ump_uk_api_version_s
94 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
95 u32 version; /**< Set to the user space version on entry, stores the device driver version on exit */
96 u32 compatible; /**< Non-null if the device is compatible with the client */
97 } _ump_uk_api_version_s;
100 * ALLOCATE ([out] u32 secure_id, [in,out] u32 size, [in] contraints)
102 typedef struct _ump_uk_allocate_s
104 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
105 u32 secure_id; /**< Return value from DD to Userdriver */
106 u32 size; /**< Input and output. Requested size; input. Returned size; output */
107 ump_uk_alloc_constraints constraints; /**< Only input to Devicedriver */
108 } _ump_uk_allocate_s;
111 * SIZE_GET ([in] u32 secure_id, [out]size )
113 typedef struct _ump_uk_size_get_s
115 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
116 u32 secure_id; /**< Input to DD */
117 u32 size; /**< Returned size; output */
118 } _ump_uk_size_get_s;
121 * Release ([in] u32 secure_id)
123 typedef struct _ump_uk_release_s
125 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
126 u32 secure_id; /**< Input to DD */
129 typedef struct _ump_uk_map_mem_s
131 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
132 void *mapping; /**< [out] Returns user-space virtual address for the mapping */
133 void *phys_addr; /**< [in] physical address */
134 unsigned long size; /**< [in] size */
135 u32 secure_id; /**< [in] secure_id to assign to mapping */
136 void *_ukk_private; /**< Only used inside linux port between kernel frontend and common part to store vma */
138 u32 is_cached; /**< [in,out] caching of CPU mappings */
141 typedef struct _ump_uk_unmap_mem_s
143 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
148 } _ump_uk_unmap_mem_s;
150 typedef struct _ump_uk_msync_s
152 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
153 void *mapping; /**< [in] mapping addr */
154 void *address; /**< [in] flush start addr */
155 u32 size; /**< [in] size to flush */
156 ump_uk_msync_op op; /**< [in] flush operation */
157 u32 cookie; /**< [in] cookie stored with reference to the kernel mapping internals */
158 u32 secure_id; /**< [in] secure_id that identifies the ump buffer */
159 u32 is_cached; /**< [out] caching of CPU mappings */
162 typedef struct _ump_uk_cache_operations_control_s
164 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
165 ump_uk_cache_op_control op; /**< [in] cache operations start/stop */
166 } _ump_uk_cache_operations_control_s;
169 typedef struct _ump_uk_switch_hw_usage_s
171 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
172 u32 secure_id; /**< [in] secure_id that identifies the ump buffer */
173 ump_uk_user new_user; /**< [in] cookie stored with reference to the kernel mapping internals */
175 } _ump_uk_switch_hw_usage_s;
177 typedef struct _ump_uk_lock_s
179 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
180 u32 secure_id; /**< [in] secure_id that identifies the ump buffer */
181 ump_uk_lock_usage lock_usage;
184 typedef struct _ump_uk_unlock_s
186 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
187 u32 secure_id; /**< [in] secure_id that identifies the ump buffer */
190 typedef struct _ump_uk_dmabuf_s
192 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
193 int fd; /**< [in] dmabuf_fd that identifies the dmabuf buffer */
194 size_t size; /**< [in] size of the buffer */
195 u32 secure_id; /**< [out] secure_id that identifies the ump buffer */
202 #endif /* __UMP_UK_TYPES_H__ */