blob: 60f1a86605f132e62c81e1a6f39ccd118549b501 [file] [log] [blame]
Harry Liebel0f702c62013-12-17 18:19:04 +00001/*
Antonio Nino Diaz93c78ed2018-08-16 16:52:57 +01002 * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
Harry Liebel0f702c62013-12-17 18:19:04 +00003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Harry Liebel0f702c62013-12-17 18:19:04 +00005 */
6
Antonio Nino Diaz0da2fe72017-05-16 09:52:02 +01007#include <assert.h>
Antonio Nino Diaz93c78ed2018-08-16 16:52:57 +01008#include <cdefs.h>
Antonio Nino Diaz39b6cc62018-08-16 16:46:06 +01009#include <stdio.h>
Harry Liebel0f702c62013-12-17 18:19:04 +000010
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000011#include <common/debug.h>
12#include <drivers/console.h>
13#include <plat/common/platform.h>
14
Antonio Nino Diaz0da2fe72017-05-16 09:52:02 +010015/*
Antonio Nino Diaz4661abc2018-08-16 14:53:05 +010016 * 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 */
Antonio Nino Diaz0da2fe72017-05-16 09:52:02 +010019
20#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
21void __assert(const char *file, unsigned int line, const char *assertion)
Harry Liebel0f702c62013-12-17 18:19:04 +000022{
Antonio Nino Diaz39b6cc62018-08-16 16:46:06 +010023 printf("ASSERT: %s:%d:%s\n", file, line, assertion);
Antonio Nino Diaz3e530d82018-08-23 15:13:58 +010024 backtrace("assert");
25 (void)console_flush();
Antonio Nino Diaz1e09ff92017-02-16 16:49:18 +000026 plat_panic_handler();
Harry Liebel0f702c62013-12-17 18:19:04 +000027}
Antonio Nino Diaz0da2fe72017-05-16 09:52:02 +010028#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
29void __assert(const char *file, unsigned int line)
30{
Antonio Nino Diaz39b6cc62018-08-16 16:46:06 +010031 printf("ASSERT: %s:%d\n", file, line);
Antonio Nino Diaz3e530d82018-08-23 15:13:58 +010032 backtrace("assert");
33 (void)console_flush();
Antonio Nino Diaz0da2fe72017-05-16 09:52:02 +010034 plat_panic_handler();
35}
36#else
37void __assert(void)
38{
Antonio Nino Diaz3e530d82018-08-23 15:13:58 +010039 backtrace("assert");
40 (void)console_flush();
Antonio Nino Diaz0da2fe72017-05-16 09:52:02 +010041 plat_panic_handler();
42}
43#endif