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