UPSTREAM: DT/arm,gic-v3: Documment PPI partition support
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / include / linux / mali / mali_utgard_uk_types.h
1 /*
2  * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
3  * 
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.
6  * 
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.
9  */
10
11 /**
12  * @file mali_uk_types.h
13  * Defines the types and constants used in the user-kernel interface
14  */
15
16 #ifndef __MALI_UTGARD_UK_TYPES_H__
17 #define __MALI_UTGARD_UK_TYPES_H__
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /* Iteration functions depend on these values being consecutive. */
24 #define MALI_UK_TIMELINE_GP   0
25 #define MALI_UK_TIMELINE_PP   1
26 #define MALI_UK_TIMELINE_SOFT 2
27 #define MALI_UK_TIMELINE_MAX  3
28
29 typedef struct {
30         u32 points[MALI_UK_TIMELINE_MAX];
31         s32 sync_fd;
32 } _mali_uk_fence_t;
33
34 /**
35  * @addtogroup uddapi Unified Device Driver (UDD) APIs
36  *
37  * @{
38  */
39
40 /**
41  * @addtogroup u_k_api UDD User/Kernel Interface (U/K) APIs
42  *
43  * @{
44  */
45
46 /** @defgroup _mali_uk_core U/K Core
47  * @{ */
48
49 /** Definition of subsystem numbers, to assist in creating a unique identifier
50  * for each U/K call.
51  *
52  * @see _mali_uk_functions */
53 typedef enum {
54         _MALI_UK_CORE_SUBSYSTEM,      /**< Core Group of U/K calls */
55         _MALI_UK_MEMORY_SUBSYSTEM,    /**< Memory Group of U/K calls */
56         _MALI_UK_PP_SUBSYSTEM,        /**< Fragment Processor Group of U/K calls */
57         _MALI_UK_GP_SUBSYSTEM,        /**< Vertex Processor Group of U/K calls */
58         _MALI_UK_PROFILING_SUBSYSTEM, /**< Profiling Group of U/K calls */
59         _MALI_UK_VSYNC_SUBSYSTEM,     /**< VSYNC Group of U/K calls */
60 } _mali_uk_subsystem_t;
61
62 /** Within a function group each function has its unique sequence number
63  * to assist in creating a unique identifier for each U/K call.
64  *
65  * An ordered pair of numbers selected from
66  * ( \ref _mali_uk_subsystem_t,\ref  _mali_uk_functions) will uniquely identify the
67  * U/K call across all groups of functions, and all functions. */
68 typedef enum {
69         /** Core functions */
70
71         _MALI_UK_OPEN                    = 0, /**< _mali_ukk_open() */
72         _MALI_UK_CLOSE,                       /**< _mali_ukk_close() */
73         _MALI_UK_WAIT_FOR_NOTIFICATION,       /**< _mali_ukk_wait_for_notification() */
74         _MALI_UK_GET_API_VERSION,             /**< _mali_ukk_get_api_version() */
75         _MALI_UK_POST_NOTIFICATION,           /**< _mali_ukk_post_notification() */
76         _MALI_UK_GET_USER_SETTING,            /**< _mali_ukk_get_user_setting() *//**< [out] */
77         _MALI_UK_GET_USER_SETTINGS,           /**< _mali_ukk_get_user_settings() *//**< [out] */
78         _MALI_UK_REQUEST_HIGH_PRIORITY,       /**< _mali_ukk_request_high_priority() */
79         _MALI_UK_TIMELINE_GET_LATEST_POINT,   /**< _mali_ukk_timeline_get_latest_point() */
80         _MALI_UK_TIMELINE_WAIT,               /**< _mali_ukk_timeline_wait() */
81         _MALI_UK_TIMELINE_CREATE_SYNC_FENCE,  /**< _mali_ukk_timeline_create_sync_fence() */
82         _MALI_UK_SOFT_JOB_START,              /**< _mali_ukk_soft_job_start() */
83         _MALI_UK_SOFT_JOB_SIGNAL,             /**< _mali_ukk_soft_job_signal() */
84     _MALI_GET_RK_KO_VERSION,                /* rk_ext */
85         _MALI_UK_GET_MALI_VERSION_IN_RK30,
86         /** Memory functions */
87
88         _MALI_UK_INIT_MEM                = 0,    /**< _mali_ukk_init_mem() */
89         _MALI_UK_TERM_MEM,                       /**< _mali_ukk_term_mem() */
90         _MALI_UK_MAP_MEM,                        /**< _mali_ukk_mem_mmap() */
91         _MALI_UK_UNMAP_MEM,                      /**< _mali_ukk_mem_munmap() */
92         _MALI_UK_QUERY_MMU_PAGE_TABLE_DUMP_SIZE, /**< _mali_ukk_mem_get_mmu_page_table_dump_size() */
93         _MALI_UK_DUMP_MMU_PAGE_TABLE,            /**< _mali_ukk_mem_dump_mmu_page_table() */
94         _MALI_UK_ATTACH_DMA_BUF,                 /**< _mali_ukk_attach_dma_buf() */
95         _MALI_UK_RELEASE_DMA_BUF,                /**< _mali_ukk_release_dma_buf() */
96         _MALI_UK_DMA_BUF_GET_SIZE,               /**< _mali_ukk_dma_buf_get_size() */
97         _MALI_UK_ATTACH_UMP_MEM,                 /**< _mali_ukk_attach_ump_mem() */
98         _MALI_UK_RELEASE_UMP_MEM,                /**< _mali_ukk_release_ump_mem() */
99         _MALI_UK_MAP_EXT_MEM,                    /**< _mali_uku_map_external_mem() */
100         _MALI_UK_UNMAP_EXT_MEM,                  /**< _mali_uku_unmap_external_mem() */
101         _MALI_UK_MEM_WRITE_SAFE,                 /**< _mali_uku_mem_write_safe() */
102
103         /** Common functions for each core */
104
105         _MALI_UK_START_JOB           = 0,     /**< Start a Fragment/Vertex Processor Job on a core */
106         _MALI_UK_GET_NUMBER_OF_CORES,         /**< Get the number of Fragment/Vertex Processor cores */
107         _MALI_UK_GET_CORE_VERSION,            /**< Get the Fragment/Vertex Processor version compatible with all cores */
108
109         /** Fragment Processor Functions  */
110
111         _MALI_UK_PP_START_JOB            = _MALI_UK_START_JOB,            /**< _mali_ukk_pp_start_job() */
112         _MALI_UK_GET_PP_NUMBER_OF_CORES  = _MALI_UK_GET_NUMBER_OF_CORES,  /**< _mali_ukk_get_pp_number_of_cores() */
113         _MALI_UK_GET_PP_CORE_VERSION     = _MALI_UK_GET_CORE_VERSION,     /**< _mali_ukk_get_pp_core_version() */
114         _MALI_UK_PP_DISABLE_WB,                                           /**< _mali_ukk_pp_job_disable_wb() */
115         _MALI_UK_PP_AND_GP_START_JOB,                                     /**< _mali_ukk_pp_and_gp_start_job() */
116
117         /** Vertex Processor Functions  */
118
119         _MALI_UK_GP_START_JOB            = _MALI_UK_START_JOB,            /**< _mali_ukk_gp_start_job() */
120         _MALI_UK_GET_GP_NUMBER_OF_CORES  = _MALI_UK_GET_NUMBER_OF_CORES,  /**< _mali_ukk_get_gp_number_of_cores() */
121         _MALI_UK_GET_GP_CORE_VERSION     = _MALI_UK_GET_CORE_VERSION,     /**< _mali_ukk_get_gp_core_version() */
122         _MALI_UK_GP_SUSPEND_RESPONSE,                                     /**< _mali_ukk_gp_suspend_response() */
123
124         /** Profiling functions */
125
126         _MALI_UK_PROFILING_ADD_EVENT     = 0, /**< __mali_uku_profiling_add_event() */
127         _MALI_UK_PROFILING_REPORT_SW_COUNTERS,/**< __mali_uku_profiling_report_sw_counters() */
128         _MALI_UK_PROFILING_MEMORY_USAGE_GET,  /**< __mali_uku_profiling_memory_usage_get() */
129
130         /** VSYNC reporting fuctions */
131         _MALI_UK_VSYNC_EVENT_REPORT      = 0, /**< _mali_ukk_vsync_event_report() */
132 } _mali_uk_functions;
133
134 /** @defgroup _mali_uk_getsysteminfo U/K Get System Info
135  * @{ */
136
137 /**
138  * Type definition for the core version number.
139  * Used when returning the version number read from a core
140  *
141  * Its format is that of the 32-bit Version register for a particular core.
142  * Refer to the "Mali200 and MaliGP2 3D Graphics Processor Technical Reference
143  * Manual", ARM DDI 0415C, for more information.
144  */
145 typedef u32 _mali_core_version;
146
147 /** @} */ /* end group _mali_uk_core */
148
149
150 /** @defgroup _mali_uk_gp U/K Vertex Processor
151  * @{ */
152
153 /** @defgroup _mali_uk_gp_suspend_response_s Vertex Processor Suspend Response
154  * @{ */
155
156 /** @brief Arguments for _mali_ukk_gp_suspend_response()
157  *
158  * When _mali_wait_for_notification() receives notification that a
159  * Vertex Processor job was suspended, you need to send a response to indicate
160  * what needs to happen with this job. You can either abort or resume the job.
161  *
162  * - set @c code to indicate response code. This is either @c _MALIGP_JOB_ABORT or
163  * @c _MALIGP_JOB_RESUME_WITH_NEW_HEAP to indicate you will provide a new heap
164  * for the job that will resolve the out of memory condition for the job.
165  * - copy the @c cookie value from the @c _mali_uk_gp_job_suspended_s notification;
166  * this is an identifier for the suspended job
167  * - set @c arguments[0] and @c arguments[1] to zero if you abort the job. If
168  * you resume it, @c argument[0] should specify the Mali start address for the new
169  * heap and @c argument[1] the Mali end address of the heap.
170  * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
171  *
172  */
173 typedef enum _maligp_job_suspended_response_code {
174         _MALIGP_JOB_ABORT,                  /**< Abort the Vertex Processor job */
175         _MALIGP_JOB_RESUME_WITH_NEW_HEAP    /**< Resume the Vertex Processor job with a new heap */
176 } _maligp_job_suspended_response_code;
177
178 typedef struct {
179         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
180         u32 cookie;                     /**< [in] cookie from the _mali_uk_gp_job_suspended_s notification */
181         _maligp_job_suspended_response_code code; /**< [in] abort or resume response code, see \ref _maligp_job_suspended_response_code */
182         u32 arguments[2];               /**< [in] 0 when aborting a job. When resuming a job, the Mali start and end address for a new heap to resume the job with */
183 } _mali_uk_gp_suspend_response_s;
184
185 /** @} */ /* end group _mali_uk_gp_suspend_response_s */
186
187 /** @defgroup _mali_uk_gpstartjob_s Vertex Processor Start Job
188  * @{ */
189
190 /** @brief Status indicating the result of the execution of a Vertex or Fragment processor job  */
191 typedef enum {
192         _MALI_UK_JOB_STATUS_END_SUCCESS         = 1 << (16 + 0),
193         _MALI_UK_JOB_STATUS_END_OOM             = 1 << (16 + 1),
194         _MALI_UK_JOB_STATUS_END_ABORT           = 1 << (16 + 2),
195         _MALI_UK_JOB_STATUS_END_TIMEOUT_SW      = 1 << (16 + 3),
196         _MALI_UK_JOB_STATUS_END_HANG            = 1 << (16 + 4),
197         _MALI_UK_JOB_STATUS_END_SEG_FAULT       = 1 << (16 + 5),
198         _MALI_UK_JOB_STATUS_END_ILLEGAL_JOB     = 1 << (16 + 6),
199         _MALI_UK_JOB_STATUS_END_UNKNOWN_ERR     = 1 << (16 + 7),
200         _MALI_UK_JOB_STATUS_END_SHUTDOWN        = 1 << (16 + 8),
201         _MALI_UK_JOB_STATUS_END_SYSTEM_UNUSABLE = 1 << (16 + 9)
202 } _mali_uk_job_status;
203
204 #define MALIGP2_NUM_REGS_FRAME (6)
205
206 /** @brief Arguments for _mali_ukk_gp_start_job()
207  *
208  * To start a Vertex Processor job
209  * - associate the request with a reference to a @c mali_gp_job_info by setting
210  * user_job_ptr to the address of the @c mali_gp_job_info of the job.
211  * - set @c priority to the priority of the @c mali_gp_job_info
212  * - specify a timeout for the job by setting @c watchdog_msecs to the number of
213  * milliseconds the job is allowed to run. Specifying a value of 0 selects the
214  * default timeout in use by the device driver.
215  * - copy the frame registers from the @c mali_gp_job_info into @c frame_registers.
216  * - set the @c perf_counter_flag, @c perf_counter_src0 and @c perf_counter_src1 to zero
217  * for a non-instrumented build. For an instrumented build you can use up
218  * to two performance counters. Set the corresponding bit in @c perf_counter_flag
219  * to enable them. @c perf_counter_src0 and @c perf_counter_src1 specify
220  * the source of what needs to get counted (e.g. number of vertex loader
221  * cache hits). For source id values, see ARM DDI0415A, Table 3-60.
222  * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
223  *
224  * When @c _mali_ukk_gp_start_job() returns @c _MALI_OSK_ERR_OK, status contains the
225  * result of the request (see \ref _mali_uk_start_job_status). If the job could
226  * not get started (@c _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE) it should be
227  * tried again.
228  *
229  * After the job has started, @c _mali_wait_for_notification() will be notified
230  * that the job finished or got suspended. It may get suspended due to
231  * resource shortage. If it finished (see _mali_ukk_wait_for_notification())
232  * the notification will contain a @c _mali_uk_gp_job_finished_s result. If
233  * it got suspended the notification will contain a @c _mali_uk_gp_job_suspended_s
234  * result.
235  *
236  * The @c _mali_uk_gp_job_finished_s contains the job status (see \ref _mali_uk_job_status),
237  * the number of milliseconds the job took to render, and values of core registers
238  * when the job finished (irq status, performance counters, renderer list
239  * address). A job has finished succesfully when its status is
240  * @c _MALI_UK_JOB_STATUS_FINISHED. If the hardware detected a timeout while rendering
241  * the job, or software detected the job is taking more than watchdog_msecs to
242  * complete, the status will indicate @c _MALI_UK_JOB_STATUS_HANG.
243  * If the hardware detected a bus error while accessing memory associated with the
244  * job, status will indicate @c _MALI_UK_JOB_STATUS_SEG_FAULT.
245  * status will indicate @c _MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to
246  * stop the job but the job didn't start on the hardware yet, e.g. when the
247  * driver shutdown.
248  *
249  * In case the job got suspended, @c _mali_uk_gp_job_suspended_s contains
250  * the @c user_job_ptr identifier used to start the job with, the @c reason
251  * why the job stalled (see \ref _maligp_job_suspended_reason) and a @c cookie
252  * to identify the core on which the job stalled.  This @c cookie will be needed
253  * when responding to this nofication by means of _mali_ukk_gp_suspend_response().
254  * (see _mali_ukk_gp_suspend_response()). The response is either to abort or
255  * resume the job. If the job got suspended due to an out of memory condition
256  * you may be able to resolve this by providing more memory and resuming the job.
257  *
258  */
259 typedef struct {
260         u64 ctx;                          /**< [in,out] user-kernel context (trashed on output) */
261         u64 user_job_ptr;                   /**< [in] identifier for the job in user space, a @c mali_gp_job_info* */
262         u32 priority;                       /**< [in] job priority. A lower number means higher priority */
263         u32 frame_registers[MALIGP2_NUM_REGS_FRAME]; /**< [in] core specific registers associated with this job */
264         u32 perf_counter_flag;              /**< [in] bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */
265         u32 perf_counter_src0;              /**< [in] source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */
266         u32 perf_counter_src1;              /**< [in] source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */
267         u32 frame_builder_id;               /**< [in] id of the originating frame builder */
268         u32 flush_id;                       /**< [in] flush id within the originating frame builder */
269         _mali_uk_fence_t fence;             /**< [in] fence this job must wait on */
270         u64 timeline_point_ptr;            /**< [in,out] pointer to u32: location where point on gp timeline for this job will be written */
271 } _mali_uk_gp_start_job_s;
272
273 #define _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE (1<<0) /**< Enable performance counter SRC0 for a job */
274 #define _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE (1<<1) /**< Enable performance counter SRC1 for a job */
275 #define _MALI_PERFORMANCE_COUNTER_FLAG_HEATMAP_ENABLE (1<<2) /**< Enable per tile (aka heatmap) generation with for a job (using the enabled counter sources) */
276
277 /** @} */ /* end group _mali_uk_gpstartjob_s */
278
279 typedef struct {
280         u64 user_job_ptr;               /**< [out] identifier for the job in user space */
281         _mali_uk_job_status status;     /**< [out] status of finished job */
282         u32 heap_current_addr;          /**< [out] value of the GP PLB PL heap start address register */
283         u32 perf_counter0;              /**< [out] value of performance counter 0 (see ARM DDI0415A) */
284         u32 perf_counter1;              /**< [out] value of performance counter 1 (see ARM DDI0415A) */
285 } _mali_uk_gp_job_finished_s;
286
287 typedef struct {
288         u64 user_job_ptr;                    /**< [out] identifier for the job in user space */
289         u32 cookie;                          /**< [out] identifier for the core in kernel space on which the job stalled */
290 } _mali_uk_gp_job_suspended_s;
291
292 /** @} */ /* end group _mali_uk_gp */
293
294
295 /** @defgroup _mali_uk_pp U/K Fragment Processor
296  * @{ */
297
298 #define _MALI_PP_MAX_SUB_JOBS 8
299
300 #define _MALI_PP_MAX_FRAME_REGISTERS ((0x058/4)+1)
301
302 #define _MALI_PP_MAX_WB_REGISTERS ((0x02C/4)+1)
303
304 #define _MALI_DLBU_MAX_REGISTERS 4
305
306 /** Flag for _mali_uk_pp_start_job_s */
307 #define _MALI_PP_JOB_FLAG_NO_NOTIFICATION (1<<0)
308 #define _MALI_PP_JOB_FLAG_IS_WINDOW_SURFACE (1<<1)
309
310 /** @defgroup _mali_uk_ppstartjob_s Fragment Processor Start Job
311  * @{ */
312
313 /** @brief Arguments for _mali_ukk_pp_start_job()
314  *
315  * To start a Fragment Processor job
316  * - associate the request with a reference to a mali_pp_job by setting
317  * @c user_job_ptr to the address of the @c mali_pp_job of the job.
318  * - set @c priority to the priority of the mali_pp_job
319  * - specify a timeout for the job by setting @c watchdog_msecs to the number of
320  * milliseconds the job is allowed to run. Specifying a value of 0 selects the
321  * default timeout in use by the device driver.
322  * - copy the frame registers from the @c mali_pp_job into @c frame_registers.
323  * For MALI200 you also need to copy the write back 0,1 and 2 registers.
324  * - set the @c perf_counter_flag, @c perf_counter_src0 and @c perf_counter_src1 to zero
325  * for a non-instrumented build. For an instrumented build you can use up
326  * to two performance counters. Set the corresponding bit in @c perf_counter_flag
327  * to enable them. @c perf_counter_src0 and @c perf_counter_src1 specify
328  * the source of what needs to get counted (e.g. number of vertex loader
329  * cache hits). For source id values, see ARM DDI0415A, Table 3-60.
330  * - pass in the user-kernel context in @c ctx that was returned from _mali_ukk_open()
331  *
332  * When _mali_ukk_pp_start_job() returns @c _MALI_OSK_ERR_OK, @c status contains the
333  * result of the request (see \ref _mali_uk_start_job_status). If the job could
334  * not get started (@c _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE) it should be
335  * tried again.
336  *
337  * After the job has started, _mali_wait_for_notification() will be notified
338  * when the job finished. The notification will contain a
339  * @c _mali_uk_pp_job_finished_s result. It contains the @c user_job_ptr
340  * identifier used to start the job with, the job @c status (see \ref _mali_uk_job_status),
341  * the number of milliseconds the job took to render, and values of core registers
342  * when the job finished (irq status, performance counters, renderer list
343  * address). A job has finished succesfully when its status is
344  * @c _MALI_UK_JOB_STATUS_FINISHED. If the hardware detected a timeout while rendering
345  * the job, or software detected the job is taking more than @c watchdog_msecs to
346  * complete, the status will indicate @c _MALI_UK_JOB_STATUS_HANG.
347  * If the hardware detected a bus error while accessing memory associated with the
348  * job, status will indicate @c _MALI_UK_JOB_STATUS_SEG_FAULT.
349  * status will indicate @c _MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to
350  * stop the job but the job didn't start on the hardware yet, e.g. when the
351  * driver shutdown.
352  *
353  */
354 typedef struct {
355         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
356         u64 user_job_ptr;               /**< [in] identifier for the job in user space */
357         u32 priority;                   /**< [in] job priority. A lower number means higher priority */
358         u32 frame_registers[_MALI_PP_MAX_FRAME_REGISTERS];         /**< [in] core specific registers associated with first sub job, see ARM DDI0415A */
359         u32 frame_registers_addr_frame[_MALI_PP_MAX_SUB_JOBS - 1]; /**< [in] ADDR_FRAME registers for sub job 1-7 */
360         u32 frame_registers_addr_stack[_MALI_PP_MAX_SUB_JOBS - 1]; /**< [in] ADDR_STACK registers for sub job 1-7 */
361         u32 wb0_registers[_MALI_PP_MAX_WB_REGISTERS];
362         u32 wb1_registers[_MALI_PP_MAX_WB_REGISTERS];
363         u32 wb2_registers[_MALI_PP_MAX_WB_REGISTERS];
364         u32 dlbu_registers[_MALI_DLBU_MAX_REGISTERS]; /**< [in] Dynamic load balancing unit registers */
365         u32 num_cores;                      /**< [in] Number of cores to set up (valid range: 1-8(M450) or 4(M400)) */
366         u32 perf_counter_flag;              /**< [in] bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */
367         u32 perf_counter_src0;              /**< [in] source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */
368         u32 perf_counter_src1;              /**< [in] source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */
369         u32 frame_builder_id;               /**< [in] id of the originating frame builder */
370         u32 flush_id;                       /**< [in] flush id within the originating frame builder */
371         u32 flags;                          /**< [in] See _MALI_PP_JOB_FLAG_* for a list of avaiable flags */
372         u32 tilesx;                         /**< [in] number of tiles in the x direction (needed for heatmap generation */
373         u32 tilesy;                         /**< [in] number of tiles in y direction (needed for reading the heatmap memory) */
374         u32 heatmap_mem;                    /**< [in] memory address to store counter values per tile (aka heatmap) */
375         u32 num_memory_cookies;             /**< [in] number of memory cookies attached to job */
376         u64 memory_cookies;               /**< [in] pointer to array of u32 memory cookies attached to job */
377         _mali_uk_fence_t fence;             /**< [in] fence this job must wait on */
378         u64 timeline_point_ptr;           /**< [in,out] pointer to location of u32 where point on pp timeline for this job will be written */
379 } _mali_uk_pp_start_job_s;
380
381 typedef struct {
382         u64 ctx;       /**< [in,out] user-kernel context (trashed on output) */
383         u64 gp_args;   /**< [in,out] GP uk arguments (see _mali_uk_gp_start_job_s) */
384         u64 pp_args;   /**< [in,out] PP uk arguments (see _mali_uk_pp_start_job_s) */
385 } _mali_uk_pp_and_gp_start_job_s;
386
387 /** @} */ /* end group _mali_uk_ppstartjob_s */
388
389 typedef struct {
390         u64 user_job_ptr;                          /**< [out] identifier for the job in user space */
391         _mali_uk_job_status status;                /**< [out] status of finished job */
392         u32 perf_counter0[_MALI_PP_MAX_SUB_JOBS];  /**< [out] value of perfomance counter 0 (see ARM DDI0415A), one for each sub job */
393         u32 perf_counter1[_MALI_PP_MAX_SUB_JOBS];  /**< [out] value of perfomance counter 1 (see ARM DDI0415A), one for each sub job */
394         u32 perf_counter_src0;
395         u32 perf_counter_src1;
396 } _mali_uk_pp_job_finished_s;
397
398 typedef struct {
399         u32 number_of_enabled_cores;               /**< [out] the new number of enabled cores */
400 } _mali_uk_pp_num_cores_changed_s;
401
402
403
404 /**
405  * Flags to indicate write-back units
406  */
407 typedef enum {
408         _MALI_UK_PP_JOB_WB0 = 1,
409         _MALI_UK_PP_JOB_WB1 = 2,
410         _MALI_UK_PP_JOB_WB2 = 4,
411 } _mali_uk_pp_job_wbx_flag;
412
413 typedef struct {
414         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
415         u32 fb_id;                      /**< [in] Frame builder ID of job to disable WB units for */
416         u32 wb0_memory;
417         u32 wb1_memory;
418         u32 wb2_memory;
419 } _mali_uk_pp_disable_wb_s;
420
421
422 /** @} */ /* end group _mali_uk_pp */
423
424 /** @defgroup _mali_uk_soft_job U/K Soft Job
425  * @{ */
426
427 typedef struct {
428         u64 ctx;                            /**< [in,out] user-kernel context (trashed on output) */
429         u64 user_job;                       /**< [in] identifier for the job in user space */
430         u64 job_id_ptr;                     /**< [in,out] pointer to location of u32 where job id will be written */
431         _mali_uk_fence_t fence;             /**< [in] fence this job must wait on */
432         u32 point;                          /**< [out] point on soft timeline for this job */
433         u32 type;                           /**< [in] type of soft job */
434 } _mali_uk_soft_job_start_s;
435
436 typedef struct {
437         u64 user_job;                       /**< [out] identifier for the job in user space */
438 } _mali_uk_soft_job_activated_s;
439
440 typedef struct {
441         u64 ctx;                          /**< [in,out] user-kernel context (trashed on output) */
442         u32 job_id;                         /**< [in] id for soft job */
443 } _mali_uk_soft_job_signal_s;
444
445 /** @} */ /* end group _mali_uk_soft_job */
446
447 /** @addtogroup _mali_uk_core U/K Core
448  * @{ */
449
450 /** @defgroup _mali_uk_waitfornotification_s Wait For Notification
451  * @{ */
452
453 /** @brief Notification type encodings
454  *
455  * Each Notification type is an ordered pair of (subsystem,id), and is unique.
456  *
457  * The encoding of subsystem,id into a 32-bit word is:
458  * encoding = (( subsystem << _MALI_NOTIFICATION_SUBSYSTEM_SHIFT ) & _MALI_NOTIFICATION_SUBSYSTEM_MASK)
459  *            | (( id <<  _MALI_NOTIFICATION_ID_SHIFT ) & _MALI_NOTIFICATION_ID_MASK)
460  *
461  * @see _mali_uk_wait_for_notification_s
462  */
463 typedef enum {
464         /** core notifications */
465
466         _MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x20,
467         _MALI_NOTIFICATION_APPLICATION_QUIT = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x40,
468         _MALI_NOTIFICATION_SETTINGS_CHANGED = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x80,
469         _MALI_NOTIFICATION_SOFT_ACTIVATED = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x100,
470
471         /** Fragment Processor notifications */
472
473         _MALI_NOTIFICATION_PP_FINISHED = (_MALI_UK_PP_SUBSYSTEM << 16) | 0x10,
474         _MALI_NOTIFICATION_PP_NUM_CORE_CHANGE = (_MALI_UK_PP_SUBSYSTEM << 16) | 0x20,
475
476         /** Vertex Processor notifications */
477
478         _MALI_NOTIFICATION_GP_FINISHED = (_MALI_UK_GP_SUBSYSTEM << 16) | 0x10,
479         _MALI_NOTIFICATION_GP_STALLED = (_MALI_UK_GP_SUBSYSTEM << 16) | 0x20,
480
481 } _mali_uk_notification_type;
482
483 /** to assist in splitting up 32-bit notification value in subsystem and id value */
484 #define _MALI_NOTIFICATION_SUBSYSTEM_MASK 0xFFFF0000
485 #define _MALI_NOTIFICATION_SUBSYSTEM_SHIFT 16
486 #define _MALI_NOTIFICATION_ID_MASK 0x0000FFFF
487 #define _MALI_NOTIFICATION_ID_SHIFT 0
488
489
490 /** @brief Enumeration of possible settings which match mali_setting_t in user space
491  *
492  *
493  */
494 typedef enum {
495         _MALI_UK_USER_SETTING_SW_EVENTS_ENABLE = 0,
496         _MALI_UK_USER_SETTING_COLORBUFFER_CAPTURE_ENABLED,
497         _MALI_UK_USER_SETTING_DEPTHBUFFER_CAPTURE_ENABLED,
498         _MALI_UK_USER_SETTING_STENCILBUFFER_CAPTURE_ENABLED,
499         _MALI_UK_USER_SETTING_PER_TILE_COUNTERS_CAPTURE_ENABLED,
500         _MALI_UK_USER_SETTING_BUFFER_CAPTURE_COMPOSITOR,
501         _MALI_UK_USER_SETTING_BUFFER_CAPTURE_WINDOW,
502         _MALI_UK_USER_SETTING_BUFFER_CAPTURE_OTHER,
503         _MALI_UK_USER_SETTING_BUFFER_CAPTURE_N_FRAMES,
504         _MALI_UK_USER_SETTING_BUFFER_CAPTURE_RESIZE_FACTOR,
505         _MALI_UK_USER_SETTING_SW_COUNTER_ENABLED,
506         _MALI_UK_USER_SETTING_MAX,
507 } _mali_uk_user_setting_t;
508
509 /* See mali_user_settings_db.c */
510 extern const char *_mali_uk_user_setting_descriptions[];
511 #define _MALI_UK_USER_SETTING_DESCRIPTIONS \
512         {                                           \
513                 "sw_events_enable",                 \
514                 "colorbuffer_capture_enable",       \
515                 "depthbuffer_capture_enable",       \
516                 "stencilbuffer_capture_enable",     \
517                 "per_tile_counters_enable",         \
518                 "buffer_capture_compositor",        \
519                 "buffer_capture_window",            \
520                 "buffer_capture_other",             \
521                 "buffer_capture_n_frames",          \
522                 "buffer_capture_resize_factor",     \
523                 "sw_counters_enable",               \
524         };
525
526 /** @brief struct to hold the value to a particular setting as seen in the kernel space
527  */
528 typedef struct {
529         _mali_uk_user_setting_t setting;
530         u32 value;
531 } _mali_uk_settings_changed_s;
532
533 /** @brief Arguments for _mali_ukk_wait_for_notification()
534  *
535  * On successful return from _mali_ukk_wait_for_notification(), the members of
536  * this structure will indicate the reason for notification.
537  *
538  * Specifically, the source of the notification can be identified by the
539  * subsystem and id fields of the mali_uk_notification_type in the code.type
540  * member. The type member is encoded in a way to divide up the types into a
541  * subsystem field, and a per-subsystem ID field. See
542  * _mali_uk_notification_type for more information.
543  *
544  * Interpreting the data union member depends on the notification type:
545  *
546  * - type == _MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS
547  *     - The kernel side is shutting down. No further
548  * _mali_uk_wait_for_notification() calls should be made.
549  *     - In this case, the value of the data union member is undefined.
550  *     - This is used to indicate to the user space client that it should close
551  * the connection to the Mali Device Driver.
552  * - type == _MALI_NOTIFICATION_PP_FINISHED
553  *    - The notification data is of type _mali_uk_pp_job_finished_s. It contains the user_job_ptr
554  * identifier used to start the job with, the job status, the number of milliseconds the job took to render,
555  * and values of core registers when the job finished (irq status, performance counters, renderer list
556  * address).
557  *    - A job has finished succesfully when its status member is _MALI_UK_JOB_STATUS_FINISHED.
558  *    - If the hardware detected a timeout while rendering the job, or software detected the job is
559  * taking more than watchdog_msecs (see _mali_ukk_pp_start_job()) to complete, the status member will
560  * indicate _MALI_UK_JOB_STATUS_HANG.
561  *    - If the hardware detected a bus error while accessing memory associated with the job, status will
562  * indicate _MALI_UK_JOB_STATUS_SEG_FAULT.
563  *    - Status will indicate MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to stop the job but the job
564  * didn't start the hardware yet, e.g. when the driver closes.
565  * - type == _MALI_NOTIFICATION_GP_FINISHED
566  *     - The notification data is of type _mali_uk_gp_job_finished_s. The notification is similar to that of
567  * type == _MALI_NOTIFICATION_PP_FINISHED, except that several other GP core register values are returned.
568  * The status values have the same meaning for type == _MALI_NOTIFICATION_PP_FINISHED.
569  * - type == _MALI_NOTIFICATION_GP_STALLED
570  *     - The nofication data is of type _mali_uk_gp_job_suspended_s. It contains the user_job_ptr
571  * identifier used to start the job with, the reason why the job stalled and a cookie to identify the core on
572  * which the job stalled.
573  *     - The reason member of gp_job_suspended is set to _MALIGP_JOB_SUSPENDED_OUT_OF_MEMORY
574  * when the polygon list builder unit has run out of memory.
575  */
576 typedef struct {
577         u64 ctx;                       /**< [in,out] user-kernel context (trashed on output) */
578         _mali_uk_notification_type type; /**< [out] Type of notification available */
579         union {
580                 _mali_uk_gp_job_suspended_s gp_job_suspended;/**< [out] Notification data for _MALI_NOTIFICATION_GP_STALLED notification type */
581                 _mali_uk_gp_job_finished_s  gp_job_finished; /**< [out] Notification data for _MALI_NOTIFICATION_GP_FINISHED notification type */
582                 _mali_uk_pp_job_finished_s  pp_job_finished; /**< [out] Notification data for _MALI_NOTIFICATION_PP_FINISHED notification type */
583                 _mali_uk_settings_changed_s setting_changed;/**< [out] Notification data for _MALI_NOTIFICAATION_SETTINGS_CHANGED notification type */
584                 _mali_uk_soft_job_activated_s soft_job_activated; /**< [out] Notification data for _MALI_NOTIFICATION_SOFT_ACTIVATED notification type */
585         } data;
586 } _mali_uk_wait_for_notification_s;
587
588 /** @brief Arguments for _mali_ukk_post_notification()
589  *
590  * Posts the specified notification to the notification queue for this application.
591  * This is used to send a quit message to the callback thread.
592  */
593 typedef struct {
594         u64 ctx;                       /**< [in,out] user-kernel context (trashed on output) */
595         _mali_uk_notification_type type; /**< [in] Type of notification to post */
596 } _mali_uk_post_notification_s;
597
598 /** @} */ /* end group _mali_uk_waitfornotification_s */
599
600 /** @defgroup _mali_uk_getapiversion_s Get API Version
601  * @{ */
602
603 /** helpers for Device Driver API version handling */
604
605 /** @brief Encode a version ID from a 16-bit input
606  *
607  * @note the input is assumed to be 16 bits. It must not exceed 16 bits. */
608 #define _MAKE_VERSION_ID(x) (((x) << 16UL) | (x))
609
610 /** @brief Check whether a 32-bit value is likely to be Device Driver API
611  * version ID. */
612 #define _IS_VERSION_ID(x) (((x) & 0xFFFF) == (((x) >> 16UL) & 0xFFFF))
613
614 /** @brief Decode a 16-bit version number from a 32-bit Device Driver API version
615  * ID */
616 #define _GET_VERSION(x) (((x) >> 16UL) & 0xFFFF)
617
618 /** @brief Determine whether two 32-bit encoded version IDs match */
619 #define _IS_API_MATCH(x, y) (IS_VERSION_ID((x)) && IS_VERSION_ID((y)) && (GET_VERSION((x)) == GET_VERSION((y))))
620  /**
621   * RK MALI version code
622   */
623 #define _MALI_RK_LIBS_VERSION 1
624
625 /**
626  * API version define.
627  * Indicates the version of the kernel API
628  * The version is a 16bit integer incremented on each API change.
629  * The 16bit integer is stored twice in a 32bit integer
630  * For example, for version 1 the value would be 0x00010001
631  */
632 #define _MALI_API_VERSION 600
633 #define _MALI_UK_API_VERSION _MAKE_VERSION_ID(_MALI_API_VERSION)
634
635 /**
636  * The API version is a 16-bit integer stored in both the lower and upper 16-bits
637  * of a 32-bit value. The 16-bit API version value is incremented on each API
638  * change. Version 1 would be 0x00010001. Used in _mali_uk_get_api_version_s.
639  */
640 typedef u32 _mali_uk_api_version;
641
642 /** @brief Arguments for _mali_uk_get_api_version()
643  *
644  * The user-side interface version must be written into the version member,
645  * encoded using _MAKE_VERSION_ID(). It will be compared to the API version of
646  * the kernel-side interface.
647  *
648  * On successful return, the version member will be the API version of the
649  * kernel-side interface. _MALI_UK_API_VERSION macro defines the current version
650  * of the API.
651  *
652  * The compatible member must be checked to see if the version of the user-side
653  * interface is compatible with the kernel-side interface, since future versions
654  * of the interface may be backwards compatible.
655  */
656 typedef struct {
657         u32 ctx;                        /**< [in,out] user-kernel context (trashed on output) */
658         _mali_uk_api_version version;   /**< [in,out] API version of user-side interface. */
659         int compatible;                 /**< [out] @c 1 when @version is compatible, @c 0 otherwise */
660 } _mali_uk_get_api_version_s;
661
662 /** @brief Arguments for _mali_uk_get_api_version_v2()
663  *
664  * The user-side interface version must be written into the version member,
665  * encoded using _MAKE_VERSION_ID(). It will be compared to the API version of
666  * the kernel-side interface.
667  *
668  * On successful return, the version member will be the API version of the
669  * kernel-side interface. _MALI_UK_API_VERSION macro defines the current version
670  * of the API.
671  *
672  * The compatible member must be checked to see if the version of the user-side
673  * interface is compatible with the kernel-side interface, since future versions
674  * of the interface may be backwards compatible.
675  */
676 typedef struct {
677         u64 ctx;                        /**< [in,out] user-kernel context (trashed on output) */
678         _mali_uk_api_version version;   /**< [in,out] API version of user-side interface. */
679         int compatible;                 /**< [out] @c 1 when @version is compatible, @c 0 otherwise */
680 } _mali_uk_get_api_version_v2_s;
681
682 typedef struct
683 {
684     u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
685     _mali_uk_api_version version;                   /**< [in,out] API version of user-side interface. */
686 } _mali_uk_get_mali_version_in_rk30_s;
687
688 /* rk_ext : rk_ko_ver_t. */
689 typedef struct {
690         u64 ctx;                        /**< [in,out] user-kernel context (trashed on output) */
691         _mali_uk_api_version version;   /**< [in,out] API version of user-side interface. */
692 } _mali_rk_ko_version_s;
693 /** @} */ /* end group _mali_uk_getapiversion_s */
694
695 /** @defgroup _mali_uk_get_user_settings_s Get user space settings */
696
697 /** @brief struct to keep the matching values of the user space settings within certain context
698  *
699  * Each member of the settings array corresponds to a matching setting in the user space and its value is the value
700  * of that particular setting.
701  *
702  * All settings are given reference to the context pointed to by the ctx pointer.
703  *
704  */
705 typedef struct {
706         u64 ctx;                       /**< [in,out] user-kernel context (trashed on output) */
707         u32 settings[_MALI_UK_USER_SETTING_MAX]; /**< [out] The values for all settings */
708 } _mali_uk_get_user_settings_s;
709
710 /** @brief struct to hold the value of a particular setting from the user space within a given context
711  */
712 typedef struct {
713         u64 ctx;                       /**< [in,out] user-kernel context (trashed on output) */
714         _mali_uk_user_setting_t setting; /**< [in] setting to get */
715         u32 value;                       /**< [out] value of setting */
716 } _mali_uk_get_user_setting_s;
717
718 /** @brief Arguments for _mali_ukk_request_high_priority() */
719 typedef struct {
720         u64 ctx;                       /**< [in,out] user-kernel context (trashed on output) */
721 } _mali_uk_request_high_priority_s;
722
723 /** @} */ /* end group _mali_uk_core */
724
725
726 /** @defgroup _mali_uk_memory U/K Memory
727  * @{ */
728
729 /** Flag for _mali_uk_map_external_mem_s, _mali_uk_attach_ump_mem_s and _mali_uk_attach_dma_buf_s */
730 #define _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE (1<<0)
731
732 typedef struct {
733         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
734         u32 phys_addr;                  /**< [in] physical address */
735         u32 size;                       /**< [in] size */
736         u32 mali_address;               /**< [in] mali address to map the physical memory to */
737         u32 rights;                     /**< [in] rights necessary for accessing memory */
738         u32 flags;                      /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */
739         u32 cookie;                     /**< [out] identifier for mapped memory object in kernel space  */
740 } _mali_uk_map_external_mem_s;
741
742 typedef struct {
743         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
744         u32 cookie;                     /**< [out] identifier for mapped memory object in kernel space  */
745 } _mali_uk_unmap_external_mem_s;
746
747 /** @note This is identical to _mali_uk_map_external_mem_s above, however phys_addr is replaced by memory descriptor */
748 typedef struct {
749         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
750         u32 mem_fd;                     /**< [in] Memory descriptor */
751         u32 size;                       /**< [in] size */
752         u32 mali_address;               /**< [in] mali address to map the physical memory to */
753         u32 rights;                     /**< [in] rights necessary for accessing memory */
754         u32 flags;                      /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */
755         u32 cookie;                     /**< [out] identifier for mapped memory object in kernel space  */
756 } _mali_uk_attach_dma_buf_s;
757
758 typedef struct {
759         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
760         u32 mem_fd;                     /**< [in] Memory descriptor */
761         u32 size;                       /**< [out] size */
762 } _mali_uk_dma_buf_get_size_s;
763
764 typedef struct {
765         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
766         u64 cookie;                     /**< [in] identifier for mapped memory object in kernel space  */
767 } _mali_uk_release_dma_buf_s;
768
769 /** @note This is identical to _mali_uk_map_external_mem_s above, however phys_addr is replaced by secure_id */
770 typedef struct {
771         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
772         u32 secure_id;                  /**< [in] secure id */
773         u32 size;                       /**< [in] size */
774         u32 mali_address;               /**< [in] mali address to map the physical memory to */
775         u32 rights;                     /**< [in] rights necessary for accessing memory */
776         u32 flags;                      /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */
777         u32 cookie;                     /**< [out] identifier for mapped memory object in kernel space  */
778 } _mali_uk_attach_ump_mem_s;
779
780 typedef struct {
781         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
782         u32 cookie;                     /**< [in] identifier for mapped memory object in kernel space  */
783 } _mali_uk_release_ump_mem_s;
784
785 /**
786  * @brief Arguments for _mali_uk[uk]_mem_write_safe()
787  */
788 typedef struct {
789         u64 ctx;  /**< [in,out] user-kernel context (trashed on output) */
790         u64 src;  /**< [in] Pointer to source data */
791         u64 dest; /**< [in] Destination Mali buffer */
792         u32 size;   /**< [in,out] Number of bytes to write/copy on input, number of bytes actually written/copied on output */
793 } _mali_uk_mem_write_safe_s;
794
795 typedef struct {
796         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
797         u32 size;                       /**< [out] size of MMU page table information (registers + page tables) */
798 } _mali_uk_query_mmu_page_table_dump_size_s;
799
800 typedef struct {
801         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
802         u32 size;                       /**< [in] size of buffer to receive mmu page table information */
803         u64 buffer;                   /**< [in,out] buffer to receive mmu page table information */
804         u32 register_writes_size;       /**< [out] size of MMU register dump */
805         u64 register_writes;           /**< [out] pointer within buffer where MMU register dump is stored */
806         u32 page_table_dump_size;       /**< [out] size of MMU page table dump */
807         u64 page_table_dump;           /**< [out] pointer within buffer where MMU page table dump is stored */
808 } _mali_uk_dump_mmu_page_table_s;
809
810 /** @} */ /* end group _mali_uk_memory */
811
812
813 /** @addtogroup _mali_uk_pp U/K Fragment Processor
814  * @{ */
815
816 /** @brief Arguments for _mali_ukk_get_pp_number_of_cores()
817  *
818  * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
819  * - Upon successful return from _mali_ukk_get_pp_number_of_cores(), @c number_of_cores
820  * will contain the number of Fragment Processor cores in the system.
821  */
822 typedef struct {
823         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
824         u32 number_of_total_cores;      /**< [out] Total number of Fragment Processor cores in the system */
825         u32 number_of_enabled_cores;    /**< [out] Number of enabled Fragment Processor cores */
826 } _mali_uk_get_pp_number_of_cores_s;
827
828 /** @brief Arguments for _mali_ukk_get_pp_core_version()
829  *
830  * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
831  * - Upon successful return from _mali_ukk_get_pp_core_version(), @c version contains
832  * the version that all Fragment Processor cores are compatible with.
833  */
834 typedef struct {
835         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
836         _mali_core_version version;     /**< [out] version returned from core, see \ref _mali_core_version  */
837         u32 padding;
838 } _mali_uk_get_pp_core_version_s;
839
840 /** @} */ /* end group _mali_uk_pp */
841
842
843 /** @addtogroup _mali_uk_gp U/K Vertex Processor
844  * @{ */
845
846 /** @brief Arguments for _mali_ukk_get_gp_number_of_cores()
847  *
848  * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
849  * - Upon successful return from _mali_ukk_get_gp_number_of_cores(), @c number_of_cores
850  * will contain the number of Vertex Processor cores in the system.
851  */
852 typedef struct {
853         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
854         u32 number_of_cores;            /**< [out] number of Vertex Processor cores in the system */
855 } _mali_uk_get_gp_number_of_cores_s;
856
857 /** @brief Arguments for _mali_ukk_get_gp_core_version()
858  *
859  * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
860  * - Upon successful return from _mali_ukk_get_gp_core_version(), @c version contains
861  * the version that all Vertex Processor cores are compatible with.
862  */
863 typedef struct {
864         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
865         _mali_core_version version;     /**< [out] version returned from core, see \ref _mali_core_version */
866 } _mali_uk_get_gp_core_version_s;
867
868 /** @} */ /* end group _mali_uk_gp */
869
870 typedef struct {
871         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
872         u32 event_id;                   /**< [in] event id to register (see  enum mali_profiling_events for values) */
873         u32 data[5];                    /**< [in] event specific data */
874 } _mali_uk_profiling_add_event_s;
875
876 typedef struct {
877         u64 ctx;                     /**< [in,out] user-kernel context (trashed on output) */
878         u32 memory_usage;              /**< [out] total memory usage */
879 } _mali_uk_profiling_memory_usage_get_s;
880
881
882 /** @addtogroup _mali_uk_memory U/K Memory
883  * @{ */
884
885 /** @brief Arguments to _mali_ukk_mem_mmap()
886  *
887  * Use of the phys_addr member depends on whether the driver is compiled for
888  * Mali-MMU or nonMMU:
889  * - in the nonMMU case, this is the physical address of the memory as seen by
890  * the CPU (which may be a constant offset from that used by Mali)
891  * - in the MMU case, this is the Mali Virtual base address of the memory to
892  * allocate, and the particular physical pages used to back the memory are
893  * entirely determined by _mali_ukk_mem_mmap(). The details of the physical pages
894  * are not reported to user-space for security reasons.
895  *
896  * The cookie member must be stored for use later when freeing the memory by
897  * calling _mali_ukk_mem_munmap(). In the Mali-MMU case, the cookie is secure.
898  *
899  * The ukk_private word must be set to zero when calling from user-space. On
900  * Kernel-side, the  OS implementation of the U/K interface can use it to
901  * communicate data to the OS implementation of the OSK layer. In particular,
902  * _mali_ukk_get_big_block() directly calls _mali_ukk_mem_mmap directly, and
903  * will communicate its own ukk_private word through the ukk_private member
904  * here. The common code itself will not inspect or modify the ukk_private
905  * word, and so it may be safely used for whatever purposes necessary to
906  * integrate Mali Memory handling into the OS.
907  *
908  * The uku_private member is currently reserved for use by the user-side
909  * implementation of the U/K interface. Its value must be zero.
910  */
911 typedef struct {
912         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
913         void *mapping;                  /**< [out] Returns user-space virtual address for the mapping */
914         u32 size;                       /**< [in] Size of the requested mapping */
915         u32 phys_addr;                  /**< [in] Physical address - could be offset, depending on caller+callee convention */
916         u32 cookie;                     /**< [out] Returns a cookie for use in munmap calls */
917 } _mali_uk_mem_mmap_s;
918
919 /** @brief Arguments to _mali_ukk_mem_munmap()
920  *
921  * The cookie and mapping members must be that returned from the same previous
922  * call to _mali_ukk_mem_mmap(). The size member must correspond to cookie
923  * and mapping - that is, it must be the value originally supplied to a call to
924  * _mali_ukk_mem_mmap that returned the values of mapping and cookie.
925  *
926  * An error will be returned if an attempt is made to unmap only part of the
927  * originally obtained range, or to unmap more than was originally obtained.
928  */
929 typedef struct {
930         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
931         void *mapping;                  /**< [in] The mapping returned from mmap call */
932         u32 size;                       /**< [in] The size passed to mmap call */
933         u32 cookie;                     /**< [in] Cookie from mmap call */
934 } _mali_uk_mem_munmap_s;
935 /** @} */ /* end group _mali_uk_memory */
936
937 /** @defgroup _mali_uk_vsync U/K VSYNC Wait Reporting Module
938  * @{ */
939
940 /** @brief VSYNC events
941  *
942  * These events are reported when DDK starts to wait for vsync and when the
943  * vsync has occured and the DDK can continue on the next frame.
944  */
945 typedef enum _mali_uk_vsync_event {
946         _MALI_UK_VSYNC_EVENT_BEGIN_WAIT = 0,
947         _MALI_UK_VSYNC_EVENT_END_WAIT
948 } _mali_uk_vsync_event;
949
950 /** @brief Arguments to _mali_ukk_vsync_event()
951  *
952  */
953 typedef struct {
954         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
955         _mali_uk_vsync_event event;     /**< [in] VSYNCH event type */
956 } _mali_uk_vsync_event_report_s;
957
958 /** @} */ /* end group _mali_uk_vsync */
959
960 /** @defgroup _mali_uk_sw_counters_report U/K Software Counter Reporting
961  * @{ */
962
963 /** @brief Software counter values
964  *
965  * Values recorded for each of the software counters during a single renderpass.
966  */
967 typedef struct {
968         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
969         u64 counters;                  /**< [in] The array of u32 counter values */
970         u32 num_counters;              /**< [in] The number of elements in counters array */
971 } _mali_uk_sw_counters_report_s;
972
973 /** @} */ /* end group _mali_uk_sw_counters_report */
974
975 /** @defgroup _mali_uk_timeline U/K Mali Timeline
976  * @{ */
977
978 typedef struct {
979         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
980         u32 timeline;                   /**< [in] timeline id */
981         u32 point;                      /**< [out] latest point on timeline */
982 } _mali_uk_timeline_get_latest_point_s;
983
984 typedef struct {
985         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
986         _mali_uk_fence_t fence;         /**< [in] fence */
987         u32 timeout;                    /**< [in] timeout (0 for no wait, -1 for blocking) */
988         u32 status;                     /**< [out] status of fence (1 if signaled, 0 if timeout) */
989 } _mali_uk_timeline_wait_s;
990
991 typedef struct {
992         u64 ctx;                      /**< [in,out] user-kernel context (trashed on output) */
993         _mali_uk_fence_t fence;         /**< [in] mali fence to create linux sync fence from */
994         s32 sync_fd;                    /**< [out] file descriptor for new linux sync fence */
995 } _mali_uk_timeline_create_sync_fence_s;
996
997 /** @} */ /* end group _mali_uk_timeline */
998
999 /** @} */ /* end group u_k_api */
1000
1001 /** @} */ /* end group uddapi */
1002
1003 #ifdef __cplusplus
1004 }
1005 #endif
1006
1007 #endif /* __MALI_UTGARD_UK_TYPES_H__ */