Stefan Reinauer | eca92fb | 2006-08-23 14:28:37 +0000 | [diff] [blame] | 1 | /* |
Uwe Hermann | c70e9fc | 2010-02-15 23:10:19 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Uwe Hermann | 2bb4acf | 2010-03-01 17:19:55 +0000 | [diff] [blame] | 3 | * |
Stefan Reinauer | 55259bd | 2010-02-28 18:13:09 +0000 | [diff] [blame] | 4 | * Copyright (C) 2010 coresystems GmbH |
Stefan Reinauer | eca92fb | 2006-08-23 14:28:37 +0000 | [diff] [blame] | 5 | * |
Stefan Reinauer | 55259bd | 2010-02-28 18:13:09 +0000 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
Uwe Hermann | 2bb4acf | 2010-03-01 17:19:55 +0000 | [diff] [blame] | 8 | * published by the Free Software Foundation; version 2 of the License. |
Stefan Reinauer | eca92fb | 2006-08-23 14:28:37 +0000 | [diff] [blame] | 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Stefan Reinauer | eca92fb | 2006-08-23 14:28:37 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
Stefan Reinauer | 55259bd | 2010-02-28 18:13:09 +0000 | [diff] [blame] | 16 | #ifndef __ASSERT_H__ |
| 17 | #define __ASSERT_H__ |
Uwe Hermann | c70e9fc | 2010-02-15 23:10:19 +0000 | [diff] [blame] | 18 | |
Julius Werner | d82e0cf | 2015-02-17 17:27:23 -0800 | [diff] [blame] | 19 | #include <arch/hlt.h> |
Hung-Te Lin | 34c5933 | 2014-02-21 16:22:52 +0800 | [diff] [blame] | 20 | #include <console/console.h> |
| 21 | |
Stefan Reinauer | 55259bd | 2010-02-28 18:13:09 +0000 | [diff] [blame] | 22 | /* GCC and CAR versions */ |
| 23 | #define ASSERT(x) { \ |
| 24 | if (!(x)) { \ |
Julius Werner | d82e0cf | 2015-02-17 17:27:23 -0800 | [diff] [blame] | 25 | printk(BIOS_EMERG, "ASSERTION ERROR: file '%s'" \ |
| 26 | ", line %d\n", __FILE__, __LINE__); \ |
| 27 | if (IS_ENABLED(CONFIG_FATAL_ASSERTS)) hlt(); \ |
Stefan Reinauer | 55259bd | 2010-02-28 18:13:09 +0000 | [diff] [blame] | 28 | } \ |
| 29 | } |
| 30 | #define BUG() { \ |
Julius Werner | d82e0cf | 2015-02-17 17:27:23 -0800 | [diff] [blame] | 31 | printk(BIOS_EMERG, "ERROR: BUG ENCOUNTERED at file '%s'"\ |
| 32 | ", line %d\n", __FILE__, __LINE__); \ |
| 33 | if (IS_ENABLED(CONFIG_FATAL_ASSERTS)) hlt(); \ |
Stefan Reinauer | 55259bd | 2010-02-28 18:13:09 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Hung-Te Lin | 34c5933 | 2014-02-21 16:22:52 +0800 | [diff] [blame] | 36 | #define assert(statement) ASSERT(statement) |
Uwe Hermann | 2bb4acf | 2010-03-01 17:19:55 +0000 | [diff] [blame] | 37 | |
| 38 | #endif // __ASSERT_H__ |