summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-09-04 15:41:27 -0700
committerGerrit <chrome-bot@google.com>2012-09-05 10:03:17 -0700
commit46ecb0913b39a8d1f57438c4311c031a252ae062 (patch)
tree22563473a0fce67dcb021fbd95e652c974bed8c3
parentf7291a50b8055f9ec0c69d79c2d5f2a881b53df8 (diff)
downloadchrome-ec-46ecb0913b39a8d1f57438c4311c031a252ae062.tar.gz
Add host command to get panic info
This only adds support in the EC; it doesn't add an ectool command. We'll add that later. This also fixes a bug where the reserved byte in the panic data structure wasn't being set to 0. BUG=chrome-os-partner:7466 BRANCH=all TEST=manual 1. crash unaligned -> system crashes 2. hostcmd 0xd3 -> returns a hex string 01010100...506e6321 3. hostcmd 0xd3 -> returns a hex string 01010500...506e6321 Change-Id: I1de8e19c44c835055d893986b42d152dc704c35f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/32183 Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--core/cortex-m/panic.c22
-rw-r--r--include/ec_commands.h10
2 files changed, 32 insertions, 0 deletions
diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c
index b86295d49d..5b0bff89e7 100644
--- a/core/cortex-m/panic.c
+++ b/core/cortex-m/panic.c
@@ -8,6 +8,7 @@
#include "config.h"
#include "console.h"
#include "cpu.h"
+#include "host_command.h"
#include "panic.h"
#include "system.h"
#include "task.h"
@@ -326,6 +327,7 @@ void report_panic(void)
pdata->struct_version = 1;
pdata->arch = PANIC_ARCH_CORTEX_M;
pdata->flags = 0;
+ pdata->reserved = 0;
/* If stack is valid, save exception frame */
if (psp >= CONFIG_RAM_BASE &&
@@ -479,3 +481,23 @@ DECLARE_CONSOLE_COMMAND(panicinfo, command_panicinfo,
NULL,
"Print info from a previous panic",
NULL);
+
+/*****************************************************************************/
+/* Host commands */
+
+int host_command_panic_info(struct host_cmd_handler_args *args)
+{
+ if (pdata_ptr->magic == PANIC_DATA_MAGIC) {
+ ASSERT(pdata_ptr->struct_size <= args->response_max);
+ memcpy(args->response, pdata_ptr, pdata_ptr->struct_size);
+ args->response_size = pdata_ptr->struct_size;
+
+ /* Data has now been returned */
+ pdata_ptr->flags |= PANIC_DATA_FLAG_OLD_HOSTCMD;
+ }
+
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_GET_PANIC_INFO,
+ host_command_panic_info,
+ EC_VER_MASK(0));
diff --git a/include/ec_commands.h b/include/ec_commands.h
index ecf0f1394e..b74da5e4cd 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -963,6 +963,8 @@ struct ec_params_force_idle {
*/
#define EC_CMD_CONSOLE_READ 0x98
+/*****************************************************************************/
+
/*
* Cut off battery power output if the battery supports.
*
@@ -1000,6 +1002,14 @@ struct ec_params_reboot_ec {
uint8_t flags; /* See EC_REBOOT_FLAG_* */
} __packed;
+/*
+ * Get information on last EC panic.
+ *
+ * Returns variable-length platform-dependent panic information. See panic.h
+ * for details.
+ */
+#define EC_CMD_GET_PANIC_INFO 0xd3
+
/*****************************************************************************/
/*
* ACPI commands