summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-02-23 15:26:11 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-24 03:08:03 +0000
commita8628526a3a4790a1890ecffc6df1d42644697c8 (patch)
treeb5ba7b6a1e708a4034ebed75fb168510c5aa75c4
parentaccd0da78954684274eb66d0d8d3a2683164e61b (diff)
downloadchrome-ec-a8628526a3a4790a1890ecffc6df1d42644697c8.tar.gz
panic: Send host event on panic detect
If a panic caused us to reboot, send a host event to notify the AP. BUG=chrome-os-partner:36985 TEST=Manual on Samus. Trigger EC panic, verify that "Panic Reset in previous boot" is seen in /var/log/eventlog. BRANCH=Samus Change-Id: Icf0d00a8cfc7aa788f3ceadd65fe3139f40df503 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/252410 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
-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