Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 4b32e62 | 2018-08-16 16:52:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2013-2018, 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 | |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 20 | #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE |
| 21 | void __assert(const char *file, unsigned int line, const char *assertion) |
| 22 | { |
Antonio Nino Diaz | 00086e3 | 2018-08-16 16:46:06 +0100 | [diff] [blame] | 23 | printf("ASSERT: %s:%d:%s\n", file, line, assertion); |
Antonio Nino Diaz | d587646 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 24 | backtrace("assert"); |
| 25 | (void)console_flush(); |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 26 | plat_panic_handler(); |
| 27 | } |
| 28 | #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO |
| 29 | void __assert(const char *file, unsigned int line) |
| 30 | { |
Antonio Nino Diaz | 00086e3 | 2018-08-16 16:46:06 +0100 | [diff] [blame] | 31 | printf("ASSERT: %s:%d\n", file, line); |
Antonio Nino Diaz | d587646 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 32 | backtrace("assert"); |
| 33 | (void)console_flush(); |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 34 | plat_panic_handler(); |
| 35 | } |
| 36 | #else |
| 37 | void __assert(void) |
| 38 | { |
Antonio Nino Diaz | d587646 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 39 | backtrace("assert"); |
| 40 | (void)console_flush(); |
Antonio Nino Diaz | e98fa3a | 2017-02-16 16:49:18 +0000 | [diff] [blame] | 41 | plat_panic_handler(); |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 42 | } |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 43 | #endif |