libpayload: Add a new "die" function to fatally signal programming errors

Hardware / Coreboot - Gabe Black [google.com] - 15 September 2014 10:37 UTC

If a programming error is detected, die can be used to print a message and stop execution similar to failing an assert. There's also a "die_if" function which is conditional.

die functions, like asserts, should be used to trap programming errors and not when the hardware does something wrong. If all code was written perfectly, no die function would ever be called. In other words, it would be appropriate to use die if a function was called with a value that was out of bounds or if malloc failed. It wouldn't be appropriate if an external device doesn't respond.

In the future, the die family of functions might print a stack trace or show other debugging info.

Old-Change-Id: I653fc8cb0b4e459522f1b86f7fac280836d57916

7c7b5ff libpayload: Add a new "die" function to fatally signal programming errors.
payloads/libpayload/include/die.h | 45 ++++++++++++++++++++++++++++++
payloads/libpayload/include/endian.h | 39 +++++++++++++++-----------
payloads/libpayload/include/ipchksum.h | 39 +++++++++++++++-----------
payloads/libpayload/include/libpayload.h | 1 +
payloads/libpayload/libc/Makefile.inc | 1 +
payloads/libpayload/libc/die.c | 42 ++++++++++++++++++++++++++++
6 files changed, 135 insertions(+), 32 deletions(-)

Upstream: review.coreboot.org


  • Share