Newer
Older
/* Modify memory.
*
* Syntax:
* mm{.b, .w, .l} {addr}
* nm{.b, .w, .l} {addr}
*/
static int
mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
ulong addr, i;
int nbytes, size;
return CMD_RET_USAGE;
#ifdef CONFIG_BOOT_RETRY_TIME
reset_cmd_timeout(); /* got a good command to get here */
#endif
/* We use the last specified parameters, unless new ones are
* entered.
*/
addr = mm_last_addr;
size = mm_last_size;
if ((flag & CMD_FLAG_REPEAT) == 0) {
/* New command specified. Check for a size specification.
* Defaults to long if no or incorrect specification.
*/
if ((size = cmd_get_data_size(argv[0], 4)) < 0)
return 1;
/* Address is specified since argc > 1
*/
addr = simple_strtoul(argv[1], NULL, 16);
addr += base_address;
}
#ifdef CONFIG_HAS_DATAFLASH
if (addr_dataflash(addr)){
puts ("Can't modify DataFlash in place. Use cp instead.\n\r");
return 0;
}
#endif
#ifdef CONFIG_BLACKFIN
if (addr_bfin_on_chip_mem(addr)) {
puts ("Can't modify L1 instruction in place. Use cp instead.\n\r");
return 0;
}
#endif
/* Print the address, followed by value. Then accept input for
* the next value. A non-converted value exits.
*/
do {
ptr = map_sysmem(addr, size);
printf(" %08x", *((uint *)ptr));
printf(" %04x", *((ushort *)ptr));
printf(" %02x", *((u_char *)ptr));
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
nbytes = readline (" ? ");
if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
/* <CR> pressed as only input, don't modify current
* location and move to next. "-" pressed will go back.
*/
if (incrflag)
addr += nbytes ? -size : size;
nbytes = 1;
#ifdef CONFIG_BOOT_RETRY_TIME
reset_cmd_timeout(); /* good enough to not time out */
#endif
}
#ifdef CONFIG_BOOT_RETRY_TIME
else if (nbytes == -2) {
break; /* timed out, exit the command */
}
#endif
else {
char *endp;
i = simple_strtoul(console_buffer, &endp, 16);
nbytes = endp - console_buffer;
if (nbytes) {
#ifdef CONFIG_BOOT_RETRY_TIME
/* good enough to not time out
*/
reset_cmd_timeout();
#endif
if (size == 4)
if (incrflag)
addr += size;
}
}
} while (nbytes);
if (ptr)
unmap_sysmem(ptr);
mm_last_addr = addr;
mm_last_size = size;
return 0;
}
#ifndef CONFIG_CRC32_VERIFY
static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
ulong addr, length;
ulong crc;
ulong *ptr;
return CMD_RET_USAGE;
addr = simple_strtoul (argv[1], NULL, 16);
length = simple_strtoul (argv[2], NULL, 16);
crc = crc32_wd (0, (const uchar *) addr, length, CHUNKSZ_CRC32);
addr, addr + length - 1, crc);
if (argc > 3) {
ptr = (ulong *) simple_strtoul (argv[3], NULL, 16);
*ptr = crc;
}
#else /* CONFIG_CRC32_VERIFY */
int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ulong addr, length;
ulong crc;
ulong *ptr;
char * const *av;
return CMD_RET_USAGE;
}
av = argv + 1;
ac = argc - 1;
if (strcmp(*av, "-v") == 0) {
verify = 1;
av++;
ac--;
if (ac < 3)
goto usage;
} else
verify = 0;
addr = simple_strtoul(*av++, NULL, 16);
addr += base_address;
length = simple_strtoul(*av++, NULL, 16);
crc = crc32_wd (0, (const uchar *) addr, length, CHUNKSZ_CRC32);
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
if (!verify) {
printf ("CRC32 for %08lx ... %08lx ==> %08lx\n",
addr, addr + length - 1, crc);
if (ac > 2) {
ptr = (ulong *) simple_strtoul (*av++, NULL, 16);
*ptr = crc;
}
} else {
vcrc = simple_strtoul(*av++, NULL, 16);
if (vcrc != crc) {
printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n",
addr, addr + length - 1, crc, vcrc);
return 1;
}
}
return 0;
}
#endif /* CONFIG_CRC32_VERIFY */
"memory modify (auto-incrementing address)",
"[.b, .w, .l] address"
#ifndef CONFIG_CRC32_VERIFY
"address count [addr]\n - compute CRC32 checksum [save at addr]"
#else /* CONFIG_CRC32_VERIFY */
U_BOOT_CMD(
"address count [addr]\n - compute CRC32 checksum [save at addr]\n"
"-v address count crc\n - verify crc of memory area"
);
#endif /* CONFIG_CRC32_VERIFY */
#ifdef CONFIG_CMD_MEMINFO
__weak void board_show_dram(ulong size)
{
puts("DRAM: ");
print_size(size, "\n");
}
static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
board_show_dram(gd->ram_size);
return 0;
}
#endif
"base off\n - set address offset for memory commands to 'off'"
#ifdef CONFIG_LOOPW
U_BOOT_CMD(
"[.b, .w, .l] address number_of_objects data_to_write"
);
#endif /* CONFIG_LOOPW */
"simple RAM read/write test",
"[start [end [pattern [iterations]]]]"
#ifdef CONFIG_MX_CYCLIC
U_BOOT_CMD(
);
U_BOOT_CMD(
);
#endif /* CONFIG_MX_CYCLIC */
#ifdef CONFIG_CMD_MEMINFO
U_BOOT_CMD(
meminfo, 3, 1, do_mem_info,
"display memory information",
""
);
#endif