g: allow idle console command in read-only mode in prod images

Being able to determine what sleep state the system is in is very
handy, and reading the state is pretty safe.

Let's declare the idle console command safe and disallow its
parameters when console is locked.

BRANCH=none
BUG=none
TEST=verified that it is possible to read the idle state when console
     is locked, but not possible to set it.

Change-Id: I97f680bf033290220a4fa7fd5a7af170736443d8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/436905
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
This commit is contained in:
Vadim Bendebury
2017-02-02 20:08:50 -08:00
parent 43298813e9
commit abef8dd8f4

View File

@@ -44,6 +44,10 @@ static int command_idle(int argc, char **argv)
int c, i;
if (argc > 1) {
if (console_is_restricted()) {
ccprintf("Console is locked, no parameters allowed\n");
return EC_ERROR_INVAL;
}
c = tolower(argv[1][0]);
for (i = 1; i < ARRAY_SIZE(idle_name); i++)
if (idle_name[i][0] == c) {
@@ -56,9 +60,9 @@ static int command_idle(int argc, char **argv)
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(idle, command_idle,
"[w|s|d]",
"Set or show the idle action: wfi, sleep, deep sleep");
DECLARE_SAFE_CONSOLE_COMMAND(idle, command_idle,
"[w|s|d]",
"Set or show the idle action: wfi, sleep, deep sleep");
static int utmi_wakeup_is_enabled(void)
{