Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 1 | /* |
Yann Gautier | a211fde | 2022-02-14 10:29:32 +0100 | [diff] [blame^] | 2 | * Copyright (c) 2013-2022, ARM Limited and Contributors. All rights reserved. |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 3 | * |
dp-arm | 82cb2c1 | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | 93c78ed | 2018-08-16 16:52:57 +0100 | [diff] [blame] | 8 | #include <cdefs.h> |
Antonio Nino Diaz | 39b6cc6 | 2018-08-16 16:46:06 +0100 | [diff] [blame] | 9 | #include <stdio.h> |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 10 | |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <common/debug.h> |
| 12 | #include <drivers/console.h> |
| 13 | #include <plat/common/platform.h> |
| 14 | |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 15 | /* |
Antonio Nino Diaz | 4661abc | 2018-08-16 14:53:05 +0100 | [diff] [blame] | 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 | */ |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 19 | |
| 20 | #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE |
Masahiro Yamada | f906a44 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 21 | void __dead2 __assert(const char *file, unsigned int line, |
| 22 | const char *assertion) |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 23 | { |
Yann Gautier | a211fde | 2022-02-14 10:29:32 +0100 | [diff] [blame^] | 24 | printf("ASSERT: %s:%u:%s\n", file, line, assertion); |
Antonio Nino Diaz | 3e530d8 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 25 | backtrace("assert"); |
Jimmy Brisson | 831b0e9 | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 26 | console_flush(); |
Antonio Nino Diaz | 1e09ff9 | 2017-02-16 16:49:18 +0000 | [diff] [blame] | 27 | plat_panic_handler(); |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 28 | } |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 29 | #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO |
Masahiro Yamada | f906a44 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 30 | void __dead2 __assert(const char *file, unsigned int line) |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 31 | { |
Yann Gautier | a211fde | 2022-02-14 10:29:32 +0100 | [diff] [blame^] | 32 | printf("ASSERT: %s:%u\n", file, line); |
Antonio Nino Diaz | 3e530d8 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 33 | backtrace("assert"); |
Jimmy Brisson | 831b0e9 | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 34 | console_flush(); |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 35 | plat_panic_handler(); |
| 36 | } |
| 37 | #else |
Masahiro Yamada | f906a44 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 38 | void __dead2 __assert(void) |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 39 | { |
Antonio Nino Diaz | 3e530d8 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 40 | backtrace("assert"); |
Jimmy Brisson | 831b0e9 | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 41 | console_flush(); |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 42 | plat_panic_handler(); |
| 43 | } |
| 44 | #endif |