~thopiekar/arm-mali/mali-400-kernel-drivers-sunxi

« back to all changes in this revision

Viewing changes to driver/src/devicedrv/mali/include/linux/mali/mali_utgard_uk_types.h

  • Committer: Dmitriy Beykun
  • Date: 2012-10-21 16:12:55 UTC
  • Revision ID: git-v1:23debc5a26ce858ef020405dbf91b2f268a72f44
added r3p0-04rel0 kernel drivers

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010-2012 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
{
 
22
#endif
 
23
 
 
24
/**
 
25
 * @addtogroup uddapi Unified Device Driver (UDD) APIs
 
26
 *
 
27
 * @{
 
28
 */
 
29
 
 
30
/**
 
31
 * @addtogroup u_k_api UDD User/Kernel Interface (U/K) APIs
 
32
 *
 
33
 * @{
 
34
 */
 
35
 
 
36
/** @defgroup _mali_uk_core U/K Core
 
37
 * @{ */
 
38
 
 
39
/** Definition of subsystem numbers, to assist in creating a unique identifier
 
40
 * for each U/K call.
 
41
 *
 
42
 * @see _mali_uk_functions */
 
43
typedef enum
 
44
{
 
45
    _MALI_UK_CORE_SUBSYSTEM,      /**< Core Group of U/K calls */
 
46
    _MALI_UK_MEMORY_SUBSYSTEM,    /**< Memory Group of U/K calls */
 
47
    _MALI_UK_PP_SUBSYSTEM,        /**< Fragment Processor Group of U/K calls */
 
48
    _MALI_UK_GP_SUBSYSTEM,        /**< Vertex Processor Group of U/K calls */
 
49
        _MALI_UK_PROFILING_SUBSYSTEM, /**< Profiling Group of U/K calls */
 
50
    _MALI_UK_PMM_SUBSYSTEM,       /**< Power Management Module Group of U/K calls */
 
51
        _MALI_UK_VSYNC_SUBSYSTEM,     /**< VSYNC Group of U/K calls */
 
52
} _mali_uk_subsystem_t;
 
53
 
 
54
/** Within a function group each function has its unique sequence number
 
55
 * to assist in creating a unique identifier for each U/K call.
 
56
 *
 
57
 * An ordered pair of numbers selected from
 
58
 * ( \ref _mali_uk_subsystem_t,\ref  _mali_uk_functions) will uniquely identify the
 
59
 * U/K call across all groups of functions, and all functions. */
 
60
typedef enum
 
61
{
 
62
        /** Core functions */
 
63
 
 
64
    _MALI_UK_OPEN                    = 0, /**< _mali_ukk_open() */
 
65
    _MALI_UK_CLOSE,                       /**< _mali_ukk_close() */
 
66
    _MALI_UK_GET_SYSTEM_INFO_SIZE,        /**< _mali_ukk_get_system_info_size() */
 
67
    _MALI_UK_GET_SYSTEM_INFO,             /**< _mali_ukk_get_system_info() */
 
68
    _MALI_UK_WAIT_FOR_NOTIFICATION,       /**< _mali_ukk_wait_for_notification() */
 
69
    _MALI_UK_GET_API_VERSION,             /**< _mali_ukk_get_api_version() */
 
70
    _MALI_UK_POST_NOTIFICATION,           /**< _mali_ukk_post_notification() */
 
71
        _MALI_UK_GET_USER_SETTING,       /**< _mali_ukk_get_user_setting() *//**< [out] */
 
72
        _MALI_UK_GET_USER_SETTINGS,       /**< _mali_ukk_get_user_settings() *//**< [out] */
 
73
 
 
74
        /** Memory functions */
 
75
 
 
76
    _MALI_UK_INIT_MEM                = 0, /**< _mali_ukk_init_mem() */
 
77
    _MALI_UK_TERM_MEM,                    /**< _mali_ukk_term_mem() */
 
78
    _MALI_UK_GET_BIG_BLOCK,               /**< _mali_ukk_get_big_block() */
 
79
    _MALI_UK_FREE_BIG_BLOCK,              /**< _mali_ukk_free_big_block() */
 
80
    _MALI_UK_MAP_MEM,                     /**< _mali_ukk_mem_mmap() */
 
81
    _MALI_UK_UNMAP_MEM,                   /**< _mali_ukk_mem_munmap() */
 
82
    _MALI_UK_QUERY_MMU_PAGE_TABLE_DUMP_SIZE, /**< _mali_ukk_mem_get_mmu_page_table_dump_size() */
 
83
    _MALI_UK_DUMP_MMU_PAGE_TABLE,         /**< _mali_ukk_mem_dump_mmu_page_table() */
 
84
    _MALI_UK_ATTACH_UMP_MEM,             /**< _mali_ukk_attach_ump_mem() */
 
85
    _MALI_UK_RELEASE_UMP_MEM,           /**< _mali_ukk_release_ump_mem() */
 
86
    _MALI_UK_MAP_EXT_MEM,                 /**< _mali_uku_map_external_mem() */
 
87
    _MALI_UK_UNMAP_EXT_MEM,               /**< _mali_uku_unmap_external_mem() */
 
88
    _MALI_UK_VA_TO_MALI_PA,               /**< _mali_uku_va_to_mali_pa() */
 
89
 
 
90
    /** Common functions for each core */
 
91
 
 
92
    _MALI_UK_START_JOB           = 0,     /**< Start a Fragment/Vertex Processor Job on a core */
 
93
    _MALI_UK_GET_NUMBER_OF_CORES,         /**< Get the number of Fragment/Vertex Processor cores */
 
94
    _MALI_UK_GET_CORE_VERSION,            /**< Get the Fragment/Vertex Processor version compatible with all cores */
 
95
 
 
96
    /** Fragment Processor Functions  */
 
97
 
 
98
    _MALI_UK_PP_START_JOB            = _MALI_UK_START_JOB,            /**< _mali_ukk_pp_start_job() */
 
99
    _MALI_UK_GET_PP_NUMBER_OF_CORES  = _MALI_UK_GET_NUMBER_OF_CORES,  /**< _mali_ukk_get_pp_number_of_cores() */
 
100
    _MALI_UK_GET_PP_CORE_VERSION     = _MALI_UK_GET_CORE_VERSION,     /**< _mali_ukk_get_pp_core_version() */
 
101
    _MALI_UK_PP_DISABLE_WB,                                           /**< _mali_ukk_pp_job_disable_wb() */
 
102
 
 
103
    /** Vertex Processor Functions  */
 
104
 
 
105
    _MALI_UK_GP_START_JOB            = _MALI_UK_START_JOB,            /**< _mali_ukk_gp_start_job() */
 
106
    _MALI_UK_GET_GP_NUMBER_OF_CORES  = _MALI_UK_GET_NUMBER_OF_CORES,  /**< _mali_ukk_get_gp_number_of_cores() */
 
107
    _MALI_UK_GET_GP_CORE_VERSION     = _MALI_UK_GET_CORE_VERSION,     /**< _mali_ukk_get_gp_core_version() */
 
108
    _MALI_UK_GP_SUSPEND_RESPONSE,                                     /**< _mali_ukk_gp_suspend_response() */
 
109
 
 
110
        /** Profiling functions */
 
111
 
 
112
        _MALI_UK_PROFILING_START         = 0, /**< __mali_uku_profiling_start() */
 
113
        _MALI_UK_PROFILING_ADD_EVENT,         /**< __mali_uku_profiling_add_event() */
 
114
        _MALI_UK_PROFILING_STOP,              /**< __mali_uku_profiling_stop() */
 
115
        _MALI_UK_PROFILING_GET_EVENT,         /**< __mali_uku_profiling_get_event() */
 
116
        _MALI_UK_PROFILING_CLEAR,             /**< __mali_uku_profiling_clear() */
 
117
        _MALI_UK_PROFILING_GET_CONFIG,        /**< __mali_uku_profiling_get_config() */
 
118
        _MALI_UK_PROFILING_REPORT_SW_COUNTERS,/**< __mali_uku_profiling_report_sw_counters() */
 
119
 
 
120
        /** VSYNC reporting fuctions */
 
121
        _MALI_UK_VSYNC_EVENT_REPORT      = 0, /**< _mali_ukk_vsync_event_report() */
 
122
 
 
123
} _mali_uk_functions;
 
124
 
 
125
/** @brief Get the size necessary for system info
 
126
 *
 
127
 * @see _mali_ukk_get_system_info_size()
 
128
 */
 
129
typedef struct
 
130
{
 
131
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
132
        u32 size;                       /**< [out] size of buffer necessary to hold system information data, in bytes */
 
133
} _mali_uk_get_system_info_size_s;
 
134
 
 
135
 
 
136
/** @defgroup _mali_uk_getsysteminfo U/K Get System Info
 
137
 * @{ */
 
138
 
 
139
/**
 
140
 * Type definition for the core version number.
 
141
 * Used when returning the version number read from a core
 
142
 *
 
143
 * Its format is that of the 32-bit Version register for a particular core.
 
144
 * Refer to the "Mali200 and MaliGP2 3D Graphics Processor Technical Reference
 
145
 * Manual", ARM DDI 0415C, for more information.
 
146
 */
 
147
typedef u32 _mali_core_version;
 
148
 
 
149
/**
 
150
 * Enum values for the different modes the driver can be put in.
 
151
 * Normal is the default mode. The driver then uses a job queue and takes job objects from the clients.
 
152
 * Job completion is reported using the _mali_ukk_wait_for_notification call.
 
153
 * The driver blocks this io command until a job has completed or failed or a timeout occurs.
 
154
 *
 
155
 * The 'raw' mode is reserved for future expansion.
 
156
 */
 
157
typedef enum _mali_driver_mode
 
158
{
 
159
        _MALI_DRIVER_MODE_RAW = 1,    /**< Reserved for future expansion */
 
160
        _MALI_DRIVER_MODE_NORMAL = 2  /**< Normal mode of operation */
 
161
} _mali_driver_mode;
 
162
 
 
163
/** @brief List of possible cores
 
164
 *
 
165
 * add new entries to the end of this enum */
 
166
typedef enum _mali_core_type
 
167
{
 
168
        _MALI_GP2 = 2,                /**< MaliGP2 Programmable Vertex Processor */
 
169
        _MALI_200 = 5,                /**< Mali200 Programmable Fragment Processor */
 
170
        _MALI_400_GP = 6,             /**< Mali400 Programmable Vertex Processor */
 
171
        _MALI_400_PP = 7,             /**< Mali400 Programmable Fragment Processor */
 
172
        /* insert new core here, do NOT alter the existing values */
 
173
} _mali_core_type;
 
174
 
 
175
/** @brief Information about each Mali Core
 
176
 *
 
177
 * Information is stored in a linked list, which is stored entirely in the
 
178
 * buffer pointed to by the system_info member of the
 
179
 * _mali_uk_get_system_info_s arguments provided to _mali_ukk_get_system_info()
 
180
 *
 
181
 * Both Fragment Processor (PP) and Vertex Processor (GP) cores are represented
 
182
 * by this struct.
 
183
 *
 
184
 * The type is reported by the type field, _mali_core_info::_mali_core_type.
 
185
 *
 
186
 * Each core is given a unique Sequence number identifying it, the core_nr
 
187
 * member.
 
188
 *
 
189
 * Flags are taken directly from the resource's flags, and are currently unused.
 
190
 *
 
191
 * Multiple mali_core_info structs are linked in a single linked list using the next field
 
192
 */
 
193
typedef struct _mali_core_info
 
194
{
 
195
        _mali_core_type type;            /**< Type of core */
 
196
        _mali_core_version version;      /**< Core Version, as reported by the Core's Version Register */
 
197
        u32 reg_address;                 /**< Address of Registers */
 
198
        u32 core_nr;                     /**< Sequence number */
 
199
        u32 flags;                       /**< Flags. Currently Unused. */
 
200
        struct _mali_core_info * next;   /**< Next core in Linked List */
 
201
} _mali_core_info;
 
202
 
 
203
/** @brief Capabilities of Memory Banks
 
204
 *
 
205
 * These may be used to restrict memory banks for certain uses. They may be
 
206
 * used when access is not possible (e.g. Bus does not support access to it)
 
207
 * or when access is possible but not desired (e.g. Access is slow).
 
208
 *
 
209
 * In the case of 'possible but not desired', there is no way of specifying
 
210
 * the flags as an optimization hint, so that the memory could be used as a
 
211
 * last resort.
 
212
 *
 
213
 * @see _mali_mem_info
 
214
 */
 
215
typedef enum _mali_bus_usage
 
216
{
 
217
 
 
218
        _MALI_PP_READABLE   = (1<<0),  /** Readable by the Fragment Processor */
 
219
        _MALI_PP_WRITEABLE  = (1<<1),  /** Writeable by the Fragment Processor */
 
220
        _MALI_GP_READABLE   = (1<<2),  /** Readable by the Vertex Processor */
 
221
        _MALI_GP_WRITEABLE  = (1<<3),  /** Writeable by the Vertex Processor */
 
222
        _MALI_CPU_READABLE  = (1<<4),  /** Readable by the CPU */
 
223
        _MALI_CPU_WRITEABLE = (1<<5),  /** Writeable by the CPU */
 
224
        _MALI_MMU_READABLE  = _MALI_PP_READABLE | _MALI_GP_READABLE,   /** Readable by the MMU (including all cores behind it) */
 
225
        _MALI_MMU_WRITEABLE = _MALI_PP_WRITEABLE | _MALI_GP_WRITEABLE, /** Writeable by the MMU (including all cores behind it) */
 
226
} _mali_bus_usage;
 
227
 
 
228
/** @brief Information about the Mali Memory system
 
229
 *
 
230
 * Information is stored in a linked list, which is stored entirely in the
 
231
 * buffer pointed to by the system_info member of the
 
232
 * _mali_uk_get_system_info_s arguments provided to _mali_ukk_get_system_info()
 
233
 *
 
234
 * Each element of the linked list describes a single Mali Memory bank.
 
235
 * Each allocation can only come from one bank, and will not cross multiple
 
236
 * banks.
 
237
 *
 
238
 * Each bank is uniquely identified by its identifier member. On Mali-nonMMU
 
239
 * systems, to allocate from this bank, the value of identifier must be passed
 
240
 * as the type_id member of the  _mali_uk_get_big_block_s arguments to
 
241
 * _mali_ukk_get_big_block.
 
242
 *
 
243
 * On Mali-MMU systems, there is only one bank, which describes the maximum
 
244
 * possible address range that could be allocated (which may be much less than
 
245
 * the available physical memory)
 
246
 *
 
247
 * The flags member describes the capabilities of the memory. It is an error
 
248
 * to attempt to build a job for a particular core (PP or GP) when the memory
 
249
 * regions used do not have the capabilities for supporting that core. This
 
250
 * would result in a job abort from the Device Driver.
 
251
 *
 
252
 * For example, it is correct to build a PP job where read-only data structures
 
253
 * are taken from a memory with _MALI_PP_READABLE set and
 
254
 * _MALI_PP_WRITEABLE clear, and a framebuffer with  _MALI_PP_WRITEABLE set and
 
255
 * _MALI_PP_READABLE clear. However, it would be incorrect to use a framebuffer
 
256
 * where _MALI_PP_WRITEABLE is clear.
 
257
 */
 
258
typedef struct _mali_mem_info
 
259
{
 
260
        u32 size;                     /**< Size of the memory bank in bytes */
 
261
        _mali_bus_usage flags;        /**< Capabilitiy flags of the memory */
 
262
        u32 maximum_order_supported;  /**< log2 supported size */
 
263
        u32 identifier;               /**< Unique identifier, to be used in allocate calls */
 
264
        struct _mali_mem_info * next; /**< Next List Link */
 
265
} _mali_mem_info;
 
266
 
 
267
/** @brief Info about the whole Mali system.
 
268
 *
 
269
 * This Contains a linked list of the cores and memory banks available. Each
 
270
 * list pointer will remain inside the system_info buffer supplied in the
 
271
 * _mali_uk_get_system_info_s arguments to a _mali_ukk_get_system_info call.
 
272
 *
 
273
 * The has_mmu member must be inspected to ensure the correct group of
 
274
 * Memory function calls is obtained - that is, those for either Mali-MMU
 
275
 * or Mali-nonMMU. @see _mali_uk_memory
 
276
 */
 
277
typedef struct _mali_system_info
 
278
{
 
279
        _mali_core_info * core_info;  /**< List of _mali_core_info structures */
 
280
        _mali_mem_info * mem_info;    /**< List of _mali_mem_info structures */
 
281
        u32 has_mmu;                  /**< Non-zero if Mali-MMU present. Zero otherwise. */
 
282
        _mali_driver_mode drivermode; /**< Reserved. Must always be _MALI_DRIVER_MODE_NORMAL */
 
283
} _mali_system_info;
 
284
 
 
285
/** @brief Arguments to _mali_ukk_get_system_info()
 
286
 *
 
287
 * A buffer of the size returned by _mali_ukk_get_system_info_size() must be
 
288
 * allocated, and the pointer to this buffer must be written into the
 
289
 * system_info member. The buffer must be suitably aligned for storage of
 
290
 * the _mali_system_info structure - for example, one returned by
 
291
 * _mali_osk_malloc(), which will be suitably aligned for any structure.
 
292
 *
 
293
 * The ukk_private member must be set to zero by the user-side. Under an OS
 
294
 * implementation, the U/K interface must write in the user-side base address
 
295
 * into the ukk_private member, so that the common code in
 
296
 * _mali_ukk_get_system_info() can determine how to adjust the pointers such
 
297
 * that they are sensible from user space. Leaving ukk_private as NULL implies
 
298
 * that no pointer adjustment is necessary - which will be the case on a
 
299
 * bare-metal/RTOS system.
 
300
 *
 
301
 * @see _mali_system_info
 
302
 */
 
303
typedef struct
 
304
{
 
305
    void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
 
306
        u32 size;                               /**< [in] size of buffer provided to store system information data */
 
307
        _mali_system_info * system_info;        /**< [in,out] pointer to buffer to store system information data. No initialisation of buffer required on input. */
 
308
        u32 ukk_private;                        /**< [in] Kernel-side private word inserted by certain U/K interface implementations. Caller must set to Zero. */
 
309
} _mali_uk_get_system_info_s;
 
310
/** @} */ /* end group _mali_uk_getsysteminfo */
 
311
 
 
312
/** @} */ /* end group _mali_uk_core */
 
313
 
 
314
 
 
315
/** @defgroup _mali_uk_gp U/K Vertex Processor
 
316
 * @{ */
 
317
 
 
318
/** @defgroup _mali_uk_gp_suspend_response_s Vertex Processor Suspend Response
 
319
 * @{ */
 
320
 
 
321
/** @brief Arguments for _mali_ukk_gp_suspend_response()
 
322
 *
 
323
 * When _mali_wait_for_notification() receives notification that a
 
324
 * Vertex Processor job was suspended, you need to send a response to indicate
 
325
 * what needs to happen with this job. You can either abort or resume the job.
 
326
 *
 
327
 * - set @c code to indicate response code. This is either @c _MALIGP_JOB_ABORT or
 
328
 * @c _MALIGP_JOB_RESUME_WITH_NEW_HEAP to indicate you will provide a new heap
 
329
 * for the job that will resolve the out of memory condition for the job.
 
330
 * - copy the @c cookie value from the @c _mali_uk_gp_job_suspended_s notification;
 
331
 * this is an identifier for the suspended job
 
332
 * - set @c arguments[0] and @c arguments[1] to zero if you abort the job. If
 
333
 * you resume it, @c argument[0] should specify the Mali start address for the new
 
334
 * heap and @c argument[1] the Mali end address of the heap.
 
335
 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
 
336
 *
 
337
 */
 
338
typedef enum _maligp_job_suspended_response_code
 
339
{
 
340
        _MALIGP_JOB_ABORT,                  /**< Abort the Vertex Processor job */
 
341
        _MALIGP_JOB_RESUME_WITH_NEW_HEAP    /**< Resume the Vertex Processor job with a new heap */
 
342
} _maligp_job_suspended_response_code;
 
343
 
 
344
typedef struct
 
345
{
 
346
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
347
        u32 cookie;                     /**< [in] cookie from the _mali_uk_gp_job_suspended_s notification */
 
348
        _maligp_job_suspended_response_code code; /**< [in] abort or resume response code, see \ref _maligp_job_suspended_response_code */
 
349
        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 */
 
350
} _mali_uk_gp_suspend_response_s;
 
351
 
 
352
/** @} */ /* end group _mali_uk_gp_suspend_response_s */
 
353
 
 
354
/** @defgroup _mali_uk_gpstartjob_s Vertex Processor Start Job
 
355
 * @{ */
 
356
 
 
357
/** @brief Status indicating the result of starting a Vertex or Fragment processor job */
 
358
typedef enum
 
359
{
 
360
    _MALI_UK_START_JOB_STARTED,                         /**< Job started */
 
361
    _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE           /**< Job could not be started at this time. Try starting the job again */
 
362
} _mali_uk_start_job_status;
 
363
 
 
364
/** @brief Status indicating the result of the execution of a Vertex or Fragment processor job  */
 
365
 
 
366
typedef enum
 
367
{
 
368
        _MALI_UK_JOB_STATUS_END_SUCCESS         = 1<<(16+0),
 
369
        _MALI_UK_JOB_STATUS_END_OOM             = 1<<(16+1),
 
370
        _MALI_UK_JOB_STATUS_END_ABORT           = 1<<(16+2),
 
371
        _MALI_UK_JOB_STATUS_END_TIMEOUT_SW      = 1<<(16+3),
 
372
        _MALI_UK_JOB_STATUS_END_HANG            = 1<<(16+4),
 
373
        _MALI_UK_JOB_STATUS_END_SEG_FAULT       = 1<<(16+5),
 
374
        _MALI_UK_JOB_STATUS_END_ILLEGAL_JOB     = 1<<(16+6),
 
375
        _MALI_UK_JOB_STATUS_END_UNKNOWN_ERR     = 1<<(16+7),
 
376
        _MALI_UK_JOB_STATUS_END_SHUTDOWN        = 1<<(16+8),
 
377
        _MALI_UK_JOB_STATUS_END_SYSTEM_UNUSABLE = 1<<(16+9)
 
378
} _mali_uk_job_status;
 
379
 
 
380
#define MALIGP2_NUM_REGS_FRAME (6)
 
381
 
 
382
/** @brief Arguments for _mali_ukk_gp_start_job()
 
383
 *
 
384
 * To start a Vertex Processor job
 
385
 * - associate the request with a reference to a @c mali_gp_job_info by setting
 
386
 * user_job_ptr to the address of the @c mali_gp_job_info of the job.
 
387
 * - set @c priority to the priority of the @c mali_gp_job_info
 
388
 * - specify a timeout for the job by setting @c watchdog_msecs to the number of
 
389
 * milliseconds the job is allowed to run. Specifying a value of 0 selects the
 
390
 * default timeout in use by the device driver.
 
391
 * - copy the frame registers from the @c mali_gp_job_info into @c frame_registers.
 
392
 * - set the @c perf_counter_flag, @c perf_counter_src0 and @c perf_counter_src1 to zero
 
393
 * for a non-instrumented build. For an instrumented build you can use up
 
394
 * to two performance counters. Set the corresponding bit in @c perf_counter_flag
 
395
 * to enable them. @c perf_counter_src0 and @c perf_counter_src1 specify
 
396
 * the source of what needs to get counted (e.g. number of vertex loader
 
397
 * cache hits). For source id values, see ARM DDI0415A, Table 3-60.
 
398
 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
 
399
 *
 
400
 * When @c _mali_ukk_gp_start_job() returns @c _MALI_OSK_ERR_OK, status contains the
 
401
 * result of the request (see \ref _mali_uk_start_job_status). If the job could
 
402
 * not get started (@c _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE) it should be
 
403
 * tried again.
 
404
 *
 
405
 * After the job has started, @c _mali_wait_for_notification() will be notified
 
406
 * that the job finished or got suspended. It may get suspended due to
 
407
 * resource shortage. If it finished (see _mali_ukk_wait_for_notification())
 
408
 * the notification will contain a @c _mali_uk_gp_job_finished_s result. If
 
409
 * it got suspended the notification will contain a @c _mali_uk_gp_job_suspended_s
 
410
 * result.
 
411
 *
 
412
 * The @c _mali_uk_gp_job_finished_s contains the job status (see \ref _mali_uk_job_status),
 
413
 * the number of milliseconds the job took to render, and values of core registers
 
414
 * when the job finished (irq status, performance counters, renderer list
 
415
 * address). A job has finished succesfully when its status is
 
416
 * @c _MALI_UK_JOB_STATUS_FINISHED. If the hardware detected a timeout while rendering
 
417
 * the job, or software detected the job is taking more than watchdog_msecs to
 
418
 * complete, the status will indicate @c _MALI_UK_JOB_STATUS_HANG.
 
419
 * If the hardware detected a bus error while accessing memory associated with the
 
420
 * job, status will indicate @c _MALI_UK_JOB_STATUS_SEG_FAULT.
 
421
 * status will indicate @c _MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to
 
422
 * stop the job but the job didn't start on the hardware yet, e.g. when the
 
423
 * driver shutdown.
 
424
 *
 
425
 * In case the job got suspended, @c _mali_uk_gp_job_suspended_s contains
 
426
 * the @c user_job_ptr identifier used to start the job with, the @c reason
 
427
 * why the job stalled (see \ref _maligp_job_suspended_reason) and a @c cookie
 
428
 * to identify the core on which the job stalled.  This @c cookie will be needed
 
429
 * when responding to this nofication by means of _mali_ukk_gp_suspend_response().
 
430
 * (see _mali_ukk_gp_suspend_response()). The response is either to abort or
 
431
 * resume the job. If the job got suspended due to an out of memory condition
 
432
 * you may be able to resolve this by providing more memory and resuming the job.
 
433
 *
 
434
 */
 
435
typedef struct
 
436
{
 
437
    void *ctx;                          /**< [in,out] user-kernel context (trashed on output) */
 
438
    u32 user_job_ptr;                   /**< [in] identifier for the job in user space, a @c mali_gp_job_info* */
 
439
    u32 priority;                       /**< [in] job priority. A lower number means higher priority */
 
440
    u32 frame_registers[MALIGP2_NUM_REGS_FRAME]; /**< [in] core specific registers associated with this job */
 
441
    u32 perf_counter_flag;              /**< [in] bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */
 
442
    u32 perf_counter_src0;              /**< [in] source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */
 
443
    u32 perf_counter_src1;              /**< [in] source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */
 
444
        u32 frame_builder_id;               /**< [in] id of the originating frame builder */
 
445
        u32 flush_id;                       /**< [in] flush id within the originating frame builder */
 
446
} _mali_uk_gp_start_job_s;
 
447
 
 
448
#define _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE (1<<0) /**< Enable performance counter SRC0 for a job */
 
449
#define _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE (1<<1) /**< Enable performance counter SRC1 for a job */
 
450
 
 
451
/** @} */ /* end group _mali_uk_gpstartjob_s */
 
452
 
 
453
typedef struct
 
454
{
 
455
    u32 user_job_ptr;               /**< [out] identifier for the job in user space */
 
456
    _mali_uk_job_status status;     /**< [out] status of finished job */
 
457
    u32 heap_current_addr;          /**< [out] value of the GP PLB PL heap start address register */
 
458
    u32 perf_counter0;              /**< [out] value of perfomance counter 0 (see ARM DDI0415A) */
 
459
    u32 perf_counter1;              /**< [out] value of perfomance counter 1 (see ARM DDI0415A) */
 
460
} _mali_uk_gp_job_finished_s;
 
461
 
 
462
typedef enum _maligp_job_suspended_reason
 
463
{
 
464
        _MALIGP_JOB_SUSPENDED_OUT_OF_MEMORY  /**< Polygon list builder unit (PLBU) has run out of memory */
 
465
} _maligp_job_suspended_reason;
 
466
 
 
467
typedef struct
 
468
{
 
469
        u32 user_job_ptr;                    /**< [out] identifier for the job in user space */
 
470
        _maligp_job_suspended_reason reason; /**< [out] reason why the job stalled */
 
471
        u32 cookie;                          /**< [out] identifier for the core in kernel space on which the job stalled */
 
472
} _mali_uk_gp_job_suspended_s;
 
473
 
 
474
/** @} */ /* end group _mali_uk_gp */
 
475
 
 
476
 
 
477
/** @defgroup _mali_uk_pp U/K Fragment Processor
 
478
 * @{ */
 
479
 
 
480
#define _MALI_PP_MAX_SUB_JOBS 8
 
481
 
 
482
#define _MALI_PP_MAX_FRAME_REGISTERS ((0x058/4)+1)
 
483
 
 
484
#define _MALI_PP_MAX_WB_REGISTERS ((0x02C/4)+1)
 
485
 
 
486
/** @defgroup _mali_uk_ppstartjob_s Fragment Processor Start Job
 
487
 * @{ */
 
488
 
 
489
/** @brief Arguments for _mali_ukk_pp_start_job()
 
490
 *
 
491
 * To start a Fragment Processor job
 
492
 * - associate the request with a reference to a mali_pp_job by setting
 
493
 * @c user_job_ptr to the address of the @c mali_pp_job of the job.
 
494
 * - set @c priority to the priority of the mali_pp_job
 
495
 * - specify a timeout for the job by setting @c watchdog_msecs to the number of
 
496
 * milliseconds the job is allowed to run. Specifying a value of 0 selects the
 
497
 * default timeout in use by the device driver.
 
498
 * - copy the frame registers from the @c mali_pp_job into @c frame_registers.
 
499
 * For MALI200 you also need to copy the write back 0,1 and 2 registers.
 
500
 * - set the @c perf_counter_flag, @c perf_counter_src0 and @c perf_counter_src1 to zero
 
501
 * for a non-instrumented build. For an instrumented build you can use up
 
502
 * to two performance counters. Set the corresponding bit in @c perf_counter_flag
 
503
 * to enable them. @c perf_counter_src0 and @c perf_counter_src1 specify
 
504
 * the source of what needs to get counted (e.g. number of vertex loader
 
505
 * cache hits). For source id values, see ARM DDI0415A, Table 3-60.
 
506
 * - pass in the user-kernel context in @c ctx that was returned from _mali_ukk_open()
 
507
 *
 
508
 * When _mali_ukk_pp_start_job() returns @c _MALI_OSK_ERR_OK, @c status contains the
 
509
 * result of the request (see \ref _mali_uk_start_job_status). If the job could
 
510
 * not get started (@c _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE) it should be
 
511
 * tried again.
 
512
 *
 
513
 * After the job has started, _mali_wait_for_notification() will be notified
 
514
 * when the job finished. The notification will contain a
 
515
 * @c _mali_uk_pp_job_finished_s result. It contains the @c user_job_ptr
 
516
 * identifier used to start the job with, the job @c status (see \ref _mali_uk_job_status),
 
517
 * the number of milliseconds the job took to render, and values of core registers
 
518
 * when the job finished (irq status, performance counters, renderer list
 
519
 * address). A job has finished succesfully when its status is
 
520
 * @c _MALI_UK_JOB_STATUS_FINISHED. If the hardware detected a timeout while rendering
 
521
 * the job, or software detected the job is taking more than @c watchdog_msecs to
 
522
 * complete, the status will indicate @c _MALI_UK_JOB_STATUS_HANG.
 
523
 * If the hardware detected a bus error while accessing memory associated with the
 
524
 * job, status will indicate @c _MALI_UK_JOB_STATUS_SEG_FAULT.
 
525
 * status will indicate @c _MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to
 
526
 * stop the job but the job didn't start on the hardware yet, e.g. when the
 
527
 * driver shutdown.
 
528
 *
 
529
 */
 
530
typedef struct
 
531
{
 
532
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
533
    u32 user_job_ptr;               /**< [in] identifier for the job in user space */
 
534
    u32 priority;                   /**< [in] job priority. A lower number means higher priority */
 
535
    u32 frame_registers[_MALI_PP_MAX_FRAME_REGISTERS];         /**< [in] core specific registers associated with first sub job, see ARM DDI0415A */
 
536
    u32 frame_registers_addr_frame[_MALI_PP_MAX_SUB_JOBS - 1]; /**< [in] ADDR_FRAME registers for sub job 1-7 */
 
537
    u32 frame_registers_addr_stack[_MALI_PP_MAX_SUB_JOBS - 1]; /**< [in] ADDR_STACK registers for sub job 1-7 */
 
538
    u32 wb0_registers[_MALI_PP_MAX_WB_REGISTERS];
 
539
    u32 wb1_registers[_MALI_PP_MAX_WB_REGISTERS];
 
540
    u32 wb2_registers[_MALI_PP_MAX_WB_REGISTERS];
 
541
        u32 num_cores;                      /**< [in] Number of cores to set up (valid range: 1-4) */
 
542
    u32 perf_counter_flag;              /**< [in] bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */
 
543
    u32 perf_counter_src0;              /**< [in] source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */
 
544
    u32 perf_counter_src1;              /**< [in] source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */
 
545
        u32 frame_builder_id;               /**< [in] id of the originating frame builder */
 
546
        u32 flush_id;                       /**< [in] flush id within the originating frame builder */
 
547
} _mali_uk_pp_start_job_s;
 
548
/** @} */ /* end group _mali_uk_ppstartjob_s */
 
549
 
 
550
typedef struct
 
551
{
 
552
    u32 user_job_ptr;                          /**< [out] identifier for the job in user space */
 
553
    _mali_uk_job_status status;                /**< [out] status of finished job */
 
554
    u32 perf_counter0[_MALI_PP_MAX_SUB_JOBS];  /**< [out] value of perfomance counter 0 (see ARM DDI0415A), one for each sub job */
 
555
    u32 perf_counter1[_MALI_PP_MAX_SUB_JOBS];  /**< [out] value of perfomance counter 1 (see ARM DDI0415A), one for each sub job */
 
556
} _mali_uk_pp_job_finished_s;
 
557
 
 
558
/**
 
559
 * Flags to indicate write-back units
 
560
 */
 
561
typedef enum
 
562
{
 
563
        _MALI_UK_PP_JOB_WB0 = 1,
 
564
        _MALI_UK_PP_JOB_WB1 = 2,
 
565
        _MALI_UK_PP_JOB_WB2 = 4,
 
566
} _mali_uk_pp_job_wbx_flag;
 
567
 
 
568
typedef struct
 
569
{
 
570
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
571
    u32 fb_id;                      /**< [in] Frame builder ID of job to disable WB units for */
 
572
    u32 flush_id;                   /**< [in] Flush ID of job to disable WB units for */
 
573
    _mali_uk_pp_job_wbx_flag wbx;   /**< [in] write-back units to disable */
 
574
} _mali_uk_pp_disable_wb_s;
 
575
 
 
576
 
 
577
/** @} */ /* end group _mali_uk_pp */
 
578
 
 
579
 
 
580
/** @addtogroup _mali_uk_core U/K Core
 
581
 * @{ */
 
582
 
 
583
/** @defgroup _mali_uk_waitfornotification_s Wait For Notification
 
584
 * @{ */
 
585
 
 
586
/** @brief Notification type encodings
 
587
 *
 
588
 * Each Notification type is an ordered pair of (subsystem,id), and is unique.
 
589
 *
 
590
 * The encoding of subsystem,id into a 32-bit word is:
 
591
 * encoding = (( subsystem << _MALI_NOTIFICATION_SUBSYSTEM_SHIFT ) & _MALI_NOTIFICATION_SUBSYSTEM_MASK)
 
592
 *            | (( id <<  _MALI_NOTIFICATION_ID_SHIFT ) & _MALI_NOTIFICATION_ID_MASK)
 
593
 *
 
594
 * @see _mali_uk_wait_for_notification_s
 
595
 */
 
596
typedef enum
 
597
{
 
598
        /** core notifications */
 
599
 
 
600
        _MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS =  (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x20,
 
601
        _MALI_NOTIFICATION_APPLICATION_QUIT =           (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x40,
 
602
        _MALI_NOTIFICATION_SETTINGS_CHANGED =           (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x80,
 
603
 
 
604
        /** Fragment Processor notifications */
 
605
 
 
606
        _MALI_NOTIFICATION_PP_FINISHED =                (_MALI_UK_PP_SUBSYSTEM << 16) | 0x10,
 
607
 
 
608
        /** Vertex Processor notifications */
 
609
 
 
610
        _MALI_NOTIFICATION_GP_FINISHED =                (_MALI_UK_GP_SUBSYSTEM << 16) | 0x10,
 
611
        _MALI_NOTIFICATION_GP_STALLED =                 (_MALI_UK_GP_SUBSYSTEM << 16) | 0x20,
 
612
 
 
613
} _mali_uk_notification_type;
 
614
 
 
615
/** to assist in splitting up 32-bit notification value in subsystem and id value */
 
616
#define _MALI_NOTIFICATION_SUBSYSTEM_MASK 0xFFFF0000
 
617
#define _MALI_NOTIFICATION_SUBSYSTEM_SHIFT 16
 
618
#define _MALI_NOTIFICATION_ID_MASK 0x0000FFFF
 
619
#define _MALI_NOTIFICATION_ID_SHIFT 0
 
620
 
 
621
 
 
622
/** @brief Enumeration of possible settings which match mali_setting_t in user space
 
623
 *
 
624
 *
 
625
 */
 
626
typedef enum
 
627
{
 
628
        _MALI_UK_USER_SETTING_SW_EVENTS_ENABLE = 0,
 
629
        _MALI_UK_USER_SETTING_COLORBUFFER_CAPTURE_ENABLED,
 
630
        _MALI_UK_USER_SETTING_DEPTHBUFFER_CAPTURE_ENABLED,
 
631
        _MALI_UK_USER_SETTING_STENCILBUFFER_CAPTURE_ENABLED,
 
632
        _MALI_UK_USER_SETTING_PER_TILE_COUNTERS_CAPTURE_ENABLED,
 
633
        _MALI_UK_USER_SETTING_BUFFER_CAPTURE_COMPOSITOR,
 
634
        _MALI_UK_USER_SETTING_BUFFER_CAPTURE_WINDOW,
 
635
        _MALI_UK_USER_SETTING_BUFFER_CAPTURE_OTHER,
 
636
        _MALI_UK_USER_SETTING_BUFFER_CAPTURE_N_FRAMES,
 
637
        _MALI_UK_USER_SETTING_BUFFER_CAPTURE_RESIZE_FACTOR,
 
638
        _MALI_UK_USER_SETTING_SW_COUNTER_ENABLED,
 
639
        _MALI_UK_USER_SETTING_MAX,
 
640
} _mali_uk_user_setting_t;
 
641
 
 
642
/* See mali_user_settings_db.c */
 
643
extern const char *_mali_uk_user_setting_descriptions[];
 
644
#define _MALI_UK_USER_SETTING_DESCRIPTIONS \
 
645
{                                           \
 
646
        "sw_events_enable",                 \
 
647
        "colorbuffer_capture_enable",       \
 
648
        "depthbuffer_capture_enable",       \
 
649
        "stencilbuffer_capture_enable",     \
 
650
        "per_tile_counters_enable",         \
 
651
        "buffer_capture_compositor",        \
 
652
        "buffer_capture_window",            \
 
653
        "buffer_capture_other",             \
 
654
        "buffer_capture_n_frames",          \
 
655
        "buffer_capture_resize_factor",     \
 
656
        "sw_counters_enable",               \
 
657
};
 
658
 
 
659
/** @brief struct to hold the value to a particular setting as seen in the kernel space
 
660
 */
 
661
typedef struct
 
662
{
 
663
        _mali_uk_user_setting_t setting;
 
664
        u32 value;
 
665
} _mali_uk_settings_changed_s;
 
666
 
 
667
/** @brief Arguments for _mali_ukk_wait_for_notification()
 
668
 *
 
669
 * On successful return from _mali_ukk_wait_for_notification(), the members of
 
670
 * this structure will indicate the reason for notification.
 
671
 *
 
672
 * Specifically, the source of the notification can be identified by the
 
673
 * subsystem and id fields of the mali_uk_notification_type in the code.type
 
674
 * member. The type member is encoded in a way to divide up the types into a
 
675
 * subsystem field, and a per-subsystem ID field. See
 
676
 * _mali_uk_notification_type for more information.
 
677
 *
 
678
 * Interpreting the data union member depends on the notification type:
 
679
 *
 
680
 * - type == _MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS
 
681
 *     - The kernel side is shutting down. No further
 
682
 * _mali_uk_wait_for_notification() calls should be made.
 
683
 *     - In this case, the value of the data union member is undefined.
 
684
 *     - This is used to indicate to the user space client that it should close
 
685
 * the connection to the Mali Device Driver.
 
686
 * - type == _MALI_NOTIFICATION_PP_FINISHED
 
687
 *    - The notification data is of type _mali_uk_pp_job_finished_s. It contains the user_job_ptr
 
688
 * identifier used to start the job with, the job status, the number of milliseconds the job took to render,
 
689
 * and values of core registers when the job finished (irq status, performance counters, renderer list
 
690
 * address).
 
691
 *    - A job has finished succesfully when its status member is _MALI_UK_JOB_STATUS_FINISHED.
 
692
 *    - If the hardware detected a timeout while rendering the job, or software detected the job is
 
693
 * taking more than watchdog_msecs (see _mali_ukk_pp_start_job()) to complete, the status member will
 
694
 * indicate _MALI_UK_JOB_STATUS_HANG.
 
695
 *    - If the hardware detected a bus error while accessing memory associated with the job, status will
 
696
 * indicate _MALI_UK_JOB_STATUS_SEG_FAULT.
 
697
 *    - Status will indicate MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to stop the job but the job
 
698
 * didn't start the hardware yet, e.g. when the driver closes.
 
699
 * - type == _MALI_NOTIFICATION_GP_FINISHED
 
700
 *     - The notification data is of type _mali_uk_gp_job_finished_s. The notification is similar to that of
 
701
 * type == _MALI_NOTIFICATION_PP_FINISHED, except that several other GP core register values are returned.
 
702
 * The status values have the same meaning for type == _MALI_NOTIFICATION_PP_FINISHED.
 
703
 * - type == _MALI_NOTIFICATION_GP_STALLED
 
704
 *     - The nofication data is of type _mali_uk_gp_job_suspended_s. It contains the user_job_ptr
 
705
 * identifier used to start the job with, the reason why the job stalled and a cookie to identify the core on
 
706
 * which the job stalled.
 
707
 *     - The reason member of gp_job_suspended is set to _MALIGP_JOB_SUSPENDED_OUT_OF_MEMORY
 
708
 * when the polygon list builder unit has run out of memory.
 
709
 */
 
710
typedef struct
 
711
{
 
712
        void *ctx;                       /**< [in,out] user-kernel context (trashed on output) */
 
713
        _mali_uk_notification_type type; /**< [out] Type of notification available */
 
714
        union
 
715
        {
 
716
                _mali_uk_gp_job_suspended_s gp_job_suspended;/**< [out] Notification data for _MALI_NOTIFICATION_GP_STALLED notification type */
 
717
                _mali_uk_gp_job_finished_s  gp_job_finished; /**< [out] Notification data for _MALI_NOTIFICATION_GP_FINISHED notification type */
 
718
                _mali_uk_pp_job_finished_s  pp_job_finished; /**< [out] Notification data for _MALI_NOTIFICATION_PP_FINISHED notification type */
 
719
                _mali_uk_settings_changed_s setting_changed;/**< [out] Notification data for _MALI_NOTIFICAATION_SETTINGS_CHANGED notification type */
 
720
        } data;
 
721
} _mali_uk_wait_for_notification_s;
 
722
 
 
723
/** @brief Arguments for _mali_ukk_post_notification()
 
724
 *
 
725
 * Posts the specified notification to the notification queue for this application.
 
726
 * This is used to send a quit message to the callback thread.
 
727
 */
 
728
typedef struct
 
729
{
 
730
    void *ctx;                       /**< [in,out] user-kernel context (trashed on output) */
 
731
        _mali_uk_notification_type type; /**< [in] Type of notification to post */
 
732
} _mali_uk_post_notification_s;
 
733
 
 
734
/** @} */ /* end group _mali_uk_waitfornotification_s */
 
735
 
 
736
/** @defgroup _mali_uk_getapiversion_s Get API Version
 
737
 * @{ */
 
738
 
 
739
/** helpers for Device Driver API version handling */
 
740
 
 
741
/** @brief Encode a version ID from a 16-bit input
 
742
 *
 
743
 * @note the input is assumed to be 16 bits. It must not exceed 16 bits. */
 
744
#define _MAKE_VERSION_ID(x) (((x) << 16UL) | (x))
 
745
 
 
746
/** @brief Check whether a 32-bit value is likely to be Device Driver API
 
747
 * version ID. */
 
748
#define _IS_VERSION_ID(x) (((x) & 0xFFFF) == (((x) >> 16UL) & 0xFFFF))
 
749
 
 
750
/** @brief Decode a 16-bit version number from a 32-bit Device Driver API version
 
751
 * ID */
 
752
#define _GET_VERSION(x) (((x) >> 16UL) & 0xFFFF)
 
753
 
 
754
/** @brief Determine whether two 32-bit encoded version IDs match */
 
755
#define _IS_API_MATCH(x, y) (IS_VERSION_ID((x)) && IS_VERSION_ID((y)) && (GET_VERSION((x)) == GET_VERSION((y))))
 
756
 
 
757
/**
 
758
 * API version define.
 
759
 * Indicates the version of the kernel API
 
760
 * The version is a 16bit integer incremented on each API change.
 
761
 * The 16bit integer is stored twice in a 32bit integer
 
762
 * For example, for version 1 the value would be 0x00010001
 
763
 */
 
764
#define _MALI_API_VERSION 14
 
765
#define _MALI_UK_API_VERSION _MAKE_VERSION_ID(_MALI_API_VERSION)
 
766
 
 
767
/**
 
768
 * The API version is a 16-bit integer stored in both the lower and upper 16-bits
 
769
 * of a 32-bit value. The 16-bit API version value is incremented on each API
 
770
 * change. Version 1 would be 0x00010001. Used in _mali_uk_get_api_version_s.
 
771
 */
 
772
typedef u32 _mali_uk_api_version;
 
773
 
 
774
/** @brief Arguments for _mali_uk_get_api_version()
 
775
 *
 
776
 * The user-side interface version must be written into the version member,
 
777
 * encoded using _MAKE_VERSION_ID(). It will be compared to the API version of
 
778
 * the kernel-side interface.
 
779
 *
 
780
 * On successful return, the version member will be the API version of the
 
781
 * kernel-side interface. _MALI_UK_API_VERSION macro defines the current version
 
782
 * of the API.
 
783
 *
 
784
 * The compatible member must be checked to see if the version of the user-side
 
785
 * interface is compatible with the kernel-side interface, since future versions
 
786
 * of the interface may be backwards compatible.
 
787
 */
 
788
typedef struct
 
789
{
 
790
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
791
        _mali_uk_api_version version;   /**< [in,out] API version of user-side interface. */
 
792
        int compatible;                 /**< [out] @c 1 when @version is compatible, @c 0 otherwise */
 
793
} _mali_uk_get_api_version_s;
 
794
/** @} */ /* end group _mali_uk_getapiversion_s */
 
795
 
 
796
/** @defgroup _mali_uk_get_user_settings_s Get user space settings */
 
797
 
 
798
/** @brief struct to keep the matching values of the user space settings within certain context
 
799
 *
 
800
 * Each member of the settings array corresponds to a matching setting in the user space and its value is the value
 
801
 * of that particular setting.
 
802
 *
 
803
 * All settings are given reference to the context pointed to by the ctx pointer.
 
804
 *
 
805
 */
 
806
typedef struct
 
807
{
 
808
        void *ctx;                       /**< [in,out] user-kernel context (trashed on output) */
 
809
        u32 settings[_MALI_UK_USER_SETTING_MAX]; /**< [out] The values for all settings */
 
810
} _mali_uk_get_user_settings_s;
 
811
 
 
812
/** @brief struct to hold the value of a particular setting from the user space within a given context
 
813
 */
 
814
typedef struct
 
815
{
 
816
        void *ctx;                       /**< [in,out] user-kernel context (trashed on output) */
 
817
        _mali_uk_user_setting_t setting; /**< [in] setting to get */
 
818
        u32 value;                       /**< [out] value of setting */
 
819
} _mali_uk_get_user_setting_s;
 
820
 
 
821
/** @} */ /* end group _mali_uk_core */
 
822
 
 
823
 
 
824
/** @defgroup _mali_uk_memory U/K Memory
 
825
 * @{ */
 
826
 
 
827
/** @brief Arguments for _mali_ukk_init_mem(). */
 
828
typedef struct
 
829
{
 
830
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
831
        u32 mali_address_base;          /**< [out] start of MALI address space */
 
832
        u32 memory_size;                /**< [out] total MALI address space available */
 
833
} _mali_uk_init_mem_s;
 
834
 
 
835
/** @brief Arguments for _mali_ukk_term_mem(). */
 
836
typedef struct
 
837
{
 
838
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
839
} _mali_uk_term_mem_s;
 
840
 
 
841
/** @note Mali-MMU only */
 
842
typedef struct
 
843
{
 
844
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
845
        u32 phys_addr;                  /**< [in] physical address */
 
846
        u32 size;                       /**< [in] size */
 
847
        u32 mali_address;               /**< [in] mali address to map the physical memory to */
 
848
        u32 rights;                     /**< [in] rights necessary for accessing memory */
 
849
        u32 flags;                      /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */
 
850
        u32 cookie;                     /**< [out] identifier for mapped memory object in kernel space  */
 
851
} _mali_uk_map_external_mem_s;
 
852
 
 
853
/** Flag for _mali_uk_map_external_mem_s and _mali_uk_attach_ump_mem_s */
 
854
#define _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE (1<<0)
 
855
 
 
856
/** @note Mali-MMU only */
 
857
typedef struct
 
858
{
 
859
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
860
        u32 cookie;                     /**< [out] identifier for mapped memory object in kernel space  */
 
861
} _mali_uk_unmap_external_mem_s;
 
862
 
 
863
/** @note This is identical to _mali_uk_map_external_mem_s above, however phys_addr is replaced by secure_id */
 
864
typedef struct
 
865
{
 
866
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
867
        u32 secure_id;                  /**< [in] secure id */
 
868
        u32 size;                       /**< [in] size */
 
869
        u32 mali_address;               /**< [in] mali address to map the physical memory to */
 
870
        u32 rights;                     /**< [in] rights necessary for accessing memory */
 
871
        u32 flags;                      /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */
 
872
        u32 cookie;                     /**< [out] identifier for mapped memory object in kernel space  */
 
873
} _mali_uk_attach_ump_mem_s;
 
874
 
 
875
/** @note Mali-MMU only; will be supported in future version */
 
876
typedef struct
 
877
{
 
878
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
879
        u32 cookie;                     /**< [in] identifier for mapped memory object in kernel space  */
 
880
} _mali_uk_release_ump_mem_s;
 
881
 
 
882
/** @brief Arguments for _mali_ukk_va_to_mali_pa()
 
883
 *
 
884
 * if size is zero or not a multiple of the system's page size, it will be
 
885
 * rounded up to the next multiple of the page size. This will occur before
 
886
 * any other use of the size parameter.
 
887
 *
 
888
 * if va is not PAGE_SIZE aligned, it will be rounded down to the next page
 
889
 * boundary.
 
890
 *
 
891
 * The range (va) to ((u32)va)+(size-1) inclusive will be checked for physical
 
892
 * contiguity.
 
893
 *
 
894
 * The implementor will check that the entire physical range is allowed to be mapped
 
895
 * into user-space.
 
896
 *
 
897
 * Failure will occur if either of the above are not satisfied.
 
898
 *
 
899
 * Otherwise, the physical base address of the range is returned through pa,
 
900
 * va is updated to be page aligned, and size is updated to be a non-zero
 
901
 * multiple of the system's pagesize.
 
902
 */
 
903
typedef struct
 
904
{
 
905
        void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
906
        void *va;                       /**< [in,out] Virtual address of the start of the range */
 
907
        u32 pa;                         /**< [out] Physical base address of the range */
 
908
        u32 size;                       /**< [in,out] Size of the range, in bytes. */
 
909
} _mali_uk_va_to_mali_pa_s;
 
910
 
 
911
 
 
912
typedef struct
 
913
{
 
914
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
915
        u32 size;                       /**< [out] size of MMU page table information (registers + page tables) */
 
916
} _mali_uk_query_mmu_page_table_dump_size_s;
 
917
 
 
918
typedef struct
 
919
{
 
920
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
921
        u32 size;                       /**< [in] size of buffer to receive mmu page table information */
 
922
    void *buffer;                   /**< [in,out] buffer to receive mmu page table information */
 
923
    u32 register_writes_size;       /**< [out] size of MMU register dump */
 
924
        u32 *register_writes;           /**< [out] pointer within buffer where MMU register dump is stored */
 
925
        u32 page_table_dump_size;       /**< [out] size of MMU page table dump */
 
926
        u32 *page_table_dump;           /**< [out] pointer within buffer where MMU page table dump is stored */
 
927
} _mali_uk_dump_mmu_page_table_s;
 
928
 
 
929
/** @} */ /* end group _mali_uk_memory */
 
930
 
 
931
 
 
932
/** @addtogroup _mali_uk_pp U/K Fragment Processor
 
933
 * @{ */
 
934
 
 
935
/** @brief Arguments for _mali_ukk_get_pp_number_of_cores()
 
936
 *
 
937
 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
 
938
 * - Upon successful return from _mali_ukk_get_pp_number_of_cores(), @c number_of_cores
 
939
 * will contain the number of Fragment Processor cores in the system.
 
940
 */
 
941
typedef struct
 
942
{
 
943
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
944
    u32 number_of_cores;            /**< [out] number of Fragment Processor cores in the system */
 
945
} _mali_uk_get_pp_number_of_cores_s;
 
946
 
 
947
/** @brief Arguments for _mali_ukk_get_pp_core_version()
 
948
 *
 
949
 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
 
950
 * - Upon successful return from _mali_ukk_get_pp_core_version(), @c version contains
 
951
 * the version that all Fragment Processor cores are compatible with.
 
952
 */
 
953
typedef struct
 
954
{
 
955
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
956
    _mali_core_version version;     /**< [out] version returned from core, see \ref _mali_core_version  */
 
957
} _mali_uk_get_pp_core_version_s;
 
958
 
 
959
/** @} */ /* end group _mali_uk_pp */
 
960
 
 
961
 
 
962
/** @addtogroup _mali_uk_gp U/K Vertex Processor
 
963
 * @{ */
 
964
 
 
965
/** @brief Arguments for _mali_ukk_get_gp_number_of_cores()
 
966
 *
 
967
 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
 
968
 * - Upon successful return from _mali_ukk_get_gp_number_of_cores(), @c number_of_cores
 
969
 * will contain the number of Vertex Processor cores in the system.
 
970
 */
 
971
typedef struct
 
972
{
 
973
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
974
    u32 number_of_cores;            /**< [out] number of Vertex Processor cores in the system */
 
975
} _mali_uk_get_gp_number_of_cores_s;
 
976
 
 
977
/** @brief Arguments for _mali_ukk_get_gp_core_version()
 
978
 *
 
979
 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
 
980
 * - Upon successful return from _mali_ukk_get_gp_core_version(), @c version contains
 
981
 * the version that all Vertex Processor cores are compatible with.
 
982
 */
 
983
typedef struct
 
984
{
 
985
    void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
986
    _mali_core_version version;     /**< [out] version returned from core, see \ref _mali_core_version */
 
987
} _mali_uk_get_gp_core_version_s;
 
988
 
 
989
typedef struct
 
990
{
 
991
        void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
992
        u32 limit;                      /**< [in,out] The desired limit for number of events to record on input, actual limit on output */
 
993
} _mali_uk_profiling_start_s;
 
994
 
 
995
typedef struct
 
996
{
 
997
        void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
998
        u32 event_id;                   /**< [in] event id to register (see  enum mali_profiling_events for values) */
 
999
        u32 data[5];                    /**< [in] event specific data */
 
1000
} _mali_uk_profiling_add_event_s;
 
1001
 
 
1002
typedef struct
 
1003
{
 
1004
        void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
1005
        u32 count;                      /**< [out] The number of events sampled */
 
1006
} _mali_uk_profiling_stop_s;
 
1007
 
 
1008
typedef struct
 
1009
{
 
1010
        void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
1011
        u32 index;                      /**< [in] which index to get (starting at zero) */
 
1012
        u64 timestamp;                  /**< [out] timestamp of event */
 
1013
        u32 event_id;                   /**< [out] event id of event (see  enum mali_profiling_events for values) */
 
1014
        u32 data[5];                    /**< [out] event specific data */
 
1015
} _mali_uk_profiling_get_event_s;
 
1016
 
 
1017
typedef struct
 
1018
{
 
1019
        void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
1020
} _mali_uk_profiling_clear_s;
 
1021
 
 
1022
/** @} */ /* end group _mali_uk_gp */
 
1023
 
 
1024
 
 
1025
/** @addtogroup _mali_uk_memory U/K Memory
 
1026
 * @{ */
 
1027
 
 
1028
/** @brief Arguments to _mali_ukk_mem_mmap()
 
1029
 *
 
1030
 * Use of the phys_addr member depends on whether the driver is compiled for
 
1031
 * Mali-MMU or nonMMU:
 
1032
 * - in the nonMMU case, this is the physical address of the memory as seen by
 
1033
 * the CPU (which may be a constant offset from that used by Mali)
 
1034
 * - in the MMU case, this is the Mali Virtual base address of the memory to
 
1035
 * allocate, and the particular physical pages used to back the memory are
 
1036
 * entirely determined by _mali_ukk_mem_mmap(). The details of the physical pages
 
1037
 * are not reported to user-space for security reasons.
 
1038
 *
 
1039
 * The cookie member must be stored for use later when freeing the memory by
 
1040
 * calling _mali_ukk_mem_munmap(). In the Mali-MMU case, the cookie is secure.
 
1041
 *
 
1042
 * The ukk_private word must be set to zero when calling from user-space. On
 
1043
 * Kernel-side, the  OS implementation of the U/K interface can use it to
 
1044
 * communicate data to the OS implementation of the OSK layer. In particular,
 
1045
 * _mali_ukk_get_big_block() directly calls _mali_ukk_mem_mmap directly, and
 
1046
 * will communicate its own ukk_private word through the ukk_private member
 
1047
 * here. The common code itself will not inspect or modify the ukk_private
 
1048
 * word, and so it may be safely used for whatever purposes necessary to
 
1049
 * integrate Mali Memory handling into the OS.
 
1050
 *
 
1051
 * The uku_private member is currently reserved for use by the user-side
 
1052
 * implementation of the U/K interface. Its value must be zero.
 
1053
 */
 
1054
typedef struct
 
1055
{
 
1056
        void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
1057
        void *mapping;                  /**< [out] Returns user-space virtual address for the mapping */
 
1058
        u32 size;                       /**< [in] Size of the requested mapping */
 
1059
        u32 phys_addr;                  /**< [in] Physical address - could be offset, depending on caller+callee convention */
 
1060
        u32 cookie;                     /**< [out] Returns a cookie for use in munmap calls */
 
1061
        void *uku_private;              /**< [in] User-side Private word used by U/K interface */
 
1062
        void *ukk_private;              /**< [in] Kernel-side Private word used by U/K interface */
 
1063
} _mali_uk_mem_mmap_s;
 
1064
 
 
1065
/** @brief Arguments to _mali_ukk_mem_munmap()
 
1066
 *
 
1067
 * The cookie and mapping members must be that returned from the same previous
 
1068
 * call to _mali_ukk_mem_mmap(). The size member must correspond to cookie
 
1069
 * and mapping - that is, it must be the value originally supplied to a call to
 
1070
 * _mali_ukk_mem_mmap that returned the values of mapping and cookie.
 
1071
 *
 
1072
 * An error will be returned if an attempt is made to unmap only part of the
 
1073
 * originally obtained range, or to unmap more than was originally obtained.
 
1074
 */
 
1075
typedef struct
 
1076
{
 
1077
        void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
1078
        void *mapping;                  /**< [in] The mapping returned from mmap call */
 
1079
        u32 size;                       /**< [in] The size passed to mmap call */
 
1080
        u32 cookie;                     /**< [in] Cookie from mmap call */
 
1081
} _mali_uk_mem_munmap_s;
 
1082
/** @} */ /* end group _mali_uk_memory */
 
1083
 
 
1084
/** @defgroup _mali_uk_vsync U/K VSYNC Wait Reporting Module
 
1085
 * @{ */
 
1086
 
 
1087
/** @brief VSYNC events
 
1088
 *
 
1089
 * These events are reported when DDK starts to wait for vsync and when the
 
1090
 * vsync has occured and the DDK can continue on the next frame.
 
1091
 */
 
1092
typedef enum _mali_uk_vsync_event
 
1093
{
 
1094
        _MALI_UK_VSYNC_EVENT_BEGIN_WAIT = 0,
 
1095
        _MALI_UK_VSYNC_EVENT_END_WAIT
 
1096
} _mali_uk_vsync_event;
 
1097
 
 
1098
/** @brief Arguments to _mali_ukk_vsync_event()
 
1099
 *
 
1100
 */
 
1101
typedef struct
 
1102
{
 
1103
        void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
1104
        _mali_uk_vsync_event event;     /**< [in] VSYNCH event type */
 
1105
} _mali_uk_vsync_event_report_s;
 
1106
 
 
1107
/** @} */ /* end group _mali_uk_vsync */
 
1108
 
 
1109
/** @defgroup _mali_uk_sw_counters_report U/K Software Counter Reporting
 
1110
 * @{ */
 
1111
 
 
1112
/** @brief Software counter values
 
1113
 *
 
1114
 * Values recorded for each of the software counters during a single renderpass.
 
1115
 */
 
1116
typedef struct
 
1117
{
 
1118
        void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
 
1119
        u32* counters;                  /**< [in] The array of counter values */
 
1120
        u32  num_counters;              /**< [in] The number of elements in counters array */
 
1121
} _mali_uk_sw_counters_report_s;
 
1122
 
 
1123
/** @} */ /* end group _mali_uk_sw_counters_report */
 
1124
 
 
1125
/** @} */ /* end group u_k_api */
 
1126
 
 
1127
/** @} */ /* end group uddapi */
 
1128
 
 
1129
#ifdef __cplusplus
 
1130
}
 
1131
#endif
 
1132
 
 
1133
#endif /* __MALI_UTGARD_UK_TYPES_H__ */