diff --git a/src/Kconfig b/src/Kconfig index 6f7f459fc1..a6032c7d07 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -808,6 +808,12 @@ config GDB_WAIT help If enabled, coreboot will wait for a GDB connection. +config FATAL_ASSERTS + bool "Halt when hitting a BUG() or assertion error" + default n + help + If enabled, coreboot will call hlt() on a BUG() or failed ASSERT(). + config DEBUG_CBFS bool "Output verbose CBFS debug messages" default n diff --git a/src/include/assert.h b/src/include/assert.h index 966449b286..669f8e5a46 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -20,20 +20,21 @@ #ifndef __ASSERT_H__ #define __ASSERT_H__ +#include #include /* GCC and CAR versions */ #define ASSERT(x) { \ if (!(x)) { \ - printk(BIOS_EMERG, "ASSERTION FAILED: file '%s', " \ - " line %d\n", __FILE__, __LINE__); \ - /* die(""); */ \ + printk(BIOS_EMERG, "ASSERTION ERROR: file '%s'" \ + ", line %d\n", __FILE__, __LINE__); \ + if (IS_ENABLED(CONFIG_FATAL_ASSERTS)) hlt(); \ } \ } #define BUG() { \ - printk(BIOS_EMERG, "BUG ENCOUNTERED: SYSTEM HALTED at file '%s', " \ - " line %d\n", __FILE__, __LINE__); \ - /* die(""); */ \ + printk(BIOS_EMERG, "ERROR: BUG ENCOUNTERED at file '%s'"\ + ", line %d\n", __FILE__, __LINE__); \ + if (IS_ENABLED(CONFIG_FATAL_ASSERTS)) hlt(); \ } #define assert(statement) ASSERT(statement)