blob: 718f72ebfcb6f272f1a41d3dccf09e3d7e124091 [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
Stefan Reinauer55259bd2010-02-28 18:13:09 +000023#if defined(__PRE_RAM__) && !CONFIG_USE_PRINTK_IN_CAR
Stefan Reinauereca92fb2006-08-23 14:28:37 +000024
Stefan Reinauer55259bd2010-02-28 18:13:09 +000025/* ROMCC versions */
26#define ASSERT(x) { \
27 if(!(x)) { \
28 print_emerg("ASSERTION FAILED: file '"); \
29 print_emerg(__FILE__); \
30 print_emerg("', line 0x"); \
31 print_debug_hex32(__LINE__); \
Stefan Reinauer64ed2b72010-03-31 14:47:43 +000032 print_emerg("\n"); \
Stefan Reinauer55259bd2010-02-28 18:13:09 +000033 /* die(""); */ \
34 } \
35}
Stefan Reinauereca92fb2006-08-23 14:28:37 +000036
Stefan Reinauer55259bd2010-02-28 18:13:09 +000037#define BUG() { \
38 print_emerg("BUG ENCOUNTERED: SYSTEM HALTED at file '");\
39 print_emerg(__FILE__); \
40 print_emerg("', line 0x"); \
41 print_debug_hex32(__LINE__); \
Stefan Reinauer64ed2b72010-03-31 14:47:43 +000042 print_emerg("\n"); \
Stefan Reinauer55259bd2010-02-28 18:13:09 +000043 /* die(""); */ \
44}
45
Stefan Reinauereca92fb2006-08-23 14:28:37 +000046#else
Stefan Reinauereca92fb2006-08-23 14:28:37 +000047
Stefan Reinauer55259bd2010-02-28 18:13:09 +000048/* GCC and CAR versions */
49#define ASSERT(x) { \
50 if (!(x)) { \
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000051 printk(BIOS_EMERG, "ASSERTION FAILED: file '%s', " \
Stefan Reinauer55259bd2010-02-28 18:13:09 +000052 " line %d\n", __FILE__, __LINE__); \
53 /* die(""); */ \
54 } \
55}
56#define BUG() { \
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000057 printk(BIOS_EMERG, "BUG ENCOUNTERED: SYSTEM HALTED at file '%s', " \
Stefan Reinauer55259bd2010-02-28 18:13:09 +000058 " line %d\n", __FILE__, __LINE__); \
59 /* die(""); */ \
60}
61
Stefan Reinauereca92fb2006-08-23 14:28:37 +000062#endif
Uwe Hermann2bb4acf2010-03-01 17:19:55 +000063
64#endif // __ASSERT_H__