1 /* 2 * Copyright (c) 2013-2019, 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 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 (void)console_flush(); 27 plat_panic_handler(); 28 } 29 #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO 30 void __dead2 __assert(const char *file, unsigned int line) 31 { 32 printf("ASSERT: %s:%d\n", file, line); 33 backtrace("assert"); 34 (void)console_flush(); 35 plat_panic_handler(); 36 } 37 #else 38 void __dead2 __assert(void) 39 { 40 backtrace("assert"); 41 (void)console_flush(); 42 plat_panic_handler(); 43 } 44 #endif 45