From 9d49598cd6f323d0119d905f9917f526e0c2920f Mon Sep 17 00:00:00 2001 From: Eric Peers Date: Tue, 17 Dec 2019 10:02:15 -0700 Subject: assert.h: add assertions with descriptive failures BUG=None TEST=tested in following patches on Trembyle board Change-Id: Ib30ccd41759e5a2a61d3182cc08ed5eb762eca98 Signed-off-by: Eric Peers Reviewed-on: https://chromium-review.googlesource.com/1971443 Tested-by: Martin Roth Reviewed-by: Martin Roth Reviewed-on: https://review.coreboot.org/c/coreboot/+/39620 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth Reviewed-by: Angel Pons Reviewed-by: Raul Rangel Reviewed-by: Paul Menzel --- src/include/assert.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/include') diff --git a/src/include/assert.h b/src/include/assert.h index 8f5af1f255..990cee11b5 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -33,6 +33,17 @@ hlt(); \ } \ } + +#define ASSERT_MSG(x, msg) { \ + if (!(x)) { \ + printk(BIOS_EMERG, "ASSERTION ERROR: file '%s'" \ + ", line %d\n", __FILE__, __LINE__); \ + printk(BIOS_EMERG, "%s", msg); \ + if (CONFIG(FATAL_ASSERTS)) \ + hlt(); \ + } \ +} + #define BUG() { \ printk(BIOS_EMERG, "ERROR: BUG ENCOUNTERED at file '%s'"\ ", line %d\n", __FILE__, __LINE__); \ -- cgit v1.2.3