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