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 | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 9 | #include <console.h> |
Soby Mathew | afe7e2f | 2014-06-12 17:23:58 +0100 | [diff] [blame] | 10 | #include <debug.h> |
Antonio Nino Diaz | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 11 | #include <platform.h> |
Antonio Nino Diaz | 00086e3 | 2018-08-16 16:46:06 +0100 | [diff] [blame] | 12 | #include <stdio.h> |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 13 | |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 14 | /* |
Antonio Nino Diaz | 9eddb1e | 2018-08-16 14:53:05 +0100 | [diff] [blame] | 15 | * Only print the output if PLAT_LOG_LEVEL_ASSERT is higher or equal to |
| 16 | * LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1. |
| 17 | */ |
Antonio Nino Diaz | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 18 | |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 19 | #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE |
| 20 | void __assert(const char *file, unsigned int line, const char *assertion) |
| 21 | { |
Antonio Nino Diaz | 00086e3 | 2018-08-16 16:46:06 +0100 | [diff] [blame] | 22 | printf("ASSERT: %s:%d:%s\n", file, line, assertion); |
Antonio Nino Diaz | d587646 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 23 | backtrace("assert"); |
| 24 | (void)console_flush(); |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 25 | plat_panic_handler(); |
| 26 | } |
| 27 | #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO |
| 28 | void __assert(const char *file, unsigned int line) |
| 29 | { |
Antonio Nino Diaz | 00086e3 | 2018-08-16 16:46:06 +0100 | [diff] [blame] | 30 | printf("ASSERT: %s:%d\n", file, line); |
Antonio Nino Diaz | d587646 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 31 | backtrace("assert"); |
| 32 | (void)console_flush(); |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 33 | plat_panic_handler(); |
| 34 | } |
| 35 | #else |
| 36 | void __assert(void) |
| 37 | { |
Antonio Nino Diaz | d587646 | 2018-08-23 15:13:58 +0100 | [diff] [blame] | 38 | backtrace("assert"); |
| 39 | (void)console_flush(); |
Antonio Nino Diaz | e98fa3a | 2017-02-16 16:49:18 +0000 | [diff] [blame] | 40 | plat_panic_handler(); |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 41 | } |
Antonio Nino Diaz | 11a6e9d | 2017-05-16 09:52:02 +0100 | [diff] [blame] | 42 | #endif |