summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2013-08-08 09:25:58 -0700
committerChromeBot <chrome-bot@google.com>2013-08-09 10:27:07 -0700
commit9c2909ff53a591f4ccacd9e87a15ccb008ed732e (patch)
treed8562d92156080b07ae76fbcf4e0585d1259792a
parent14463a22e1f78c4641571c64856ec111194067ad (diff)
downloadchrome-ec-9c2909ff53a591f4ccacd9e87a15ccb008ed732e.tar.gz
console_output: Add commands for saving / restoring print mask.
Saving + restoring the channel print mask previously involved running the 'chan' command with no parameters, then parsing the output. This parsing is unreliable if other tasks are also writing to the console. Add commands to save / backup the current channel mask, and later restoring it. Typical method to limit channel mask will now be: chan save chan <mask> ... chan restore BUG=chromium:269758. TEST=Run 'chan save' / 'chan 0' / 'chan restore' on EC console, verify print mask is restored. BRANCH=Peppy/Falco. Change-Id: I039e521c43b9f5b9451ef99c166a390ea03b8da7 Original-Change-Id: I725c7fb5e3ac7e55ed5f435446f8fc5c54af165f Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/65208 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/65318
-rw-r--r--common/console_output.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/common/console_output.c b/common/console_output.c
index b7985883cc..385c48d0af 100644
--- a/common/console_output.c
+++ b/common/console_output.c
@@ -14,6 +14,7 @@
#define CC_DEFAULT CC_ALL
#endif
static uint32_t channel_mask = CC_DEFAULT;
+static uint32_t channel_mask_saved = CC_DEFAULT;
/* List of channel names; must match enum console_channel. */
/* TODO: move this to board.c */
@@ -82,18 +83,28 @@ static int command_ch(int argc, char **argv)
int i;
char *e;
- /* If one arg, set the mask */
+ /* If one arg, save / restore, or set the mask */
if (argc == 2) {
- int m = strtoi(argv[1], &e, 0);
- if (*e)
- return EC_ERROR_PARAM1;
-
- /* No disabling the command output channel */
- channel_mask = m | CC_MASK(CC_COMMAND);
-
- /* TODO: save channel list to EEPROM */
-
- return EC_SUCCESS;
+ if (strcasecmp(argv[1], "save") == 0) {
+ channel_mask_saved = channel_mask;
+ return EC_SUCCESS;
+ } else if (strcasecmp(argv[1], "restore") == 0) {
+ channel_mask = channel_mask_saved;
+ return EC_SUCCESS;
+
+ } else {
+ /* Set the mask */
+ int m = strtoi(argv[1], &e, 0);
+ if (*e)
+ return EC_ERROR_PARAM1;
+
+ /* No disabling the command output channel */
+ channel_mask = m | CC_MASK(CC_COMMAND);
+
+ /* TODO: save channel list to EEPROM */
+
+ return EC_SUCCESS;
+ }
}
/* Print the list of channels */
@@ -108,6 +119,6 @@ static int command_ch(int argc, char **argv)
return EC_SUCCESS;
};
DECLARE_CONSOLE_COMMAND(chan, command_ch,
- "[mask]",
- "Get or set console channel mask",
+ "[ save | restore | <mask> ]",
+ "Save, restore, get or set console channel mask",
NULL);