fernly/cmd-peekpoke.c
Sean Cross f8991202c6 cmd: Use strtoul instead of _strtoul
The non-underscore one comes from vsprintf.

Signed-off-by: Sean Cross <xobs@kosagi.com>
2014-11-28 13:12:53 +08:00

41 lines
704 B
C

#include <string.h>
#include "bionic.h"
#include "memio.h"
#include "printf.h"
#include "serial.h"
int cmd_peek(int argc, char **argv)
{
uint32_t offset;
if (argc < 1) {
printf("Usage: peek [offset]\n");
return -1;
}
offset = strtoul(argv[0], NULL, 0);
printf("Value at 0x%08x: ", offset);
printf("0x%08x\n", *((volatile uint32_t *)offset));
return 0;
}
int cmd_poke(int argc, char **argv)
{
uint32_t offset;
uint32_t val;
if (argc < 2) {
printf("Usage: poke [offset] [val]\n");
return -1;
}
offset = strtoul(argv[0], NULL, 0);
val = strtoul(argv[1], NULL, 0);
printf("Setting value at 0x%08x to 0x%08x: ", offset, val);
writel(val, offset);
printf("Ok\n");
return 0;
}