summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-06-28 10:53:26 +0800
committerChromeBot <chrome-bot@google.com>2013-07-10 11:16:18 -0700
commit01ed345ebd7a5928298d52afbd8358c55b816c08 (patch)
tree2e68708df85bfc29f67ff9f666083d25e2f17232 /util
parentd67f83a63cc0a03994a2cc5c0565c7b51f773816 (diff)
downloadchrome-ec-01ed345ebd7a5928298d52afbd8358c55b816c08.tar.gz
Uprev panic data struct version
The struct was changed in commit 74c34bbad, but the struct version was left as 1. We need to uprev this so the data returned by host command is useful. BUG=chrome-os-partner:16901 chrome-os-partner:20548 TEST='ectool panicinfo' with new and old struct. Compare output with output from console command 'panicinfo'. BRANCH=None Change-Id: I4df3142497dc5ee21d100c4cb8118fb7a0ce7a7e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60314 Reviewed-by: Daisuke Nojiri <dnojiri@google.com>
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 702f8298b3..eafe2e5d93 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -1604,8 +1604,13 @@ int cmd_panic_info(int argc, char *argv[])
struct panic_data *pdata = (struct panic_data *)ec_inbuf;
const uint32_t *lregs = pdata->regs;
const uint32_t *sregs = NULL;
- int in_handler;
+ enum {
+ ORIG_UNKNOWN = 0,
+ ORIG_PROCESS,
+ ORIG_HANDLER
+ } origin = ORIG_UNKNOWN;
int i;
+ const char *panic_origins[3] = {"", "PROCESS", "HANDLER"};
rv = ec_command(EC_CMD_GET_PANIC_INFO, 0, NULL, 0,
ec_inbuf, ec_max_insize);
@@ -1617,17 +1622,34 @@ int cmd_panic_info(int argc, char *argv[])
return 0;
}
+ /*
+ * We only understand panic data with version <= 2. Warn the user
+ * of higher versions.
+ */
+ if (pdata->struct_version > 2)
+ fprintf(stderr,
+ "Unknown panic data version (%d). "
+ "Following data may be incorrect!\n",
+ pdata->struct_version);
+
printf("Saved panic data:%s\n",
(pdata->flags & PANIC_DATA_FLAG_OLD_HOSTCMD ? "" : " (NEW)"));
- in_handler = ((pdata->regs[11] & 0xf) == 1 ||
- (pdata->regs[11] & 0xf) == 9);
+ if (pdata->struct_version == 2)
+ origin = ((lregs[11] & 0xf) == 1 || (lregs[11] & 0xf) == 9) ?
+ ORIG_HANDLER : ORIG_PROCESS;
+ /*
+ * In pdata struct, 'regs', which is allocated before 'frame', has
+ * one less elements in version 1. Therefore, if the data is from
+ * version 1, shift 'sregs' by one element to align with 'frame' in
+ * version 1.
+ */
if (pdata->flags & PANIC_DATA_FLAG_FRAME_VALID)
- sregs = pdata->frame;
+ sregs = pdata->frame - (pdata->struct_version == 1 ? 1 : 0);
printf("=== %s EXCEPTION: %02x ====== xPSR: %08x ===\n",
- in_handler ? "HANDLER" : "PROCESS",
+ panic_origins[origin],
lregs[1] & 0xff, sregs ? sregs[7] : -1);
for (i = 0; i < 4; ++i)
print_panic_reg(i, sregs, i);
@@ -1636,7 +1658,7 @@ int cmd_panic_info(int argc, char *argv[])
print_panic_reg(10, lregs, 9);
print_panic_reg(11, lregs, 10);
print_panic_reg(12, sregs, 4);
- print_panic_reg(13, lregs, in_handler ? 2 : 0);
+ print_panic_reg(13, lregs, origin == ORIG_HANDLER ? 2 : 0);
print_panic_reg(14, sregs, 5);
print_panic_reg(15, sregs, 6);