diff options
author | Aseda Aboagye <aaboagye@google.com> | 2015-11-12 12:02:32 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-11-26 01:39:36 -0800 |
commit | f14dd412ce2ae44ac3ad1648a447a25077dbd82f (patch) | |
tree | 6087c71a230379a515ec92ab2056a0c839f196cc /common | |
parent | 1d0785da90f97bd2a58e40a62e5280fd0a574f08 (diff) | |
download | chrome-ec-f14dd412ce2ae44ac3ad1648a447a25077dbd82f.tar.gz |
ec3po: Add compatibility for older EC images.
The EC-3PO console and interpreter could be used to talk to EC images
which do not have the necessary changes to support the new enhancements.
If this was the case, the interpreter would be very confused and the
user wouldn't be able to use the console. This commit adds
compatibility support for talking to both non-enhanced and enhanced EC
images.
When the console and interpreter are instantiated, they assume by
default that the EC image they are talking to is non-enhanced. When the
user presses the carriage return key, the console initiates an
interrogation with the EC image. The interrogation is a simple
EC_SYN(0xEC) and waits EC_INTERROGATION_TIMEOUT for the correct
EC_ACK(0xC0). Enhanced EC images will try to reply immediately to a
EC_SYN. Non-enhanced EC images will just ignore the EC_SYN as it's not a
printable character. Once the interrogation is complete, the console
will either simply pass everything forwards to the EC or provide the
console interface itself.
BUG=chrome-os-partner:46063
BRANCH=None
TEST=Enabled CONFIG_EXPERIMENTAL_CONSOLE on GLaDOS. Entered some
commands and verified console was working. Disabled
CONFIG_EXPERIMENTAL_CONSOLE on GLaDOS, reflashed, and verified console
was still working without restarting the EC-3PO console.
TEST=./util/ec3po/console_unittest.py -b
TEST=./util/ec3po/interpreter_unittest.py -b
TEST=cros lint --debug util/ec3po/console.py
TEST=cros lint --debug util/ec3po/console_unittest.py
TEST=cros lint --debug util/ec3po/interpreter.py
TEST=cros lint --debug util/ec3po/interpreter_unittest.py
Change-Id: I4f472afbdd7e898bee308c239b68ace0f4049842
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/313002
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/console.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/common/console.c b/common/console.c index d7365be189..3c23161ee6 100644 --- a/common/console.c +++ b/common/console.c @@ -21,6 +21,11 @@ #define PROMPT "> " +#ifdef CONFIG_EXPERIMENTAL_CONSOLE +#define EC_SYN 0xEC +#define EC_ACK 0xC0 +#endif /* defined(CONFIG_EXPERIMENTAL_CONSOLE) */ + /* ASCII control character; for example, CTRL('C') = ^C */ #define CTRL(c) ((c) - '@') @@ -447,6 +452,18 @@ static int handle_esc(int c) static void console_handle_char(int c) { +#ifdef CONFIG_EXPERIMENTAL_CONSOLE + /* + * If we receive a EC_SYN, we should respond immediately with a EC_ACK. + * This handshake lets the interpreter know that this is an enhanced + * image. + */ + if (c == EC_SYN) { + console_putc(EC_ACK); + return; + } +#endif /* defined(CONFIG_EXPERIMENTAL_CONSOLE) */ + /* Translate CR and CRLF to LF (newline) */ if (c == '\r') { last_rx_was_cr = 1; |