diff options
author | Yilun Lin <yllin@google.com> | 2019-03-11 17:41:17 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-04-18 19:52:06 -0700 |
commit | 2b452718a0b2e08fad8e0a830b443db862bf806c (patch) | |
tree | 43eb5a122ecdab194707e5fd8c7d2205d071ab31 | |
parent | 521db7dfbff864bf4fd2442a6129872b6b4ea873 (diff) | |
download | chrome-ec-2b452718a0b2e08fad8e0a830b443db862bf806c.tar.gz |
util/ectool, common/system: Share sysmbol reset_flag_desc.
There were two symbols reset_flag_desc and reset_flag_strings used
in two separated places: host binary ectool and device.
This CL combines these two symbols to reduce maintance efforts.
TEST=make buildall -j
BRANCH=None
BUG=None
Change-Id: I3b5731ab08804f46629d6e43466dce963bd86a69
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1514395
Commit-Ready: Yilun Lin <yllin@chromium.org>
Tested-by: Yilun Lin <yllin@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r-- | common/system.c | 20 | ||||
-rw-r--r-- | include/reset_flag_desc.inc | 28 | ||||
-rw-r--r-- | util/ectool.c | 41 |
3 files changed, 55 insertions, 34 deletions
diff --git a/common/system.c b/common/system.c index 813c0b6399..458798357c 100644 --- a/common/system.c +++ b/common/system.c @@ -86,16 +86,6 @@ struct jump_data { /* Jump data (at end of RAM, or preceding panic data) */ static struct jump_data *jdata; -/* - * Reset flag descriptions. Must be in same order as bits of RESET_FLAG_ - * constants. - */ -static const char * const reset_flag_descs[] = { - "other", "reset-pin", "brownout", "power-on", "watchdog", "soft", - "hibernate", "rtc-alarm", "wake-pin", "low-battery", "sysjump", - "hard", "ap-off", "preserved", "usb-resume", "rdd", "rbox", - "security", "ap-watchdog" }; - static uint32_t reset_flags; static int jumped_to_image; static int disable_jump; /* Disable ALL jumps if system is locked */ @@ -278,6 +268,9 @@ void system_print_reset_flags(void) { int count = 0; int i; + static const char * const reset_flag_descs[] = { + #include "reset_flag_desc.inc" + }; if (!reset_flags) { CPUTS("unknown"); @@ -292,6 +285,13 @@ void system_print_reset_flags(void) CPUTS(reset_flag_descs[i]); } } + + if (reset_flags >= BIT(i)) { + if (count) + CPUTS(" "); + + CPUTS("no-desc"); + } } int system_jumped_to_this_image(void) diff --git a/include/reset_flag_desc.inc b/include/reset_flag_desc.inc new file mode 100644 index 0000000000..425332b31b --- /dev/null +++ b/include/reset_flag_desc.inc @@ -0,0 +1,28 @@ +/* Copyright 2019 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. + */ + +/* + * Reset flag descriptions. Must be in same order as bits of RESET_FLAG_ + * constants. + */ +"other", +"reset-pin", +"brownout", +"power-on", +"watchdog", +"soft", +"hibernate", +"rtc-alarm", +"wake-pin", +"low-battery", +"sysjump", +"hard", +"ap-off", +"preserved", +"usb-resume", +"rdd", +"rbox", +"security", +"ap-watchdog", diff --git a/util/ectool.c b/util/ectool.c index 9d51cc7bc4..1717ae1850 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -843,33 +843,14 @@ static const char *reset_cause_to_str(uint16_t cause) int cmd_uptimeinfo(int argc, char *argv[]) { - static const char * const reset_flag_strings[] = { - "other", - "reset-pin", - "brownout", - "power-on", - "watchdog", - "soft", - "hibernate", - "rtc-alarm", - "wake-pin", - "low-battery", - "sysjump", - "hard", - "ap-off", - "preserved", - "usb-resume", - "rdd", - "rbox", - "security", - "ap-watchdog" - }; - struct ec_response_uptime_info r; int rv; int i; int flag_count; uint32_t flag; + static const char * const reset_flag_descs[] = { + #include "reset_flag_desc.inc" + }; if (argc != 1) { fprintf(stderr, "uptimeinfo takes no arguments"); @@ -901,15 +882,27 @@ int cmd_uptimeinfo(int argc, char *argv[]) } printf("EC reset flags at last EC boot: "); + + if (!r.ec_reset_flags) { + printf("unknown\n"); + return 0; + } + flag_count = 0; - for (flag = 0; flag != ARRAY_SIZE(reset_flag_strings); ++flag) { + for (flag = 0; flag < ARRAY_SIZE(reset_flag_descs); ++flag) { if ((r.ec_reset_flags & BIT(flag)) != 0) { if (flag_count) printf(" | "); - printf(reset_flag_strings[flag]); + printf(reset_flag_descs[flag]); flag_count++; } } + + if (r.ec_reset_flags >= BIT(flag)) { + if (flag_count) + printf(" | "); + printf("no-desc"); + } printf("\n"); return 0; } |