blob: 8fa8f72123652e35c1f1100ad866d93859098c19 [file] [log] [blame]
Harry Liebel0f702c62013-12-17 18:19:04 +00001/*
Antonio Nino Diaz4b32e622018-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-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Harry Liebel0f702c62013-12-17 18:19:04 +00005 */
6
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +01007#include <assert.h>
Antonio Nino Diaz4b32e622018-08-16 16:52:57 +01008#include <cdefs.h>
Antonio Nino Diaze3962d02017-02-16 16:17:19 +00009#include <console.h>
Soby Mathewafe7e2f2014-06-12 17:23:58 +010010#include <debug.h>
Antonio Nino Diaze3962d02017-02-16 16:17:19 +000011#include <platform.h>
Antonio Nino Diaz00086e32018-08-16 16:46:06 +010012#include <stdio.h>
Harry Liebel0f702c62013-12-17 18:19:04 +000013
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010014/*
Antonio Nino Diaz9eddb1e2018-08-16 14:53:05 +010015 * Only print the output if PLAT_LOG_LEVEL_ASSERT is higher or equal to
16 * LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
17 */
Antonio Nino Diaze3962d02017-02-16 16:17:19 +000018
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010019#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
20void __assert(const char *file, unsigned int line, const char *assertion)
21{
Antonio Nino Diaz00086e32018-08-16 16:46:06 +010022 printf("ASSERT: %s:%d:%s\n", file, line, assertion);
Antonio Nino Diazd5876462018-08-23 15:13:58 +010023 backtrace("assert");
24 (void)console_flush();
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010025 plat_panic_handler();
26}
27#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
28void __assert(const char *file, unsigned int line)
29{
Antonio Nino Diaz00086e32018-08-16 16:46:06 +010030 printf("ASSERT: %s:%d\n", file, line);
Antonio Nino Diazd5876462018-08-23 15:13:58 +010031 backtrace("assert");
32 (void)console_flush();
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010033 plat_panic_handler();
34}
35#else
36void __assert(void)
37{
Antonio Nino Diazd5876462018-08-23 15:13:58 +010038 backtrace("assert");
39 (void)console_flush();
Antonio Nino Diaze98fa3a2017-02-16 16:49:18 +000040 plat_panic_handler();
Harry Liebel0f702c62013-12-17 18:19:04 +000041}
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010042#endif