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