diff options
author | Louis Yung-Chieh Lo <yjlou@chromium.org> | 2014-04-03 14:11:57 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-04-04 04:55:08 +0000 |
commit | 6d8276c431b9549aa1b573bbe867342a1cdbc08b (patch) | |
tree | 8fba98fd922105cf899fe5db2ec25e869b7f9746 /common | |
parent | 671b5646235374c664791acc80b6a01b87941656 (diff) | |
download | chrome-ec-6d8276c431b9549aa1b573bbe867342a1cdbc08b.tar.gz |
i8042: add a console command to dump internal state.
To help i8042 debug, add a new "8042" command. It also integrates
other 8042-related command in one place to dump all 8042 state.
Also few fixes to re-format the output.
BUG=none
BRANCH=none
TEST=Buidl and tested on squawks
Change-Id: I23d0522aa9d32b38efc864cb97217852a5ad1ea0
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193123
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/keyboard_8042.c | 95 |
1 files changed, 89 insertions, 6 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c index 7ea4bb1639..321abfecb9 100644 --- a/common/keyboard_8042.c +++ b/common/keyboard_8042.c @@ -271,6 +271,8 @@ void keyboard_host_write(int data, int is_cmd) */ static void keyboard_enable_irq(int enable) { + CPRINTF("[%T KB IRQ %s]\n", enable ? "enable" : "disable"); + i8042_irq_enabled = enable; if (enable) lpc_keyboard_resume_irq(); @@ -1011,16 +1013,16 @@ static int command_typematic(int argc, char **argv) typematic_inter_delay = strtoi(argv[2], NULL, 0) * MSEC; } - ccprintf("From host: 0x%02x\n", typematic_value_from_host); - ccprintf("First delay: %d ms\n", typematic_first_delay / 1000); - ccprintf("Inter delay: %d ms\n", typematic_inter_delay / 1000); + ccprintf("From host: 0x%02x\n", typematic_value_from_host); + ccprintf("First delay: %3d ms\n", typematic_first_delay / 1000); + ccprintf("Inter delay: %3d ms\n", typematic_inter_delay / 1000); ccprintf("Now: %.6ld\n", get_time().val); ccprintf("Deadline: %.6ld\n", typematic_deadline.val); - ccputs("Repeat scan code:"); + ccputs("Repeat scan code: {"); for (i = 0; i < typematic_len; ++i) - ccprintf(" 0x%02x", typematic_scan_code[i]); - ccputs("\n"); + ccprintf("0x%02x, ", typematic_scan_code[i]); + ccputs("}\n"); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(typematic, command_typematic, @@ -1142,6 +1144,87 @@ DECLARE_CONSOLE_COMMAND(kbd, command_keyboard, "Print or toggle keyboard info", NULL); + +static int command_8042_internal(int argc, char **argv) +{ + int i; + + ccprintf("data_port_state=%d\n", data_port_state); + ccprintf("i8042_irq_enabled=%d\n", i8042_irq_enabled); + ccprintf("keyboard_enabled=%d\n", keyboard_enabled); + ccprintf("keystroke_enabled=%d\n", keystroke_enabled); + + ccprintf("resend_command[]={"); + for (i = 0; i < resend_command_len; i++) + ccprintf("0x%02x, ", resend_command[i]); + ccprintf("}\n"); + + ccprintf("controller_ram_address=0x%02x\n", controller_ram_address); + ccprintf("A20_status=%d\n", A20_status); + + ccprintf("from_host.buf[]={"); + for (i = from_host.head; i != from_host.tail; + i = (i + 1) % from_host.buf_bytes) + ccprintf("0x%02x, ", from_host.buf[i]); + ccprintf("}\n"); + + ccprintf("to_host.buf[]={"); + for (i = to_host.head; + i != to_host.tail; + i = (i + 1) % to_host.buf_bytes) + ccprintf("0x%02x, ", to_host.buf[i]); + ccprintf("}\n"); + + return EC_SUCCESS; +} + + +static int command_8042(int argc, char **argv) +{ + if (argc >= 2) { + if (!strcasecmp(argv[1], "internal")) + return command_8042_internal(argc, argv); + else if (!strcasecmp(argv[1], "typematic")) + return command_typematic(argc - 1, argv + 1); + else if (!strcasecmp(argv[1], "codeset")) + return command_codeset(argc - 1, argv + 1); + else if (!strcasecmp(argv[1], "ctrlram")) + return command_controller_ram(argc - 1, argv + 1); + else if (!strcasecmp(argv[1], "kblog")) + return command_keyboard_log(argc - 1, argv + 1); + else if (!strcasecmp(argv[1], "kbd")) + return command_keyboard(argc - 1, argv + 1); + else + return EC_ERROR_PARAM1; + } else { + char *ctlram_argv[] = {"ctrlram", "0"}; + + ccprintf("\n- Typematic:\n"); + command_typematic(argc, argv); + ccprintf("\n- Codeset:\n"); + command_codeset(argc, argv); + ccprintf("\n- Control RAM:\n"); + command_controller_ram( + sizeof(ctlram_argv) / sizeof(ctlram_argv[0]), + ctlram_argv); + ccprintf("\n- Keyboard log:\n"); + command_keyboard_log(argc, argv); + ccprintf("\n- Keyboard:\n"); + command_keyboard(argc, argv); + ccprintf("\n- Internal:\n"); + command_8042_internal(argc, argv); + ccprintf("\n"); + } + + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(8042, command_8042, + "[internal | typematic | codeset | ctrlram |" + " kblog | kbd]", + "Print 8042 state in one place", + NULL); + + /*****************************************************************************/ /* Hooks */ |