aboutsummaryrefslogtreecommitdiff
path: root/src/include/assert.h
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2015-02-17 17:27:23 -0800
committerPatrick Georgi <pgeorgi@google.com>2015-04-17 10:11:33 +0200
commitd82e0cf331b5f7f3122930808705030ed861b14e (patch)
tree3523b2ab5ddb2a99cb9927a68059e06e959a9795 /src/include/assert.h
parentf0d038f469b1b7aa0e22bc214be1a6c9bc554ae4 (diff)
Fix non-x86 __PRE_RAM__ assertions and add FATAL_ASSERTS Kconfig option
This patch fixes a bug that caused non-x86 boards to use the poor man's assert() version with a lot more instructions per invocation and hexadecimal line numbers in __PRE_RAM__ environments. This was really just an oversight in the ARM port... even x86 uses a proper printk() in most cases (those with CAR) and there's no reason not to do so on the generally even more flexible SRAM-based architectures. Additionally, it adds a new Kconfig option to make failed assertions and BUG() calls halt again. This seems to have been the original intention, but was commented out once out of fear that this might prevent production systems from booting. It is still a useful debugging feature though (since otherwise assertions can easily just scroll past and get overlooked), so the user should be able to decide the this based on his needs. (Also changed error messages for both to include the word "ERROR", since grepping for that is the most sophisticated way we currently have to detect firmware problems. Some automated Chromium OS suspend tests check for that.) BRANCH=veyron BUG=None TEST=Booted Jerry. Compared binary sizes before and after, new version's bootblock is some ~600 bytes smaller. Change-Id: I894da18d77e12bf104e443322e2d58e60564e4b7 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 6a5343124719c18a1c969477e3d18bda13c0bf26 Original-Change-Id: I0268cfd67d8c894406b18bb3759a577944bcffb1 Original-Signed-off-by: Julius Werner <jwerner@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/250661 Original-Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/9775 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <edward.ocallaghan@koparo.com>
Diffstat (limited to 'src/include/assert.h')
-rw-r--r--src/include/assert.h13
1 files changed, 7 insertions, 6 deletions
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 <arch/hlt.h>
#include <console/console.h>
/* 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)