blob: c199de6f73006194e12f75c5e3d6deba4a31c97a [file] [log] [blame]
Harry Liebel0f702c62013-12-17 18:19:04 +00001/*
Yann Gautiereee19592022-02-14 10:29:32 +01002 * Copyright (c) 2013-2022, 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 Diaz00086e32018-08-16 16:46:06 +01009#include <stdio.h>
Harry Liebel0f702c62013-12-17 18:19:04 +000010
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#include <common/debug.h>
12#include <drivers/console.h>
13#include <plat/common/platform.h>
14
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010015/*
Antonio Nino Diaz9eddb1e2018-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 Diaze3962d02017-02-16 16:17:19 +000019
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010020#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
Masahiro Yamada77389b22019-07-26 20:21:39 +090021void __dead2 __assert(const char *file, unsigned int line,
22 const char *assertion)
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010023{
Yann Gautiereee19592022-02-14 10:29:32 +010024 printf("ASSERT: %s:%u:%s\n", file, line, assertion);
Antonio Nino Diazd5876462018-08-23 15:13:58 +010025 backtrace("assert");
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050026 console_flush();
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010027 plat_panic_handler();
28}
29#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
Masahiro Yamada77389b22019-07-26 20:21:39 +090030void __dead2 __assert(const char *file, unsigned int line)
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010031{
Yann Gautiereee19592022-02-14 10:29:32 +010032 printf("ASSERT: %s:%u\n", file, line);
Antonio Nino Diazd5876462018-08-23 15:13:58 +010033 backtrace("assert");
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050034 console_flush();
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010035 plat_panic_handler();
36}
37#else
Masahiro Yamada77389b22019-07-26 20:21:39 +090038void __dead2 __assert(void)
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010039{
Antonio Nino Diazd5876462018-08-23 15:13:58 +010040 backtrace("assert");
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050041 console_flush();
Antonio Nino Diaze98fa3a2017-02-16 16:49:18 +000042 plat_panic_handler();
Harry Liebel0f702c62013-12-17 18:19:04 +000043}
Antonio Nino Diaz11a6e9d2017-05-16 09:52:02 +010044#endif