summaryrefslogtreecommitdiff
path: root/common/memory_commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/memory_commands.c')
-rw-r--r--common/memory_commands.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/common/memory_commands.c b/common/memory_commands.c
index a313379e86..46df50e74d 100644
--- a/common/memory_commands.c
+++ b/common/memory_commands.c
@@ -13,11 +13,18 @@ static int command_write_word(int argc, char **argv)
{
volatile uint32_t *address;
uint32_t value;
+ char *e;
if (argc != 3)
- return EC_ERROR_INVAL;
- address = (uint32_t*)strtoi(argv[1], NULL, 0);
- value = strtoi(argv[2], NULL, 0);
+ return EC_ERROR_PARAM_COUNT;
+
+ address = (uint32_t *)strtoi(argv[1], &e, 0);
+ if (*e)
+ return EC_ERROR_PARAM1;
+
+ 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 */
@@ -26,24 +33,32 @@ static int command_write_word(int argc, char **argv)
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(ww, command_write_word);
-DECLARE_CONSOLE_COMMAND(writeword, command_write_word);
+DECLARE_CONSOLE_COMMAND(ww, command_write_word,
+ "addr value",
+ "Write a word to memory",
+ NULL);
static int command_read_word(int argc, char **argv)
{
volatile uint32_t *address;
uint32_t value;
+ char *e;
if (argc != 2)
- return EC_ERROR_INVAL;
+ return EC_ERROR_PARAM_COUNT;
+
+ address = (uint32_t *)strtoi(argv[1], &e, 0);
+ if (*e)
+ return EC_ERROR_PARAM1;
- address = (uint32_t*)strtoi(argv[1], NULL, 0);
value = *address;
ccprintf("read 0x%p = 0x%08x\n", address, value);
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(rw, command_read_word);
-DECLARE_CONSOLE_COMMAND(readword, command_read_word);
+DECLARE_CONSOLE_COMMAND(rw, command_read_word,
+ "addr",
+ "Read a word from memory",
+ NULL);