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 | |
Claus Pedersen | 885e268 | 2022-09-12 22:42:58 +0000 | [diff] [blame] | 20 | #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO |
Masahiro Yamada | f906a44 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 21 | void __dead2 __assert(const char *file, unsigned int line) |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 22 | { |
Yann Gautier | a211fde | 2022-02-14 10:29:32 +0100 | [diff] [blame] | 23 | printf("ASSERT: %s:%u\n", file, line); |
Antonio Nino Diaz | 3e530d8 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 24 | backtrace("assert"); |
Jimmy Brisson | 831b0e9 | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 25 | console_flush(); |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 26 | plat_panic_handler(); |
27 | } | ||||
28 | #else | ||||
Masahiro Yamada | f906a44 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 29 | void __dead2 __assert(void) |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 30 | { |
Antonio Nino Diaz | 3e530d8 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 31 | backtrace("assert"); |
Jimmy Brisson | 831b0e9 | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 32 | console_flush(); |
Antonio Nino Diaz | 0da2fe7 | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 33 | plat_panic_handler(); |
34 | } | ||||
35 | #endif |