blob: 198538974ff232fed1e8e2b8e22e7b707de5a0e0 [file] [log] [blame]
Stefan Reinauereca92fb2006-08-23 14:28:37 +00001/*
Uwe Hermannc70e9fc2010-02-15 23:10:19 +00002 * This file is part of the coreboot project.
Uwe Hermann2bb4acf2010-03-01 17:19:55 +00003 *
Stefan Reinauer55259bd2010-02-28 18:13:09 +00004 * Copyright (C) 2010 coresystems GmbH
Stefan Reinauereca92fb2006-08-23 14:28:37 +00005 *
Stefan Reinauer55259bd2010-02-28 18:13:09 +00006 * 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 Hermann2bb4acf2010-03-01 17:19:55 +00008 * published by the Free Software Foundation; version 2 of the License.
Stefan Reinauereca92fb2006-08-23 14:28:37 +00009 *
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 Reinauereca92fb2006-08-23 14:28:37 +000014 */
15
Stefan Reinauer55259bd2010-02-28 18:13:09 +000016#ifndef __ASSERT_H__
17#define __ASSERT_H__
Uwe Hermannc70e9fc2010-02-15 23:10:19 +000018
Julius Wernerd82e0cf2015-02-17 17:27:23 -080019#include <arch/hlt.h>
Hung-Te Lin34c59332014-02-21 16:22:52 +080020#include <console/console.h>
21
Stefan Reinauer55259bd2010-02-28 18:13:09 +000022/* GCC and CAR versions */
23#define ASSERT(x) { \
24 if (!(x)) { \
Julius Wernerd82e0cf2015-02-17 17:27:23 -080025 printk(BIOS_EMERG, "ASSERTION ERROR: file '%s'" \
26 ", line %d\n", __FILE__, __LINE__); \
27 if (IS_ENABLED(CONFIG_FATAL_ASSERTS)) hlt(); \
Stefan Reinauer55259bd2010-02-28 18:13:09 +000028 } \
29}
30#define BUG() { \
Julius Wernerd82e0cf2015-02-17 17:27:23 -080031 printk(BIOS_EMERG, "ERROR: BUG ENCOUNTERED at file '%s'"\
32 ", line %d\n", __FILE__, __LINE__); \
33 if (IS_ENABLED(CONFIG_FATAL_ASSERTS)) hlt(); \
Stefan Reinauer55259bd2010-02-28 18:13:09 +000034}
35
Hung-Te Lin34c59332014-02-21 16:22:52 +080036#define assert(statement) ASSERT(statement)
Uwe Hermann2bb4acf2010-03-01 17:19:55 +000037
38#endif // __ASSERT_H__