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

« back to all changes in this revision

Viewing changes to driver/src/devicedrv/mali/common/mali_uk_types.h

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