summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-02-13 15:29:33 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-18 04:53:51 +0000
commitd00847782480e492401ba3bc5a8a8e6f026b08ba (patch)
tree01c42b77ba518cf57e7512affcb833f0df61056f /include
parent9cb03971f6852fa03df3290e44a8451e01774755 (diff)
downloadchrome-ec-d00847782480e492401ba3bc5a8a8e6f026b08ba.tar.gz
cortex-m*: Save panicinfo on non-exception panics
Make non-exception "software" panics such as stack overflow and assert failure save a panic log. Log the panic type in r4, and misc. panic data in r5 so that panic reasons can be distinguished. BUG=chrome-os-partner:36744 TEST=Manual on samus_pd. Run 'crash divzero' then 'panicinfo' after reboot. Verify that panic info is printed with "r4 :dead6660". Trigger stack overflow, verify that panic info is printed with "r4 :dead6661". BRANCH=Samus Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I5f7a8eb0a5c2ac5799d29bb241deb24fabf38f68 Reviewed-on: https://chromium-review.googlesource.com/249912 Tested-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/config.h6
-rw-r--r--include/panic.h16
-rw-r--r--include/software_panic.h23
3 files changed, 45 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h
index 9fb9508644..5f30ba31f3 100644
--- a/include/config.h
+++ b/include/config.h
@@ -379,6 +379,12 @@
#define CONFIG_COMMON_PANIC_OUTPUT
/*
+ * Store a panic log and halt the system for a software-related reasons, such as
+ * stack overflow or assertion failure.
+ */
+#undef CONFIG_SOFTWARE_PANIC
+
+/*
* Provide the default GPIO abstraction layer.
* You want this unless you are doing a really tiny firmware.
*/
diff --git a/include/panic.h b/include/panic.h
index 74376554b6..1097029002 100644
--- a/include/panic.h
+++ b/include/panic.h
@@ -9,6 +9,8 @@
#ifndef __CROS_EC_PANIC_H
#define __CROS_EC_PANIC_H
+#include "software_panic.h"
+
#include <stdarg.h>
/* ARM Cortex-Mx registers saved on panic */
@@ -120,6 +122,20 @@ void panic(const char *msg);
*/
void panic_reboot(void);
+#ifdef CONFIG_SOFTWARE_PANIC
+/**
+ * Store a panic log and halt the system for a software-related reason, such as
+ * stack overflow or assertion failure.
+ */
+void software_panic(uint32_t panic_reason, uint32_t panic_info);
+
+/**
+ * Log a watchdog panic in the panic log. Called on the subsequent reboot after
+ * the watchdog fires.
+ */
+void panic_log_watchdog(void);
+#endif
+
/**
* Enable/disable bus fault handler
*
diff --git a/include/software_panic.h b/include/software_panic.h
new file mode 100644
index 0000000000..9dc6d5a394
--- /dev/null
+++ b/include/software_panic.h
@@ -0,0 +1,23 @@
+/* Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Software panic constants. This file must be parsable by the assembler.
+ */
+
+#ifndef __CROS_EC_SOFTWARE_PANIC_H
+#define __CROS_EC_SOFTWARE_PANIC_H
+
+/* Holds software panic reason PANIC_SW_* */
+#define SOFTWARE_PANIC_REASON_REG r4
+#define SOFTWARE_PANIC_INFO_REG r5
+
+#define PANIC_SW_BASE 0xDEAD6660
+
+/* Software panic reasons */
+#define PANIC_SW_DIV_ZERO (PANIC_SW_BASE + 0)
+#define PANIC_SW_STACK_OVERFLOW (PANIC_SW_BASE + 1)
+#define PANIC_SW_ASSERT (PANIC_SW_BASE + 3)
+#define PANIC_SW_WATCHDOG (PANIC_SW_BASE + 4)
+
+#endif /* __CROS_EC_SOFTWARE_PANIC_H */