Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 1 | /* |
Yann Gautier | eee1959 | 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 | fa3cf0b | 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 | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | 4b32e62 | 2018-08-16 16:52:57 +0100 | [diff] [blame] | 8 | #include <cdefs.h> |
Antonio Nino Diaz | 00086e3 | 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 | e0f9063 | 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 | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 15 | /* |
Antonio Nino Diaz | 9eddb1e | 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 | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 19 | |
Claus Pedersen | 785e66c | 2022-09-12 22:42:58 +0000 | [diff] [blame] | 20 | #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO |
Masahiro Yamada | 77389b2 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 21 | void __dead2 __assert(const char *file, unsigned int line) |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 22 | { |
Yann Gautier | eee1959 | 2022-02-14 10:29:32 +0100 | [diff] [blame] | 23 | printf("ASSERT: %s:%u\n", file, line); |
Antonio Nino Diaz | d587646 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 24 | backtrace("assert"); |
Jimmy Brisson | 39f9eee | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 25 | console_flush(); |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 26 | plat_panic_handler(); |
27 | } | ||||
28 | #else | ||||
Masahiro Yamada | 77389b2 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 29 | void __dead2 __assert(void) |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 30 | { |
Antonio Nino Diaz | d587646 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 31 | backtrace("assert"); |
Jimmy Brisson | 39f9eee | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 32 | console_flush(); |
Antonio Nino Diaz | e98fa3a | 2017-02-16 16:49:18 +0000 | [diff] [blame] | 33 | plat_panic_handler(); |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 34 | } |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 35 | #endif |