From cef1e7fa9a1b3a098994afcdcab0143dea890047 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Wed, 3 Aug 2016 10:12:39 -0700 Subject: [PATCH] Add new "hang" option to crash command The crash command is used to intentionally invoke various failure modes in a running system. This adds one more (and cleans up the command slightly). The "crash hang" command does the same thing as "crash watchdog", except that it disables interrupts first. Some SoCs may require special handling to recover from that case. BUG=none BRANCH=none TEST=make buildall; run on Cr50 hardware Invoked all the options to the crash command, observed that the appropriate response occurred in each case (a stack trace if possible, followed by a reboot). Change-Id: I18897cfc04726e6aeda59f4c6e742d7a0037cf80 Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/366127 Reviewed-by: Vadim Bendebury --- common/panic_output.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/common/panic_output.c b/common/panic_output.c index 42dc72515c..ec80d6f4e9 100644 --- a/common/panic_output.c +++ b/common/panic_output.c @@ -166,10 +166,12 @@ static int command_crash(int argc, char **argv) int zero = 0; cflush(); - if (argc >= 3 && !strcasecmp(argv[2], "unsigned")) - ccprintf("%08x", (unsigned long)1 / zero); - else - ccprintf("%08x", (long)1 / zero); + ccprintf("%08x", (long)1 / zero); + } else if (!strcasecmp(argv[1], "udivzero")) { + int zero = 0; + + cflush(); + ccprintf("%08x", (unsigned long)1 / zero); #ifdef CONFIG_CMD_STACKOVERFLOW } else if (!strcasecmp(argv[1], "stack")) { stack_overflow_recurse(1); @@ -180,6 +182,10 @@ static int command_crash(int argc, char **argv) } else if (!strcasecmp(argv[1], "watchdog")) { while (1) ; + } else if (!strcasecmp(argv[1], "hang")) { + interrupt_disable(); + while (1) + ; } else { return EC_ERROR_PARAM1; } @@ -188,7 +194,11 @@ static int command_crash(int argc, char **argv) return EC_ERROR_UNKNOWN; } DECLARE_CONSOLE_COMMAND(crash, command_crash, - "[assert | divzero | stack | unaligned | watchdog] [options]", + "[assert | divzero | udivzero" +#ifdef CONFIG_CMD_STACKOVERFLOW + " | stack" +#endif + " | unaligned | watchdog | hang]", "Crash the system (for testing)", NULL); #endif