Initial commit
[kernel/linux-3.0.git] / drivers / gpu / vithar / osk / src / linux / include / osk / mali_osk_arch_debug.h
1 /*
2  *
3  * (C) COPYRIGHT 2010-2012 ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
6  * 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  * 
8  * A copy of the licence is included with the program, and can also be obtained from Free Software
9  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
10  * 
11  */
12
13
14
15 /**
16  * @file
17  * Implementation of the OS abstraction layer for the kernel device driver
18  */
19
20 #ifndef _OSK_ARCH_DEBUG_H_
21 #define _OSK_ARCH_DEBUG_H_
22
23 #include <malisw/mali_stdtypes.h>
24 #include "mali_osk_arch_types.h"
25
26 #if MALI_UNIT_TEST
27 /* Kernel testing helpers */
28 void      osk_kernel_test_init(void);
29 void      osk_kernel_test_term(void);
30 void      osk_kernel_test_wait(void);
31 void      osk_kernel_test_signal(void);
32 mali_bool osk_kernel_test_has_asserted(void);
33 void      oskp_kernel_test_exit(void);
34 #endif
35
36 /** Maximum number of bytes (incl. end of string character) supported in the generated debug output string */
37 #define OSK_DEBUG_MESSAGE_SIZE 256
38
39 /**
40  * All OSKP_ASSERT* and OSKP_PRINT_* macros will eventually call OSKP_PRINT to output messages
41  */
42 void oskp_debug_print(const char *fmt, ...);
43 #define OSKP_PRINT(...) oskp_debug_print(__VA_ARGS__)
44
45 /**
46  * Insert a breakpoint to cause entry in an attached debugger. However, since there is
47  * no API available to trigger entry in a debugger, we dereference a NULL
48  * pointer which should cause an exception and enter a debugger.
49  */
50 #define OSKP_BREAKPOINT() *(int *)0 = 0
51
52 /**
53  * Quit the driver and halt.
54  */
55 #define OSKP_QUIT() BUG()
56
57 /**
58  * Print a backtrace 
59  */
60 #define OSKP_TRACE() WARN_ON(1)
61
62 #define OSKP_CHANNEL_INFO      ((u32)0x00000001)      /**< @brief No output*/
63 #define OSKP_CHANNEL_WARN      ((u32)0x00000002)      /**< @brief Standard output*/
64 #define OSKP_CHANNEL_ERROR     ((u32)0x00000004)      /**< @brief Error output*/
65 #define OSKP_CHANNEL_RAW       ((u32)0x00000008)      /**< @brief Raw output*/
66 #define OSKP_CHANNEL_ALL       ((u32)0xFFFFFFFF)      /**< @brief All the channels at the same time*/
67
68 /** @brief Disable the asserts tests if set to 1. Default is to enable the asserts. */
69 #ifndef OSK_DISABLE_ASSERT
70 #define OSK_DISABLE_ASSERTS 0    
71 #endif
72
73 /** @brief If equals to 0, a trace containing the file, line, and function will be displayed before each message. */
74 #define OSK_SKIP_TRACE 0
75
76 /** @brief If different from 0, the trace will only contain the file and line. */
77 #define OSK_SKIP_FUNCTION_NAME 0
78
79 /** @brief Variable to set the permissions per module and per channel. 
80  */
81 #define OSK_MODULES_PERMISSIONS "ALL_ALL"
82
83 /** @brief String terminating every message printed by the debug API */
84 #define OSK_STOP_MSG "\n"
85
86 /** @brief Enables support for runtime configuration if set to 1. 
87  */
88 #define OSK_USE_RUNTIME_CONFIG 0
89 #define OSK_SIMULATE_FAILURES  MALI_BASE_TRACK_MEMLEAK  /**< @brief Enables simulation of failures (for testing) if non-zero */
90
91 #define OSK_ACTION_IGNORE             0 /**< @brief The given message is ignored then the execution continues*/
92 #define OSK_ACTION_PRINT_AND_CONTINUE 1 /**< @brief The given message is printed then the execution continues*/
93 #define OSK_ACTION_PRINT_AND_BREAK    2 /**< @brief The given message is printed then a break point is triggered*/
94 #define OSK_ACTION_PRINT_AND_QUIT     3 /**< @brief The given message is printed then the execution is stopped*/
95 #define OSK_ACTION_PRINT_AND_TRACE    4 /**< @brief The given message and a backtrace is printed then the execution continues*/
96
97 /**
98  * @def OSK_ON_INFO
99  * @brief Defines the API behavior when @ref OSK_PRINT_INFO() is called
100  * @note Must be set to one of the following values: @see OSK_ACTION_PRINT_AND_CONTINUE,
101  * @note @ref OSK_ACTION_PRINT_AND_BREAK, @see OSK_ACTION_PRINT_AND_QUIT, @see OSK_ACTION_IGNORE
102  *
103  * @def OSK_ON_WARN
104  * @brief Defines the API behavior when @see OSK_PRINT_WARN() is called
105  * @note Must be set to one of the following values: @see OSK_ACTION_PRINT_AND_CONTINUE,
106  * @note @see OSK_ACTION_PRINT_AND_BREAK, @see OSK_ACTION_PRINT_AND_QUIT, @see OSK_ACTION_IGNORE
107  *
108  * @def OSK_ON_ERROR
109  * @brief Defines the API behavior when @see OSK_PRINT_ERROR() is called
110  * @note Must be set to one of the following values: @see OSK_ACTION_PRINT_AND_CONTINUE,
111  * @note @see OSK_ACTION_PRINT_AND_BREAK, @see OSK_ACTION_PRINT_AND_QUIT, @see OSK_ACTION_IGNORE
112  *
113  * @def OSK_ON_ASSERT
114  * @brief Defines the API behavior when @see OSKP_PRINT_ASSERT() is called
115  * @note Must be set to one of the following values: @see OSK_ACTION_PRINT_AND_CONTINUE,
116  * @note @see OSK_ACTION_PRINT_AND_BREAK, @see OSK_ACTION_PRINT_AND_QUIT, @see OSK_ACTION_IGNORE
117  *
118  * @def OSK_ON_RAW
119  * @brief Defines the API behavior when @see OSKP_PRINT_RAW() is called
120  * @note Must be set to one of the following values: @see OSK_ACTION_PRINT_AND_CONTINUE,
121  * @note @see OSK_ACTION_PRINT_AND_BREAK, @see OSK_ACTION_PRINT_AND_QUIT, @see OSK_ACTION_IGNORE
122  *
123  *
124  */
125 #if MALI_DEBUG
126         #define OSK_ON_INFO                OSK_ACTION_IGNORE
127         #define OSK_ON_WARN                OSK_ACTION_PRINT_AND_CONTINUE
128         #define OSK_ON_ASSERT              OSK_ACTION_PRINT_AND_QUIT
129         #define OSK_ON_ERROR               OSK_ACTION_PRINT_AND_CONTINUE
130         #define OSK_ON_RAW                 OSK_ACTION_PRINT_AND_CONTINUE
131 #else
132         #define OSK_ON_INFO                OSK_ACTION_IGNORE
133         #define OSK_ON_WARN                OSK_ACTION_IGNORE
134         #define OSK_ON_ASSERT              OSK_ACTION_IGNORE
135         #define OSK_ON_ERROR               OSK_ACTION_PRINT_AND_CONTINUE
136         #define OSK_ON_RAW                 OSK_ACTION_PRINT_AND_CONTINUE
137 #endif
138
139 #if MALI_UNIT_TEST
140 #define OSKP_KERNEL_TEST_ASSERT()               oskp_kernel_test_exit()
141 #else
142 #define OSKP_KERNEL_TEST_ASSERT()               CSTD_NOP()
143 #endif
144
145 /**
146  * OSK_ASSERT macros do nothing if the flag @see OSK_DISABLE_ASSERTS is set to 1
147  */
148 #if OSK_DISABLE_ASSERTS
149         #define OSKP_ASSERT(expr)           CSTD_NOP()
150         #define OSKP_INTERNAL_ASSERT(expr)  CSTD_NOP()
151         #define OSKP_ASSERT_MSG(expr, ...)  CSTD_NOP()
152 #else /* OSK_DISABLE_ASSERTS */
153
154 /**
155  * @def OSKP_ASSERT_MSG(expr, ...)
156  * @brief Calls @see OSKP_PRINT_ASSERT and prints the given message if @a expr is false
157  *
158  * @note This macro does nothing if the flag @see OSK_DISABLE_ASSERTS is set to 1
159  *
160  * @param expr Boolean expression
161  * @param ...  Message to display when @a expr is false, as a format string followed by format arguments.
162  */
163 #define OSKP_ASSERT_MSG(expr, ...)\
164         do\
165         {\
166                 if(MALI_FALSE == (expr))\
167                 {\
168                         OSKP_PRINT_ASSERT(__VA_ARGS__);\
169                 }\
170         }while(MALI_FALSE)
171
172 /**
173  * @def OSKP_ASSERT(expr)
174  * @brief Calls @see OSKP_PRINT_ASSERT and prints the expression @a expr if @a expr is false
175  *
176  * @note This macro does nothing if the flag @see OSK_DISABLE_ASSERTS is set to 1
177  *
178  * @param expr Boolean expression
179  */
180 #define OSKP_ASSERT(expr)\
181         OSKP_ASSERT_MSG(expr, #expr)
182
183 /**
184  * @def OSKP_INTERNAL_ASSERT(expr)
185  * @brief Calls @see OSKP_BREAKPOINT if @a expr is false 
186  * This assert function is for internal use of OSK functions which themselves are used to implement
187  * the OSK_ASSERT functionality. These functions should use OSK_INTERNAL_ASSERT which does not use
188  * any OSK functions to prevent ending up in a recursive loop. 
189  *
190  * @note This macro does nothing if the flag @see OSK_DISABLE_ASSERTS is set to 1
191  *
192  * @param expr Boolean expression
193  */
194 #define OSKP_INTERNAL_ASSERT(expr)\
195         do\
196         {\
197                 if(MALI_FALSE == (expr))\
198                 {\
199                         OSKP_BREAKPOINT();\
200                 }\
201         }while(MALI_FALSE)
202
203 /**
204  * @def   OSKP_PRINT_ASSERT(...)
205  * @brief Prints "MALI<ASSERT>" followed by trace, function name and the given message.
206  *
207  * The behavior of this function is defined by the macro @see OSK_ON_ASSERT.
208  *
209  * @note This macro does nothing if the flag @see OSK_DISABLE_ASSERTS is set to 1
210  *
211  * Example:  OSKP_PRINT_ASSERT(" %d blocks could not be allocated", mem_alocated) will print:\n
212  * "MALI<ASSERT> In file <path> line: <line number> function:<function name> 10 blocks could not be allocated"
213  *
214  * @note Depending on the values of @see OSK_SKIP_FUNCTION_NAME and @see OSK_SKIP_TRACE the trace will be displayed
215  * before the message.
216  *
217  * @param ...      Message to print, passed as a format string followed by format arguments.  
218  */
219 #define OSKP_PRINT_ASSERT(...)\
220         do\
221         {\
222                 OSKP_ASSERT_OUT(OSKP_PRINT_TRACE, OSKP_PRINT_FUNCTION, __VA_ARGS__);\
223                 oskp_debug_assert_call_hook();\
224                 OSKP_KERNEL_TEST_ASSERT();\
225                 OSKP_ASSERT_ACTION();\
226         }while(MALI_FALSE)
227
228 #endif
229
230 /**
231  * @def OSKP_DEBUG_CODE( X )
232  * @brief Executes the code inside the macro only in debug mode
233  *
234  * @param X Code to compile only in debug mode.
235  */
236 #if MALI_DEBUG
237         #define OSKP_DEBUG_CODE( X ) X
238 #else
239         #define OSKP_DEBUG_CODE( X ) CSTD_NOP()
240 #endif
241
242 /**
243  * @def OSKP_ASSERT_ACTION
244  * @brief (Private) Action associated to the @see OSKP_PRINT_ASSERT event.
245  */
246 /* Configure the post display action */
247 #if OSK_ON_ASSERT == OSK_ACTION_PRINT_AND_BREAK
248         #define OSKP_ASSERT_ACTION OSKP_BREAKPOINT
249 #elif OSK_ON_ASSERT == OSK_ACTION_PRINT_AND_QUIT
250         #define OSKP_ASSERT_ACTION OSKP_QUIT
251 #elif OSK_ON_ASSERT == OSK_ACTION_PRINT_AND_TRACE
252         #define OSKP_ASSERT_ACTION OSKP_TRACE
253 #elif OSK_ON_ASSERT == OSK_ACTION_PRINT_AND_CONTINUE || OSK_ON_ASSERT == OSK_ACTION_IGNORE
254         #define OSKP_ASSERT_ACTION() CSTD_NOP()
255 #else
256         #error invalid value for OSK_ON_ASSERT
257 #endif
258
259 /**
260  * @def OSKP_RAW_ACTION
261  * @brief (Private) Action associated to the @see OSK_PRINT_RAW event.
262  */
263 /* Configure the post display action */
264 #if OSK_ON_RAW == OSK_ACTION_PRINT_AND_BREAK
265         #define OSKP_RAW_ACTION OSKP_BREAKPOINT
266 #elif OSK_ON_RAW == OSK_ACTION_PRINT_AND_QUIT
267         #define OSKP_RAW_ACTION OSKP_QUIT
268 #elif OSK_ON_RAW == OSK_ACTION_PRINT_AND_TRACE
269         #define OSKP_RAW_ACTION OSKP_TRACE
270 #elif OSK_ON_RAW == OSK_ACTION_PRINT_AND_CONTINUE || OSK_ON_RAW == OSK_ACTION_IGNORE
271         #define OSKP_RAW_ACTION() CSTD_NOP()
272 #else
273         #error invalid value for OSK_ON_RAW
274 #endif
275
276 /**
277  * @def OSKP_INFO_ACTION
278  * @brief (Private) Action associated to the @see OSK_PRINT_INFO event.
279  */
280 /* Configure the post display action */
281 #if OSK_ON_INFO == OSK_ACTION_PRINT_AND_BREAK
282         #define OSKP_INFO_ACTION OSKP_BREAKPOINT
283 #elif OSK_ON_INFO == OSK_ACTION_PRINT_AND_QUIT
284         #define OSKP_INFO_ACTION OSKP_QUIT
285 #elif OSK_ON_INFO == OSK_ACTION_PRINT_AND_TRACE
286         #define OSKP_INFO_ACTION OSKP_TRACE
287 #elif OSK_ON_INFO == OSK_ACTION_PRINT_AND_CONTINUE || OSK_ON_INFO == OSK_ACTION_IGNORE
288         #define OSKP_INFO_ACTION() CSTD_NOP()
289 #else
290         #error invalid value for OSK_ON_INFO
291 #endif
292
293 /**
294  * @def OSKP_ERROR_ACTION
295  * @brief (Private) Action associated to the @see OSK_PRINT_ERROR event.
296  */
297 /* Configure the post display action */
298 #if OSK_ON_ERROR == OSK_ACTION_PRINT_AND_BREAK
299         #define OSKP_ERROR_ACTION OSKP_BREAKPOINT
300 #elif OSK_ON_ERROR == OSK_ACTION_PRINT_AND_QUIT
301         #define OSKP_ERROR_ACTION OSKP_QUIT
302 #elif OSK_ON_ERROR == OSK_ACTION_PRINT_AND_TRACE
303         #define OSKP_ERROR_ACTION OSKP_TRACE
304 #elif OSK_ON_ERROR == OSK_ACTION_PRINT_AND_CONTINUE || OSK_ON_ERROR == OSK_ACTION_IGNORE
305         #define OSKP_ERROR_ACTION() CSTD_NOP()
306 #else
307         #error invalid value for OSK_ON_ERROR
308 #endif
309
310 /**
311  * @def OSKP_WARN_ACTION
312  * @brief (Private) Action associated to the @see OSK_PRINT_WARN event.
313  */
314 /* Configure the post display action */
315 #if OSK_ON_WARN == OSK_ACTION_PRINT_AND_BREAK
316         #define OSKP_WARN_ACTION OSKP_BREAKPOINT
317 #elif OSK_ON_WARN == OSK_ACTION_PRINT_AND_QUIT
318         #define OSKP_WARN_ACTION OSKP_QUIT
319 #elif OSK_ON_WARN == OSK_ACTION_PRINT_AND_TRACE
320         #define OSKP_WARN_ACTION OSKP_TRACE
321 #elif OSK_ON_WARN == OSK_ACTION_PRINT_AND_CONTINUE || OSK_ON_WARN == OSK_ACTION_IGNORE
322         #define OSKP_WARN_ACTION() CSTD_NOP()
323 #else
324         #error invalid value for OSK_ON_WARN
325 #endif
326
327 /**
328  * @def   OSKP_PRINT_RAW(module, ...)
329  * @brief Prints given message
330  *
331  * The behavior of this function is defined by macro @see OSK_ON_RAW
332  *
333  * Example:
334  * @code OSKP_PRINT_RAW(OSK_BASE_MEM, " %d blocks could not be allocated", mem_allocated); @endcode will print:
335  * \n
336  * "10 blocks could not be allocated"
337  *
338  * @param module   Name of the module which prints the message.
339  * @param ...      Format string followed by a varying number of parameters
340  */
341 #define OSKP_PRINT_RAW(module, ...)\
342         do\
343         {\
344                 if(MALI_FALSE != OSKP_PRINT_IS_ALLOWED( (module), OSK_CHANNEL_RAW))\
345                 {\
346                         OSKP_RAW_OUT(oskp_module_to_str( (module) ), \
347                             OSKP_PRINT_TRACE, OSKP_PRINT_FUNCTION, __VA_ARGS__ );\
348                 }\
349                 OSKP_RAW_ACTION();\
350         }while(MALI_FALSE)
351
352 /**
353  * @def   OSKP_PRINT_INFO(module, ...)
354  * @brief Prints "MALI<INFO,module_name>: " followed by the given message.
355  *
356  * The behavior of this function is defined by the macro @see OSK_ON_INFO
357  *
358  * Example:
359  * @code OSKP_PRINT_INFO(OSK_BASE_MEM, " %d blocks could not be allocated", mem_allocated); @endcode will print: 
360  * \n
361  * "MALI<INFO,BASE_MEM>: 10 blocks could not be allocated"\n
362  *
363  * @param module   Name of the module which prints the message.
364  * @param ...      Format string followed by a varying number of parameters
365  */
366 #define OSKP_PRINT_INFO(module, ...)\
367         do\
368         {\
369                 if(MALI_FALSE != OSKP_PRINT_IS_ALLOWED( (module), OSK_CHANNEL_INFO))\
370                 {\
371                         OSKP_INFO_OUT(oskp_module_to_str( (module) ), \
372                             OSKP_PRINT_TRACE, OSKP_PRINT_FUNCTION, __VA_ARGS__ );\
373                 }\
374                 OSKP_INFO_ACTION();\
375         }while(MALI_FALSE)
376
377 /**
378  * @def   OSKP_PRINT_WARN(module, ...)
379  * @brief Prints "MALI<WARN,module_name>: " followed by the given message.
380  *
381  * The behavior of this function is defined by the macro @see OSK_ON_WARN
382  *
383  * Example:
384  * @code OSK_PRINT_WARN(OSK_BASE_MEM, " %d blocks could not be allocated", mem_allocated);@endcode will print: \n
385  * "MALI<WARN,BASE_MEM>: 10 blocks could not be allocated"\n
386  *
387  * @param module   Name of the module which prints the message.
388  * @param ...      Format string followed by a varying number of parameters
389  */
390 #define OSKP_PRINT_WARN(module, ...)\
391         do\
392         {\
393                 if(MALI_FALSE != OSKP_PRINT_IS_ALLOWED( (module), OSK_CHANNEL_WARN))\
394                 {\
395                         OSKP_WARN_OUT(oskp_module_to_str( (module) ), \
396                             OSKP_PRINT_TRACE, OSKP_PRINT_FUNCTION, __VA_ARGS__ );\
397                 }\
398                 OSKP_WARN_ACTION();\
399         }while(MALI_FALSE)
400
401 /**
402  * @def OSKP_PRINT_ERROR(module, ...)
403  * @brief Prints "MALI<ERROR,module_name>: " followed by the given message.
404  *
405  * The behavior of this function is defined by the macro @see OSK_ON_ERROR
406  *
407  * Example:
408  * @code OSKP_PRINT_ERROR(OSK_BASE_MEM, " %d blocks could not be allocated", mem_allocated); @endcode will print: 
409  * \n
410  * "MALI<ERROR,BASE_MEM>: 10 blocks could not be allocated"\n
411  *
412  * @param module   Name of the module which prints the message.
413  * @param ...      Format string followed by a varying number of parameters
414  */
415 #define OSKP_PRINT_ERROR(module, ...)\
416         do\
417         {\
418                 if(MALI_FALSE != OSKP_PRINT_IS_ALLOWED( (module), OSK_CHANNEL_ERROR))\
419                 {\
420                         OSKP_ERROR_OUT(oskp_module_to_str( (module) ), \
421                             OSKP_PRINT_TRACE, OSKP_PRINT_FUNCTION, __VA_ARGS__ );\
422                 }\
423                 OSKP_ERROR_ACTION();\
424         }while(MALI_FALSE)
425
426 /**
427  * @def OSKP_PRINT_TRACE
428  * @brief Private macro containing the format of the trace to display before every message
429  * @sa OSK_SKIP_TRACE, OSK_SKIP_FUNCTION_NAME
430  */
431 #if OSK_SKIP_TRACE == 0
432         #define OSKP_PRINT_TRACE \
433                 "In file: " __FILE__ " line: " CSTD_STR2(__LINE__)
434         #if OSK_SKIP_FUNCTION_NAME == 0
435                 #define OSKP_PRINT_FUNCTION CSTD_FUNC
436         #else
437                 #define OSKP_PRINT_FUNCTION ""
438         #endif
439 #else
440         #define OSKP_PRINT_TRACE ""
441 #endif
442
443 /**
444  * @def OSKP_PRINT_ALLOW(module, channel)
445  * @brief Allow the given module to print on the given channel
446  * @note If @see OSK_USE_RUNTIME_CONFIG is disabled then this macro doesn't do anything
447  * @param module is a @see osk_module
448  * @param channel is one of @see OSK_CHANNEL_INFO, @see OSK_CHANNEL_WARN, @see OSK_CHANNEL_ERROR,
449  * @see OSK_CHANNEL_ALL
450  * @return MALI_TRUE if the module is allowed to print on the channel.
451  */
452 /**
453  * @def OSKP_PRINT_BLOCK(module, channel)
454  * @brief Prevent the given module from printing on the given channel
455  * @note If @see OSK_USE_RUNTIME_CONFIG is disabled then this macro doesn't do anything
456  * @param module is a @see osk_module
457  * @param channel is one of @see OSK_CHANNEL_INFO, @see OSK_CHANNEL_WARN, @see OSK_CHANNEL_ERROR,
458  * @see OSK_CHANNEL_ALL
459  * @return MALI_TRUE if the module is allowed to print on the channel.
460  */
461 #if OSK_USE_RUNTIME_CONFIG
462         #define OSKP_PRINT_ALLOW(module, channel)   oskp_debug_print_allow( (module), (channel) )
463         #define OSKP_PRINT_BLOCK(module, channel)   oskp_debug_print_block( (module), (channel) )
464 #else
465         #define OSKP_PRINT_ALLOW(module, channel)   CSTD_NOP()
466         #define OSKP_PRINT_BLOCK(module, channel)   CSTD_NOP()
467 #endif
468
469 /**
470  * @def OSKP_RAW_OUT(module, trace, ...)
471  * @brief (Private) system printing function associated to the @see OSK_PRINT_RAW event.
472  * @param module module ID
473  * @param trace location in the code from where the message is printed
474  * @param function function from where the message is printed
475  * @param ... Format string followed by format arguments.
476  */
477 /* Select the correct system output function*/
478 #if OSK_ON_RAW != OSK_ACTION_IGNORE
479         #define OSKP_RAW_OUT(module, trace, function, ...)\
480                 do\
481                 {\
482                         OSKP_PRINT(__VA_ARGS__);\
483                         OSKP_PRINT(OSK_STOP_MSG);\
484                 }while(MALI_FALSE)
485 #else
486         #define OSKP_RAW_OUT(module, trace, function, ...) CSTD_NOP()
487 #endif
488
489
490 /**
491  * @def OSKP_INFO_OUT(module, trace, ...)
492  * @brief (Private) system printing function associated to the @see OSK_PRINT_INFO event.
493  * @param module module ID
494  * @param trace location in the code from where the message is printed
495  * @param function function from where the message is printed
496  * @param ... Format string followed by format arguments.
497  */
498 /* Select the correct system output function*/
499 #if OSK_ON_INFO != OSK_ACTION_IGNORE
500         #define OSKP_INFO_OUT(module, trace, function, ...)\
501                 do\
502                 {\
503                         /* Split up in several lines to prevent hitting max 128 chars limit of OSK print function */ \
504                         OSKP_PRINT("Mali<INFO,%s>: ", module);\
505                         OSKP_PRINT(__VA_ARGS__);\
506                         OSKP_PRINT(OSK_STOP_MSG);\
507                 }while(MALI_FALSE)
508 #else
509         #define OSKP_INFO_OUT(module, trace, function, ...) CSTD_NOP()
510 #endif
511
512 /**
513  * @def OSKP_ASSERT_OUT(trace, function, ...)
514  * @brief (Private) system printing function associated to the @see OSKP_PRINT_ASSERT event.
515  * @param trace location in the code from where the message is printed
516  * @param function function from where the message is printed
517  * @param ... Format string followed by format arguments.
518  * @note function parameter cannot be concatenated with other strings
519  */
520 /* Select the correct system output function*/
521 #if OSK_ON_ASSERT != OSK_ACTION_IGNORE
522         #define OSKP_ASSERT_OUT(trace, function, ...)\
523                 do\
524                 {\
525                         /* Split up in several lines to prevent hitting max 128 chars limit of OSK print function */ \
526                         OSKP_PRINT("Mali<ASSERT>: %s function:%s ", trace, function);\
527                         OSKP_PRINT(__VA_ARGS__);\
528                         OSKP_PRINT(OSK_STOP_MSG);\
529                 }while(MALI_FALSE)
530 #else
531         #define OSKP_ASSERT_OUT(trace, function, ...) CSTD_NOP()
532 #endif
533
534 /**
535  * @def OSKP_WARN_OUT(module, trace, ...)
536  * @brief (Private) system printing function associated to the @see OSK_PRINT_WARN event.
537  * @param module module ID
538  * @param trace location in the code from where the message is printed
539  * @param function function from where the message is printed
540  * @param ... Format string followed by format arguments.
541  * @note function parameter cannot be concatenated with other strings
542  */
543 /* Select the correct system output function*/
544 #if OSK_ON_WARN != OSK_ACTION_IGNORE
545         #define OSKP_WARN_OUT(module, trace, function, ...)\
546                 do\
547                 {\
548                         /* Split up in several lines to prevent hitting max 128 chars limit of OSK print function */ \
549                         OSKP_PRINT("Mali<WARN,%s>: ", module);\
550                         OSKP_PRINT(__VA_ARGS__);\
551                         OSKP_PRINT(OSK_STOP_MSG);\
552                 }while(MALI_FALSE)
553 #else
554         #define OSKP_WARN_OUT(module, trace, function, ...) CSTD_NOP()
555 #endif
556
557 /**
558  * @def OSKP_ERROR_OUT(module, trace, ...)
559  * @brief (Private) system printing function associated to the @see OSK_PRINT_ERROR event.
560  * @param module module ID
561  * @param trace location in the code from where the message is printed
562  * @param function function from where the message is printed
563  * @param ... Format string followed by format arguments.
564  * @note function parameter cannot be concatenated with other strings
565  */
566 /* Select the correct system output function*/
567 #if OSK_ON_ERROR != OSK_ACTION_IGNORE
568         #define OSKP_ERROR_OUT(module, trace, function, ...)\
569                 do\
570                 {\
571                         /* Split up in several lines to prevent hitting max 128 chars limit of OSK print function */ \
572                         OSKP_PRINT("Mali<ERROR,%s>: ", module);\
573                         OSKP_PRINT(__VA_ARGS__);\
574                         OSKP_PRINT(OSK_STOP_MSG);\
575                 }while(MALI_FALSE)
576 #else
577         #define OSKP_ERROR_OUT(module, trace, function, ...) CSTD_NOP()
578 #endif
579
580 /**
581  * @def OSKP_PRINT_IS_ALLOWED(module, channel)
582  * @brief function or constant indicating if the given module is allowed to print on the given channel
583  * @note If @see OSK_USE_RUNTIME_CONFIG is disabled then this macro is set to MALI_TRUE to avoid any overhead
584  * @param module is a @see osk_module
585  * @param channel is one of @see OSK_CHANNEL_INFO, @see OSK_CHANNEL_WARN, @see OSK_CHANNEL_ERROR,
586  * @see OSK_CHANNEL_ALL
587  * @return MALI_TRUE if the module is allowed to print on the channel.
588  */
589 #if OSK_USE_RUNTIME_CONFIG
590         #define OSKP_PRINT_IS_ALLOWED(module, channel) oskp_is_allowed_to_print( (module), (channel) )
591 #else
592         #define OSKP_PRINT_IS_ALLOWED(module, channel) MALI_TRUE
593 #endif
594
595 /**
596  * @def OSKP_SIMULATE_FAILURE_IS_ENABLED(module, feature)
597  * @brief Macro that evaluates as true if the specified feature is enabled for the given module
598  * @note If @ref OSK_USE_RUNTIME_CONFIG is disabled then this macro always evaluates as true.
599  * @param[in] module is a @ref cdbg_module
600  * @param[in] channel is one of @see OSK_CHANNEL_INFO, @see OSK_CHANNEL_WARN, @see OSK_CHANNEL_ERROR,
601  * @return MALI_TRUE if the feature is enabled
602  */
603 #if OSK_USE_RUNTIME_CONFIG
604 #define OSKP_SIMULATE_FAILURE_IS_ENABLED(module, channel) oskp_is_allowed_to_simulate_failure( (module), (channel) )
605 #else
606 #define OSKP_SIMULATE_FAILURE_IS_ENABLED(module, channel) MALI_TRUE
607 #endif
608
609 OSK_STATIC_INLINE void osk_debug_get_thread_info( u32 *thread_id, u32 *cpu_nr )
610 {
611         OSK_ASSERT( thread_id != NULL );
612         OSK_ASSERT( cpu_nr != NULL );
613
614         /* This implementation uses the PID as shown in ps listings.
615          * On 64-bit systems, this could narrow from signed 64-bit to unsigned 32-bit */
616         *thread_id = (u32)task_pid_nr(current);
617
618         /* On 64-bit systems, this could narrow from unsigned 64-bit to unsigned 32-bit */
619         *cpu_nr = (u32)task_cpu(current);
620 }
621
622
623 #endif /* _OSK_ARCH_DEBUG_H_ */
624