From e3fa16282750c3731515b1840bfee62aae3e349e Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Mon, 6 Feb 2012 12:20:50 +0800 Subject: [PATCH] Add ctrlram command to get/set controller RAM content. BUG=none TEST=tested on bds. Change-Id: Ibfabf2c35d19c231f3ebe860877b9f4020b0f870 --- common/keyboard.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/common/keyboard.c b/common/keyboard.c index 268a824110..22facfb030 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -547,3 +547,36 @@ static int command_codeset(int argc, char **argv) return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(codeset, command_codeset); + + +static int command_controller_ram(int argc, char **argv) +{ + int index; + + if (argc >= 2) { + index = strtoi(argv[1], NULL, 0); + uart_printf("Controller RAM index = %d\n", index); + if (index >= 0x20) { + uart_printf("Index is out of range (0x00-0x1f).\n"); + return EC_ERROR_UNKNOWN; + } + + if (argc >= 3) { + controller_ram[index] = strtoi(argv[2], NULL, 0); + uart_printf("Write ctlram[%d] as 0x%02x.\n", + index, controller_ram[index]); + } else { + uart_printf("ctlram[%d] is 0x%02x.\n", + index, controller_ram[index]); + } + } else { + uart_puts("Usage: ctrlram []\n"); + uart_puts("\nGet/set controller RAM.\n\n"); + return EC_ERROR_UNKNOWN; + } + + uart_flush_output(); + + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(ctrlram, command_controller_ram);