Files
OpenCellular/common/memory_commands.c
Vic Yang 5007bbc009 Use uintptr_t when converting integer from/to pointer
Perviously we use uint32_t for this, but this doesn't compile for 64-bit
environment (and likely doesn't for 16-bit either.) Use uintptr_t so that
we don't get size mismatch errors.

BUG=chrome-os-partner:19257
TEST=Run host emulated tests
BRANCH=None

Change-Id: I3cd66a745fa171c41a5f142514284ec106586acb
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50358
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-07 20:59:53 -07:00

63 lines
1.3 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 *)(uintptr_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 *)(uintptr_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);