console: Add weak method to notify about death

Call weak method die_notify.

The method should be overwritten in mainboard directory to signal that
a fatal error had occurred. On boards that do share the same EC and where
the EC is capable of controlling LEDs or a buzzer the method can be
overwritten in EC directory instead.

Tested on Lenovo T500.

Change-Id: I71f8ddfc96047e8a0d39f084588db1fe2f251612
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-on: https://review.coreboot.org/19696
Reviewed-by: Martin Roth <martinroth@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Patrick Rudolph
2017-05-17 19:08:32 +02:00
committed by Nico Huber
parent c3cbe9433c
commit 4b7b18d14a
2 changed files with 17 additions and 0 deletions

View File

@ -21,10 +21,21 @@
#ifndef __ROMCC__ #ifndef __ROMCC__
#define NORETURN __attribute__((noreturn)) #define NORETURN __attribute__((noreturn))
/*
* The method should be overwritten in mainboard directory to signal that a
* fatal error had occurred. On boards that do share the same EC and where the
* EC is capable of controlling LEDs or a buzzer the method can be overwritten
* in EC directory instead.
*/
__attribute__ ((weak)) void die_notify(void)
{
}
/* Report a fatal error */ /* Report a fatal error */
void NORETURN die(const char *msg) void NORETURN die(const char *msg)
{ {
printk(BIOS_EMERG, "%s", msg); printk(BIOS_EMERG, "%s", msg);
die_notify();
halt(); halt();
} }
#endif #endif

View File

@ -42,6 +42,12 @@ void post_log_clear(void);
void mainboard_post(u8 value); void mainboard_post(u8 value);
void __attribute__((noreturn)) die(const char *msg); void __attribute__((noreturn)) die(const char *msg);
/*
* This function is weak and can be overridden to provide additional
* feedback to the user. Possible use case: Play a beep.
*/
void die_notify(void);
#define __CONSOLE_ENABLE__ \ #define __CONSOLE_ENABLE__ \
((ENV_BOOTBLOCK && IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE)) || \ ((ENV_BOOTBLOCK && IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE)) || \
(ENV_POSTCAR && IS_ENABLED(CONFIG_POSTCAR_CONSOLE)) || \ (ENV_POSTCAR && IS_ENABLED(CONFIG_POSTCAR_CONSOLE)) || \