1 /*
2  * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <assert.h>
8 #include <cdefs.h>
9 #include <stdio.h>
10 
11 #include <common/debug.h>
12 #include <drivers/console.h>
13 #include <plat/common/platform.h>
14 
15 /*
16  * Only print the output if PLAT_LOG_LEVEL_ASSERT is higher or equal to
17  * LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
18  */
19 
20 #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
__assert(const char * file,unsigned int line,const char * assertion)21 void __dead2 __assert(const char *file, unsigned int line,
22 		      const char *assertion)
23 {
24 	printf("ASSERT: %s:%d:%s\n", file, line, assertion);
25 	backtrace("assert");
26 	console_flush();
27 	plat_panic_handler();
28 }
29 #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
__assert(const char * file,unsigned int line)30 void __dead2 __assert(const char *file, unsigned int line)
31 {
32 	printf("ASSERT: %s:%d\n", file, line);
33 	backtrace("assert");
34 	console_flush();
35 	plat_panic_handler();
36 }
37 #else
__assert(void)38 void __dead2 __assert(void)
39 {
40 	backtrace("assert");
41 	console_flush();
42 	plat_panic_handler();
43 }
44 #endif
45