blob: 9f624a931f7c93b14866405c1e539ab8180f872c [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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Uwe Hermann2bb4acf2010-03-01 17:19:55 +000017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Stefan Reinauereca92fb2006-08-23 14:28:37 +000018 */
19
Stefan Reinauer55259bd2010-02-28 18:13:09 +000020#ifndef __ASSERT_H__
21#define __ASSERT_H__
Uwe Hermannc70e9fc2010-02-15 23:10:19 +000022
Hung-Te Lin34c59332014-02-21 16:22:52 +080023#include <console/console.h>
24
Stefan Reinauer704b5962010-08-30 17:53:13 +000025#if defined(__PRE_RAM__) && !CONFIG_CACHE_AS_RAM
Stefan Reinauereca92fb2006-08-23 14:28:37 +000026
Stefan Reinauer55259bd2010-02-28 18:13:09 +000027/* ROMCC versions */
28#define ASSERT(x) { \
29 if(!(x)) { \
30 print_emerg("ASSERTION FAILED: file '"); \
31 print_emerg(__FILE__); \
32 print_emerg("', line 0x"); \
33 print_debug_hex32(__LINE__); \
Stefan Reinauer64ed2b72010-03-31 14:47:43 +000034 print_emerg("\n"); \
Stefan Reinauer55259bd2010-02-28 18:13:09 +000035 /* die(""); */ \
36 } \
37}
Stefan Reinauereca92fb2006-08-23 14:28:37 +000038
Stefan Reinauer55259bd2010-02-28 18:13:09 +000039#define BUG() { \
40 print_emerg("BUG ENCOUNTERED: SYSTEM HALTED at file '");\
41 print_emerg(__FILE__); \
42 print_emerg("', line 0x"); \
43 print_debug_hex32(__LINE__); \
Stefan Reinauer64ed2b72010-03-31 14:47:43 +000044 print_emerg("\n"); \
Stefan Reinauer55259bd2010-02-28 18:13:09 +000045 /* die(""); */ \
46}
47
Stefan Reinauereca92fb2006-08-23 14:28:37 +000048#else
Stefan Reinauereca92fb2006-08-23 14:28:37 +000049
Stefan Reinauer55259bd2010-02-28 18:13:09 +000050/* GCC and CAR versions */
51#define ASSERT(x) { \
52 if (!(x)) { \
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000053 printk(BIOS_EMERG, "ASSERTION FAILED: file '%s', " \
Stefan Reinauer55259bd2010-02-28 18:13:09 +000054 " line %d\n", __FILE__, __LINE__); \
55 /* die(""); */ \
56 } \
57}
58#define BUG() { \
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000059 printk(BIOS_EMERG, "BUG ENCOUNTERED: SYSTEM HALTED at file '%s', " \
Stefan Reinauer55259bd2010-02-28 18:13:09 +000060 " line %d\n", __FILE__, __LINE__); \
61 /* die(""); */ \
62}
63
Hung-Te Lin34c59332014-02-21 16:22:52 +080064#endif /* defined(__PRE_RAM__) && !CONFIG_CACHE_AS_RAM */
65
66#define assert(statement) ASSERT(statement)
Uwe Hermann2bb4acf2010-03-01 17:19:55 +000067
68#endif // __ASSERT_H__