2 * Copyright (C) 2010 ARM Limited. All rights reserved.
4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
7 * A copy of the licence is included with the program, and can also be obtained from Free Software
8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
13 * Defines the kernel-side interface of the user-kernel interface
16 #ifndef __MALI_UKK_H__
17 #define __MALI_UKK_H__
20 #include "mali_uk_types.h"
28 * @addtogroup uddapi Unified Device Driver (UDD) APIs
34 * @addtogroup u_k_api UDD User/Kernel Interface (U/K) APIs
36 * - The _mali_uk functions are an abstraction of the interface to the device
37 * driver. On certain OSs, this would be implemented via the IOCTL interface.
38 * On other OSs, it could be via extension of some Device Driver Class, or
39 * direct function call for Bare metal/RTOSs.
40 * - It is important to note that:
41 * - The Device Driver has implemented the _mali_ukk set of functions
42 * - The Base Driver calls the corresponding set of _mali_uku functions.
43 * - What requires porting is solely the calling mechanism from User-side to
44 * Kernel-side, and propagating back the results.
45 * - Each U/K function is associated with a (group, number) pair from
46 * \ref _mali_uk_functions to make it possible for a common function in the
47 * Base Driver and Device Driver to route User/Kernel calls from/to the
48 * correct _mali_uk function. For example, in an IOCTL system, the IOCTL number
49 * would be formed based on the group and number assigned to the _mali_uk
50 * function, as listed in \ref _mali_uk_functions. On the user-side, each
51 * _mali_uku function would just make an IOCTL with the IOCTL-code being an
52 * encoded form of the (group, number) pair. On the kernel-side, the Device
53 * Driver's IOCTL handler decodes the IOCTL-code back into a (group, number)
54 * pair, and uses this to determine which corresponding _mali_ukk should be
56 * - Refer to \ref _mali_uk_functions for more information about this
57 * (group, number) pairing.
58 * - In a system where there is no distinction between user and kernel-side,
59 * the U/K interface may be implemented as:@code
60 * MALI_STATIC_INLINE _mali_osk_errcode_t _mali_uku_examplefunction( _mali_uk_examplefunction_s *args )
62 * return mali_ukk_examplefunction( args );
65 * - Therefore, all U/K calls behave \em as \em though they were direct
66 * function calls (but the \b implementation \em need \em not be a direct
69 * @note Naming the _mali_uk functions the same on both User and Kernel sides
70 * on non-RTOS systems causes debugging issues when setting breakpoints. In
71 * this case, it is not clear which function the breakpoint is put on.
72 * Therefore the _mali_uk functions in user space are prefixed with \c _mali_uku
73 * and in kernel space with \c _mali_ukk. The naming for the argument
74 * structures is unaffected.
76 * - The _mali_uk functions are synchronous.
77 * - Arguments to the _mali_uk functions are passed in a structure. The only
78 * parameter passed to the _mali_uk functions is a pointer to this structure.
79 * This first member of this structure, ctx, is a pointer to a context returned
80 * by _mali_uku_open(). For example:@code
84 * u32 number_of_cores;
85 * } _mali_uk_get_gp_number_of_cores_s;
88 * - Each _mali_uk function has its own argument structure named after the
89 * function. The argument is distinguished by the _s suffix.
90 * - The argument types are defined by the base driver and user-kernel
92 * - All _mali_uk functions return a standard \ref _mali_osk_errcode_t.
93 * - Only arguments of type input or input/output need be initialized before
94 * calling a _mali_uk function.
95 * - Arguments of type output and input/output are only valid when the
96 * _mali_uk function returns \ref _MALI_OSK_ERR_OK.
97 * - The \c ctx member is always invalid after it has been used by a
98 * _mali_uk function, except for the context management functions
101 * \b Interface \b restrictions
103 * The requirements of the interface mean that an implementation of the
104 * User-kernel interface may do no 'real' work. For example, the following are
105 * illegal in the User-kernel implementation:
106 * - Calling functions necessary for operation on all systems, which would
107 * not otherwise get called on RTOS systems.
108 * - For example, a U/K interface that calls multiple _mali_ukk functions
109 * during one particular U/K call. This could not be achieved by the same code
110 * which uses direct function calls for the U/K interface.
111 * - Writing in values to the args members, when otherwise these members would
112 * not hold a useful value for a direct function call U/K interface.
113 * - For example, U/K interface implementation that take NULL members in
114 * their arguments structure from the user side, but those members are
115 * replaced with non-NULL values in the kernel-side of the U/K interface
116 * implementation. A scratch area for writing data is one such example. In this
117 * case, a direct function call U/K interface would segfault, because no code
118 * would be present to replace the NULL pointer with a meaningful pointer.
119 * - Note that we discourage the case where the U/K implementation changes
120 * a NULL argument member to non-NULL, and then the Device Driver code (outside
121 * of the U/K layer) re-checks this member for NULL, and corrects it when
122 * necessary. Whilst such code works even on direct function call U/K
123 * intefaces, it reduces the testing coverage of the Device Driver code. This
124 * is because we have no way of testing the NULL == value path on an OS
127 * A number of allowable examples exist where U/K interfaces do 'real' work:
128 * - The 'pointer switching' technique for \ref _mali_ukk_get_system_info
129 * - In this case, without the pointer switching on direct function call
130 * U/K interface, the Device Driver code still sees the same thing: a pointer
131 * to which it can write memory. This is because such a system has no
132 * distinction between a user and kernel pointer.
133 * - Writing an OS-specific value into the ukk_private member for
134 * _mali_ukk_mem_mmap().
135 * - In this case, this value is passed around by Device Driver code, but
136 * its actual value is never checked. Device Driver code simply passes it from
137 * the U/K layer to the OSK layer, where it can be acted upon. In this case,
138 * \em some OS implementations of the U/K (_mali_ukk_mem_mmap()) and OSK
139 * (_mali_osk_mem_mapregion_init()) functions will collaborate on the
140 * meaning of ukk_private member. On other OSs, it may be unused by both
142 * - On OS systems (not including direct function call U/K interface
143 * implementations), _mali_ukk_get_big_block() may succeed, but the subsequent
144 * copying to user space may fail.
145 * - A problem scenario exists: some memory has been reserved by
146 * _mali_ukk_get_big_block(), but the user-mode will be unaware of it (it will
147 * never receive any information about this memory). In this case, the U/K
148 * implementation must do everything necessary to 'rollback' the \em atomic
149 * _mali_ukk_get_big_block() transaction.
150 * - Therefore, on error inside the U/K interface implementation itself,
151 * it will be as though the _mali_ukk function itself had failed, and cleaned
153 * - Compare this to a direct function call U/K implementation, where all
154 * error cleanup is handled by the _mali_ukk function itself. The direct
155 * function call U/K interface implementation is automatically atomic.
157 * The last example highlights a consequence of all U/K interface
158 * implementations: they must be atomic with respect to the Device Driver code.
159 * And therefore, should Device Driver code succeed but the U/K implementation
160 * fail afterwards (but before return to user-space), then the U/K
161 * implementation must cause appropriate cleanup actions to preserve the
162 * atomicity of the interface.
168 /** @defgroup _mali_uk_context U/K Context management
170 * These functions allow for initialisation of the user-kernel interface once per process.
172 * Generally the context will store the OS specific object to communicate with the kernel device driver and further
173 * state information required by the specific implementation. The context is shareable among all threads in the caller process.
175 * On IOCTL systems, this is likely to be a file descriptor as a result of opening the kernel device driver.
177 * On a bare-metal/RTOS system with no distinction between kernel and
178 * user-space, the U/K interface simply calls the _mali_ukk variant of the
179 * function by direct function call. In this case, the context returned is the
180 * mali_session_data from _mali_ukk_open().
182 * The kernel side implementations of the U/K interface expect the first member of the argument structure to
183 * be the context created by _mali_uku_open(). On some OS implementations, the meaning of this context
184 * will be different between user-side and kernel-side. In which case, the kernel-side will need to replace this context
185 * with the kernel-side equivalent, because user-side will not have access to kernel-side data. The context parameter
186 * in the argument structure therefore has to be of type input/output.
188 * It should be noted that the caller cannot reuse the \c ctx member of U/K
189 * argument structure after a U/K call, because it may be overwritten. Instead,
190 * the context handle must always be stored elsewhere, and copied into
191 * the appropriate U/K argument structure for each user-side call to
192 * the U/K interface. This is not usually a problem, since U/K argument
193 * structures are usually placed on the stack.
197 /** @brief Begin a new Mali Device Driver session
199 * This is used to obtain a per-process context handle for all future U/K calls.
201 * @param context pointer to storage to return a (void*)context handle.
202 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
204 _mali_osk_errcode_t _mali_ukk_open( void **context );
206 /** @brief End a Mali Device Driver session
208 * This should be called when the process no longer requires use of the Mali Device Driver.
210 * The context handle must not be used after it has been closed.
212 * @param context pointer to a stored (void*)context handle.
213 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
215 _mali_osk_errcode_t _mali_ukk_close( void **context );
217 /** @} */ /* end group _mali_uk_context */
220 /** @addtogroup _mali_uk_core U/K Core
222 * The core functions provide the following functionality:
223 * - verify that the user and kernel API are compatible
224 * - retrieve information about the cores and memory banks in the system
225 * - wait for the result of jobs started on a core
229 /** @brief Returns the size of the buffer needed for a _mali_ukk_get_system_info call
231 * This function must be called before a call is made to
232 * _mali_ukk_get_system_info, so that memory of the correct size can be
233 * allocated, and a pointer to this memory written into the system_info member
234 * of _mali_uk_get_system_info_s.
236 * @param args see _mali_uk_get_system_info_size_s in "mali_uk_types.h"
237 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
239 _mali_osk_errcode_t _mali_ukk_get_system_info_size( _mali_uk_get_system_info_size_s *args );
241 /** @brief Returns information about the system (cores and memory banks)
243 * A buffer for this needs to be allocated by the caller. The size of the buffer required is returned by
244 * _mali_ukk_get_system_info_size(). The user is responsible for freeing the buffer.
246 * The _mali_system_info structure will be written to the start of this buffer,
247 * and the core_info and mem_info lists will be written to locations inside
248 * the buffer, and will be suitably aligned.
250 * Under OS implementations of the U/K interface we need to pack/unpack
251 * pointers across the user/kernel boundary. This has required that we malloc()
252 * an intermediate buffer inside the kernel-side U/K interface, and free it
253 * before returning to user-side. To avoid modifying common code, we do the
254 * following pseudo-code, which we shall call 'pointer switching':
258 * Copy_From_User(kargs, args, ... );
259 * void __user * local_ptr = kargs->system_info;
260 * kargs->system_info = _mali_osk_malloc( ... );
261 * _mali_ukk_get_system_info( kargs );
262 * Copy_To_User( local_ptr, kargs->system_info, ... );
263 * _mali_osk_free( kargs->system_info );
266 * @note The user-side's args->system_info members was unmodified here.
268 * However, the current implementation requires an extra ukk_private word so that the common code can work out
269 * how to patch pointers to user-mode for an OS's U/K implementation, this should be set to the user-space
270 * destination address for pointer-patching to occur. When NULL, it is unused, an no pointer-patching occurs in the
273 * @param args see _mali_uk_get_system_info_s in "mali_uk_types.h"
274 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
276 _mali_osk_errcode_t _mali_ukk_get_system_info( _mali_uk_get_system_info_s *args );
278 /** @brief Waits for a job notification.
280 * Sleeps until notified or a timeout occurs. Returns information about the notification.
282 * @param args see _mali_uk_wait_for_notification_s in "mali_uk_types.h"
283 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
285 _mali_osk_errcode_t _mali_ukk_wait_for_notification( _mali_uk_wait_for_notification_s *args );
287 /** @brief Post a notification to the notification queue of this application.
289 * @param args see _mali_uk_post_notification_s in "mali_uk_types.h"
290 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
292 _mali_osk_errcode_t _mali_ukk_post_notification( _mali_uk_post_notification_s *args );
294 /** @brief Verifies if the user and kernel side of this API are compatible.
296 * @param args see _mali_uk_get_api_version_s in "mali_uk_types.h"
297 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
299 _mali_osk_errcode_t _mali_ukk_get_api_version( _mali_uk_get_api_version_s *args );
300 /** @} */ /* end group _mali_uk_core */
303 /** @addtogroup _mali_uk_memory U/K Memory
305 * The memory functions provide functionality with and without a Mali-MMU present.
307 * For Mali-MMU based systems, the following functionality is provided:
308 * - Initialize and terminate MALI virtual address space
309 * - Allocate/deallocate physical memory to a MALI virtual address range and map into/unmap from the
310 * current process address space
311 * - Map/unmap external physical memory into the MALI virtual address range
313 * For Mali-nonMMU based systems:
314 * - Allocate/deallocate MALI memory
319 * @brief Initialize the Mali-MMU Memory system
321 * For Mali-MMU builds of the drivers, this function must be called before any
322 * other functions in the \ref _mali_uk_memory group are called.
324 * @note This function is for Mali-MMU builds \b only. It should not be called
325 * when the drivers are built without Mali-MMU support.
327 * @param args see \ref _mali_uk_init_mem_s in mali_uk_types.h
328 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable
329 * _mali_osk_errcode_t on failure.
331 _mali_osk_errcode_t _mali_ukk_init_mem( _mali_uk_init_mem_s *args );
334 * @brief Terminate the MMU Memory system
336 * For Mali-MMU builds of the drivers, this function must be called when
337 * functions in the \ref _mali_uk_memory group will no longer be called. This
338 * function must be called before the application terminates.
340 * @note This function is for Mali-MMU builds \b only. It should not be called
341 * when the drivers are built without Mali-MMU support.
343 * @param args see \ref _mali_uk_term_mem_s in mali_uk_types.h
344 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable
345 * _mali_osk_errcode_t on failure.
347 _mali_osk_errcode_t _mali_ukk_term_mem( _mali_uk_term_mem_s *args );
349 /** @brief Map a block of memory into the current user process
351 * Allocates a minimum of minimum_size_requested bytes of MALI memory and maps it into the current
352 * process space. The number of bytes allocated is returned in args->block_size.
354 * This is only used for Mali-nonMMU mode.
356 * @param args see _mali_uk_get_big_block_s in "mali_uk_types.h"
357 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
359 _mali_osk_errcode_t _mali_ukk_get_big_block( _mali_uk_get_big_block_s *args );
361 /** @brief Unmap a block of memory from the current user process
363 * Frees allocated MALI memory and unmaps it from the current process space. The previously allocated memory
364 * is indicated by the cookie as returned by _mali_ukk_get_big_block().
366 * This is only used for Mali-nonMMU mode.
368 * @param args see _mali_uk_free_big_block_s in "mali_uk_types.h"
369 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
371 _mali_osk_errcode_t _mali_ukk_free_big_block( _mali_uk_free_big_block_s *args );
373 /** @brief Map Mali Memory into the current user process
375 * Maps Mali memory into the current user process in a generic way.
377 * This function is to be used for Mali-MMU mode. The function is available in both Mali-MMU and Mali-nonMMU modes,
378 * but should not be called by a user process in Mali-nonMMU mode. In Mali-nonMMU mode, the function is callable
379 * from the kernel side, and is used to implement _mali_ukk_get_big_block() in this case.
381 * The implementation and operation of _mali_ukk_mem_mmap() is dependant on whether the driver is built for Mali-MMU
383 * - In the nonMMU case, _mali_ukk_mem_mmap() requires a physical address to be specified. For this reason, an OS U/K
384 * implementation should not allow this to be called from user-space. In any case, nonMMU implementations are
385 * inherently insecure, and so the overall impact is minimal. Mali-MMU mode should be used if security is desired.
386 * - In the MMU case, _mali_ukk_mem_mmap() the _mali_uk_mem_mmap_s::phys_addr
387 * member is used for the \em Mali-virtual address desired for the mapping. The
388 * implementation of _mali_ukk_mem_mmap() will allocate both the CPU-virtual
389 * and CPU-physical addresses, and can cope with mapping a contiguous virtual
390 * address range to a sequence of non-contiguous physical pages. In this case,
391 * the CPU-physical addresses are not communicated back to the user-side, as
392 * they are unnecsessary; the \em Mali-virtual address range must be used for
393 * programming Mali structures.
395 * This means that in the first (nonMMU) case, the caller must manage the physical address allocations. The caller
396 * in this case is _mali_ukk_get_big_block(), which does indeed manage the Mali physical address ranges.
398 * In the second (MMU) case, _mali_ukk_mem_mmap() handles management of
399 * CPU-virtual and CPU-physical ranges, but the \em caller must manage the
400 * \em Mali-virtual address range from the user-side.
402 * @note Mali-virtual address ranges are entirely separate between processes.
403 * It is not possible for a process to accidentally corrupt another process'
404 * \em Mali-virtual address space.
406 * @param args see _mali_uk_mem_mmap_s in "mali_uk_types.h"
407 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
409 _mali_osk_errcode_t _mali_ukk_mem_mmap( _mali_uk_mem_mmap_s *args );
411 /** @brief Unmap Mali Memory from the current user process
413 * Unmaps Mali memory from the current user process in a generic way. This only operates on Mali memory supplied
414 * from _mali_ukk_mem_mmap().
416 * @param args see _mali_uk_mem_munmap_s in "mali_uk_types.h"
417 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
419 _mali_osk_errcode_t _mali_ukk_mem_munmap( _mali_uk_mem_munmap_s *args );
421 /** @brief Determine the buffer size necessary for an MMU page table dump.
422 * @param args see _mali_uk_query_mmu_page_table_dump_size_s in mali_uk_types.h
423 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
425 _mali_osk_errcode_t _mali_ukk_query_mmu_page_table_dump_size( _mali_uk_query_mmu_page_table_dump_size_s *args );
426 /** @brief Dump MMU Page tables.
427 * @param args see _mali_uk_dump_mmu_page_table_s in mali_uk_types.h
428 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
430 _mali_osk_errcode_t _mali_ukk_dump_mmu_page_table( _mali_uk_dump_mmu_page_table_s * args );
432 /** @brief Map a physically contiguous range of memory into Mali
433 * @param args see _mali_uk_map_external_mem_s in mali_uk_types.h
434 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
436 _mali_osk_errcode_t _mali_ukk_map_external_mem( _mali_uk_map_external_mem_s *args );
438 /** @brief Unmap a physically contiguous range of memory from Mali
439 * @param args see _mali_uk_unmap_external_mem_s in mali_uk_types.h
440 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
442 _mali_osk_errcode_t _mali_ukk_unmap_external_mem( _mali_uk_unmap_external_mem_s *args );
444 #if MALI_USE_UNIFIED_MEMORY_PROVIDER != 0
445 /** @brief Map UMP memory into Mali
446 * @param args see _mali_uk_attach_ump_mem_s in mali_uk_types.h
447 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
449 _mali_osk_errcode_t _mali_ukk_attach_ump_mem( _mali_uk_attach_ump_mem_s *args );
450 /** @brief Unmap UMP memory from Mali
451 * @param args see _mali_uk_release_ump_mem_s in mali_uk_types.h
452 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
454 _mali_osk_errcode_t _mali_ukk_release_ump_mem( _mali_uk_release_ump_mem_s *args );
455 #endif /* MALI_USE_UNIFIED_MEMORY_PROVIDER */
457 /** @brief Determine virtual-to-physical mapping of a contiguous memory range
460 * This allows the user-side to do a virtual-to-physical address translation.
461 * In conjunction with _mali_uku_map_external_mem, this can be used to do
464 * This function will only succeed on a virtual range that is mapped into the
465 * current process, and that is contigious.
467 * If va is not page-aligned, then it is rounded down to the next page
468 * boundary. The remainer is added to size, such that ((u32)va)+size before
469 * rounding is equal to ((u32)va)+size after rounding. The rounded modified
470 * va and size will be written out into args on success.
472 * If the supplied size is zero, or not a multiple of the system's PAGE_SIZE,
473 * then size will be rounded up to the next multiple of PAGE_SIZE before
474 * translation occurs. The rounded up size will be written out into args on
477 * On most OSs, virtual-to-physical address translation is a priveledged
478 * function. Therefore, the implementer must validate the range supplied, to
479 * ensure they are not providing arbitrary virtual-to-physical address
480 * translations. While it is unlikely such a mechanism could be used to
481 * compromise the security of a system on its own, it is possible it could be
482 * combined with another small security risk to cause a much larger security
485 * @note This is an optional part of the interface, and is only used by certain
486 * implementations of libEGL. If the platform layer in your libEGL
487 * implementation does not require Virtual-to-Physical address translation,
488 * then this function need not be implemented. A stub implementation should not
489 * be required either, as it would only be removed by the compiler's dead code
492 * @note if implemented, this function is entirely platform-dependant, and does
493 * not exist in common code.
495 * @param args see _mali_uk_va_to_mali_pa_s in "mali_uk_types.h"
496 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
498 _mali_osk_errcode_t _mali_ukk_va_to_mali_pa( _mali_uk_va_to_mali_pa_s * args );
500 /** @} */ /* end group _mali_uk_memory */
503 /** @addtogroup _mali_uk_pp U/K Fragment Processor
505 * The Fragment Processor (aka PP (Pixel Processor)) functions provide the following functionality:
506 * - retrieving version of the fragment processors
507 * - determine number of fragment processors
508 * - starting a job on a fragment processor
512 /** @brief Issue a request to start a new job on a Fragment Processor.
514 * If the request fails args->status is set to _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE and you can
515 * try to start the job again.
517 * An existing job could be returned for requeueing if the new job has a higher priority than a previously started job
518 * which the hardware hasn't actually started processing yet. In this case the new job will be started instead and the
519 * existing one returned, otherwise the new job is started and the status field args->status is set to
520 * _MALI_UK_START_JOB_STARTED.
522 * If an existing lower priority job is returned, args->returned_user_job_ptr contains a
523 * pointer to the returned job and the status field args->status is set to
524 * _MALI_UK_START_JOB_STARTED_LOW_PRI_JOB_RETURNED.
526 * Job completion can be awaited with _mali_ukk_wait_for_notification().
528 * @param args see _mali_uk_pp_start_job_s in "mali_uk_types.h"
529 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
531 _mali_osk_errcode_t _mali_ukk_pp_start_job( _mali_uk_pp_start_job_s *args );
533 /** @brief Returns the number of Fragment Processors in the system
535 * @param args see _mali_uk_get_pp_number_of_cores_s in "mali_uk_types.h"
536 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
538 _mali_osk_errcode_t _mali_ukk_get_pp_number_of_cores( _mali_uk_get_pp_number_of_cores_s *args );
540 /** @brief Returns the version that all Fragment Processor cores are compatible with.
542 * This function may only be called when _mali_ukk_get_pp_number_of_cores() indicated at least one Fragment
543 * Processor core is available.
545 * @param args see _mali_uk_get_pp_core_version_s in "mali_uk_types.h"
546 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
548 _mali_osk_errcode_t _mali_ukk_get_pp_core_version( _mali_uk_get_pp_core_version_s *args );
550 /** @brief Abort any PP jobs with the given ID.
552 * Jobs internally queued or currently running on the hardware is to be stopped/aborted.
553 * Jobs aborted are reported via the normal job completion system.
554 * Any jobs, running or internally queued should be aborted imediately.
555 * Normal notifiction procedures to report on the status of these jobs.
558 * @param args see _malu_uk_pp_abort_job_s in "mali_uk_types.h"
560 void _mali_ukk_pp_abort_job( _mali_uk_pp_abort_job_s *args );
561 /** @} */ /* end group _mali_uk_pp */
564 /** @addtogroup _mali_uk_gp U/K Vertex Processor
566 * The Vertex Processor (aka GP (Geometry Processor)) functions provide the following functionality:
567 * - retrieving version of the Vertex Processors
568 * - determine number of Vertex Processors available
569 * - starting a job on a Vertex Processor
573 /** @brief Issue a request to start a new job on a Vertex Processor.
575 * If the request fails args->status is set to _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE and you can
576 * try to start the job again.
578 * An existing job could be returned for requeueing if the new job has a higher priority than a previously started job
579 * which the hardware hasn't actually started processing yet. In this case the new job will be started and the
580 * existing one returned, otherwise the new job is started and the status field args->status is set to
581 * _MALI_UK_START_JOB_STARTED.
583 * If an existing lower priority job is returned, args->returned_user_job_ptr contains a pointer to
584 * the returned job and the status field args->status is set to
585 * _MALI_UK_START_JOB_STARTED_LOW_PRI_JOB_RETURNED.
587 * Job completion can be awaited with _mali_ukk_wait_for_notification().
589 * @param args see _mali_uk_gp_start_job_s in "mali_uk_types.h"
590 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
592 _mali_osk_errcode_t _mali_ukk_gp_start_job( _mali_uk_gp_start_job_s *args );
594 /** @brief Returns the number of Vertex Processors in the system.
596 * @param args see _mali_uk_get_gp_number_of_cores_s in "mali_uk_types.h"
597 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
599 _mali_osk_errcode_t _mali_ukk_get_gp_number_of_cores( _mali_uk_get_gp_number_of_cores_s *args );
601 /** @brief Returns the version that all Vertex Processor cores are compatible with.
603 * This function may only be called when _mali_uk_get_gp_number_of_cores() indicated at least one Vertex
604 * Processor core is available.
606 * @param args see _mali_uk_get_gp_core_version_s in "mali_uk_types.h"
607 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
609 _mali_osk_errcode_t _mali_ukk_get_gp_core_version( _mali_uk_get_gp_core_version_s *args );
611 /** @brief Resume or abort suspended Vertex Processor jobs.
613 * After receiving notification that a Vertex Processor job was suspended from
614 * _mali_ukk_wait_for_notification() you can use this function to resume or abort the job.
616 * @param args see _mali_uk_gp_suspend_response_s in "mali_uk_types.h"
617 * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
619 _mali_osk_errcode_t _mali_ukk_gp_suspend_response( _mali_uk_gp_suspend_response_s *args );
621 /** @brief Abort any GP jobs with the given ID.
623 * Jobs internally queued or currently running on the hardware is to be stopped/aborted.
624 * Jobs aborted are reported via the normal job completion system.
626 * Any jobs, running or internally queued should be aborted imediately.
627 * Normal notifiction procedures to report on the status of these jobs.
629 * @param args see _mali_uk_gp_abort_job_s in "mali_uk_types.h"
631 void _mali_ukk_gp_abort_job( _mali_uk_gp_abort_job_s *args );
632 /** @} */ /* end group _mali_uk_gp */
635 /** @addtogroup _mali_uk_pmm U/K Power Management Module
638 /* @brief Power Management Module event message
640 * @note The event message can fail to be sent due to OOM but this is
641 * stored in the PMM state machine to be handled later
643 * @param args see _mali_uk_pmm_event_message_s in "mali_uk_types.h"
645 void _mali_ukk_pmm_event_message( _mali_uk_pmm_message_s *args );
646 /** @} */ /* end group _mali_uk_pmm */
647 #endif /* USING_MALI_PMM */
649 #if MALI_TIMELINE_PROFILING_ENABLED
650 /** @addtogroup _mali_uk_profiling U/K Timeline profiling module
653 /** @brief Start recording profiling events.
655 * @param args see _mali_uk_profiling_start_s in "mali_uk_types.h"
657 _mali_osk_errcode_t _mali_ukk_profiling_start(_mali_uk_profiling_start_s *args);
659 /** @brief Add event to profiling buffer.
661 * @param args see _mali_uk_profiling_add_event_s in "mali_uk_types.h"
663 _mali_osk_errcode_t _mali_ukk_profiling_add_event(_mali_uk_profiling_add_event_s *args);
665 /** @brief Stop recording profiling events.
667 * @param args see _mali_uk_profiling_stop_s in "mali_uk_types.h"
669 _mali_osk_errcode_t _mali_ukk_profiling_stop(_mali_uk_profiling_stop_s *args);
671 /** @brief Retrieve a recorded profiling event.
673 * @param args see _mali_uk_profiling_get_event_s in "mali_uk_types.h"
675 _mali_osk_errcode_t _mali_ukk_profiling_get_event(_mali_uk_profiling_get_event_s *args);
677 /** @brief Clear recorded profiling events.
679 * @param args see _mali_uk_profiling_clear_s in "mali_uk_types.h"
681 _mali_osk_errcode_t _mali_ukk_profiling_clear(_mali_uk_profiling_clear_s *args);
683 /** @brief Get the profiling config applicable for calling process.
685 * @param args see _mali_uk_profiling_get_config_s in "mali_uk_types.h"
687 _mali_osk_errcode_t _mali_ukk_profiling_get_config(_mali_uk_profiling_get_config_s *args);
689 /** @brief Transfer software counters from user to kernel space
691 * @param args see _mali_uk_transfer_sw_counters_s in "mali_uk_types.h"
693 _mali_osk_errcode_t _mali_ukk_transfer_sw_counters(_mali_uk_sw_counters_s *args);
695 /** @} */ /* end group _mali_uk_profiling */
698 /** @addtogroup _mali_uk_vsync U/K VSYNC reporting module
701 /** @brief Report events related to vsync.
703 * @note Events should be reported when starting to wait for vsync and when the
704 * waiting is finished. This information can then be used in kernel space to
705 * complement the GPU utilization metric.
707 * @param args see _mali_uk_vsync_event_report_s in "mali_uk_types.h"
709 _mali_osk_errcode_t _mali_ukk_vsync_event_report(_mali_uk_vsync_event_report_s *args);
711 /** @} */ /* end group _mali_uk_vsync */
713 /** @} */ /* end group u_k_api */
715 /** @} */ /* end group uddapi */
717 u32 _mali_ukk_report_memory_usage(void);
723 #endif /* __MALI_UKK_H__ */