summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/panic_output.c14
-rw-r--r--include/ec_commands.h3
-rw-r--r--include/panic.h8
3 files changed, 22 insertions, 3 deletions
diff --git a/common/panic_output.c b/common/panic_output.c
index a2c5e56b32..4658dc6bb2 100644
--- a/common/panic_output.c
+++ b/common/panic_output.c
@@ -115,6 +115,20 @@ struct panic_data *panic_get_data(void)
return pdata_ptr->magic == PANIC_DATA_MAGIC ? pdata_ptr : NULL;
}
+static void panic_init(void)
+{
+#ifdef CONFIG_HOSTCMD_EVENTS
+ struct panic_data *addr = panic_get_data();
+
+ /* Notify host of new panic event */
+ if (addr && !(addr->flags & PANIC_DATA_FLAG_OLD_HOSTEVENT)) {
+ host_set_single_event(EC_HOST_EVENT_PANIC);
+ addr->flags |= PANIC_DATA_FLAG_OLD_HOSTEVENT;
+ }
+#endif
+}
+DECLARE_HOOK(HOOK_INIT, panic_init, HOOK_PRIO_DEFAULT);
+
#ifdef CONFIG_CMD_STACKOVERFLOW
static void stack_overflow_recurse(int n)
{
diff --git a/include/ec_commands.h b/include/ec_commands.h
index df16a557e9..d54feecbe8 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -279,6 +279,9 @@ enum host_event_code {
/* Battery Status flags have changed */
EC_HOST_EVENT_BATTERY_STATUS = 23,
+ /* EC encountered a panic, triggering a reset */
+ EC_HOST_EVENT_PANIC = 24,
+
/*
* The high bit of the event mask is not used as a host event code. If
* it reads back as set, then the entire event mask should be
diff --git a/include/panic.h b/include/panic.h
index 1097029002..122f0c317c 100644
--- a/include/panic.h
+++ b/include/panic.h
@@ -62,11 +62,13 @@ struct panic_data {
/* Flags for panic_data.flags */
/* panic_data.frame is valid */
-#define PANIC_DATA_FLAG_FRAME_VALID (1 << 0)
+#define PANIC_DATA_FLAG_FRAME_VALID (1 << 0)
/* Already printed at console */
-#define PANIC_DATA_FLAG_OLD_CONSOLE (1 << 1)
+#define PANIC_DATA_FLAG_OLD_CONSOLE (1 << 1)
/* Already returned via host command */
-#define PANIC_DATA_FLAG_OLD_HOSTCMD (1 << 2)
+#define PANIC_DATA_FLAG_OLD_HOSTCMD (1 << 2)
+/* Already reported via host event */
+#define PANIC_DATA_FLAG_OLD_HOSTEVENT (1 << 3)
/**
* Write a string to the panic reporting device