mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-31 11:01:19 +00:00
Additional help messages and usage are gated by CONFIG_CONSOLE_CMDHELP, so we can turn it on if there's space (adds about 3KB to image size) and turn it off when there isn't. Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=none TEST=manual 1) help 2) help list 3) help gpioset 4) gpioset -> wrong number of params 5) gpioset fred 0 -> param1 bad 6) gpioset cpu_prochot fred -> param2 bad Change-Id: Ibe99f37212020f763ebe65a068e6aa83a809a370
65 lines
1.2 KiB
C
65 lines
1.2 KiB
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* System module for Chrome EC */
|
|
|
|
#include "console.h"
|
|
#include "util.h"
|
|
|
|
|
|
static int command_write_word(int argc, char **argv)
|
|
{
|
|
volatile uint32_t *address;
|
|
uint32_t value;
|
|
char *e;
|
|
|
|
if (argc != 3)
|
|
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 */
|
|
|
|
*address = value;
|
|
|
|
return EC_SUCCESS;
|
|
}
|
|
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_PARAM_COUNT;
|
|
|
|
address = (uint32_t *)strtoi(argv[1], &e, 0);
|
|
if (*e)
|
|
return EC_ERROR_PARAM1;
|
|
|
|
value = *address;
|
|
|
|
ccprintf("read 0x%p = 0x%08x\n", address, value);
|
|
|
|
return EC_SUCCESS;
|
|
}
|
|
DECLARE_CONSOLE_COMMAND(rw, command_read_word,
|
|
"addr",
|
|
"Read a word from memory",
|
|
NULL);
|