summaryrefslogtreecommitdiff
path: root/common/memory_commands.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-11-13 13:57:10 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-14 22:47:13 +0000
commite28b6184b117bfa3e0193ce8ed6a84b70c631c51 (patch)
treec98f4fae5916525001921a2ac5fbe04301473ac1 /common/memory_commands.c
parent399a810103839ecf990c1add90156aa49d631317 (diff)
downloadchrome-ec-e28b6184b117bfa3e0193ce8ed6a84b70c631c51.tar.gz
tweak: Allow "rw" command to read AND write memory.
It's really annoying to have to type two different commands. If I want to read a location and then write it and then read it back (which often happens when poking at hardware), then this: rw 0x40570008 rw 0x40570008 14 rw 0x40570008 is much easier to enter than this: rw 0x40570008 ww 0x40570008 14 rw 0x40570008 The "ww" command is still there, if you're really attached to it. BUG=none BRANCH=none TEST=manual Tried the example above. It worked. Change-Id: I2302ed60df3dd3ec2224afa7c32d997bd2468ec1 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/229660 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/memory_commands.c')
-rw-r--r--common/memory_commands.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/common/memory_commands.c b/common/memory_commands.c
index c8a1ea76df..3886a3ac1d 100644
--- a/common/memory_commands.c
+++ b/common/memory_commands.c
@@ -43,20 +43,34 @@ static int command_read_word(int argc, char **argv)
uint32_t value;
char *e;
- if (argc != 2)
+ if (argc < 2)
return EC_ERROR_PARAM_COUNT;
address = (uint32_t *)(uintptr_t)strtoi(argv[1], &e, 0);
if (*e)
return EC_ERROR_PARAM1;
- value = *address;
+ /* Just reading? */
+ if (argc < 3) {
+ value = *address;
+ ccprintf("read 0x%p = 0x%08x\n", address, value);
+ return EC_SUCCESS;
+ }
- ccprintf("read 0x%p = 0x%08x\n", address, value);
+ /* Writing! */
+ value = strtoi(argv[2], &e, 0);
+ if (*e)
+ return EC_ERROR_PARAM2;
+
+ ccprintf("write 0x%p = 0x%08x\n", address, value);
+ cflush(); /* Flush before writing in case this crashes */
+
+ *address = value;
return EC_SUCCESS;
+
}
DECLARE_CONSOLE_COMMAND(rw, command_read_word,
- "addr",
- "Read a word from memory",
+ "addr [value]",
+ "Read or write a word in memory",
NULL);