Blame view
cmd/mem.c
26.5 KB
3863585bb Initial revision |
1 2 3 4 |
/* * (C) Copyright 2000 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * |
1a4596601 Add GPL-2.0+ SPDX... |
5 |
* SPDX-License-Identifier: GPL-2.0+ |
3863585bb Initial revision |
6 7 8 9 10 11 12 13 14 |
*/ /* * Memory Functions * * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) */ #include <common.h> |
24b852a7a Move console defi... |
15 |
#include <console.h> |
0098e179e Move bootretry co... |
16 |
#include <bootretry.h> |
18d66533a move CLI prototyp... |
17 |
#include <cli.h> |
3863585bb Initial revision |
18 |
#include <command.h> |
24b852a7a Move console defi... |
19 |
#include <console.h> |
d20a40de9 Roll crc32 into h... |
20 |
#include <hash.h> |
e48f3741c sandbox: Fix warn... |
21 |
#include <inttypes.h> |
0eb25b619 common: Make sure... |
22 |
#include <mapmem.h> |
a6e6fc610 Added watchdog tr... |
23 |
#include <watchdog.h> |
0628ab8ec sandbox: Change m... |
24 |
#include <asm/io.h> |
15a33e49d Add option to dis... |
25 26 27 |
#include <linux/compiler.h> DECLARE_GLOBAL_DATA_PTR; |
3863585bb Initial revision |
28 |
|
8e169cc94 Move CONFIG_SYS_M... |
29 30 31 |
#ifndef CONFIG_SYS_MEMTEST_SCRATCH #define CONFIG_SYS_MEMTEST_SCRATCH 0 #endif |
54841ab50 Make sure that ar... |
32 |
static int mod_mem(cmd_tbl_t *, int, int, int, char * const []); |
3863585bb Initial revision |
33 34 35 36 |
/* Display values from last command. * Memory modify remembered values are different from display memory. */ |
581508bdf cmd_mem: Store la... |
37 38 39 |
static ulong dp_last_addr, dp_last_size; static ulong dp_last_length = 0x40; static ulong mm_last_addr, mm_last_size; |
3863585bb Initial revision |
40 41 42 43 44 45 |
static ulong base_address = 0; /* Memory Display * * Syntax: |
4d1fd7f1a Add 64-bit data s... |
46 |
* md{.b, .w, .l, .q} {addr} {len} |
3863585bb Initial revision |
47 48 |
*/ #define DISP_LINE_LEN 16 |
088f1b199 common/cmd_*.c: s... |
49 |
static int do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
50 |
{ |
c68c03f52 Drop CONFIG_HAS_D... |
51 52 |
ulong addr, length, bytes; const void *buf; |
27b207fd0 * Implement new m... |
53 |
int size; |
3863585bb Initial revision |
54 55 56 57 58 59 60 61 |
int rc = 0; /* We use the last specified parameters, unless new ones are * entered. */ addr = dp_last_addr; size = dp_last_size; length = dp_last_length; |
47e26b1bf cmd_usage(): simp... |
62 |
if (argc < 2) |
4c12eeb8b Convert cmd_usage... |
63 |
return CMD_RET_USAGE; |
3863585bb Initial revision |
64 65 66 67 68 |
if ((flag & CMD_FLAG_REPEAT) == 0) { /* New command specified. Check for a size specification. * Defaults to long if no or incorrect specification. */ |
27b207fd0 * Implement new m... |
69 70 |
if ((size = cmd_get_data_size(argv[0], 4)) < 0) return 1; |
3863585bb Initial revision |
71 72 73 74 75 76 77 78 79 80 81 82 |
/* Address is specified since argc > 1 */ addr = simple_strtoul(argv[1], NULL, 16); addr += base_address; /* If another parameter, it is the length to display. * Length is the number of objects, not number of bytes. */ if (argc > 2) length = simple_strtoul(argv[2], NULL, 16); } |
c68c03f52 Drop CONFIG_HAS_D... |
83 84 |
bytes = size * length; buf = map_sysmem(addr, bytes); |
0628ab8ec sandbox: Change m... |
85 |
|
c68c03f52 Drop CONFIG_HAS_D... |
86 87 88 89 |
/* Print the lines. */ print_buffer(addr, buf, size, length, DISP_LINE_LEN / size); addr += bytes; unmap_sysmem(buf); |
3863585bb Initial revision |
90 91 92 93 94 95 |
dp_last_addr = addr; dp_last_length = length; dp_last_size = size; return (rc); } |
088f1b199 common/cmd_*.c: s... |
96 |
static int do_mem_mm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
97 98 99 |
{ return mod_mem (cmdtp, 1, flag, argc, argv); } |
088f1b199 common/cmd_*.c: s... |
100 |
static int do_mem_nm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
101 102 103 |
{ return mod_mem (cmdtp, 0, flag, argc, argv); } |
088f1b199 common/cmd_*.c: s... |
104 |
static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
105 |
{ |
4d1fd7f1a Add 64-bit data s... |
106 107 108 109 110 111 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA u64 writeval; #else ulong writeval; #endif ulong addr, count; |
27b207fd0 * Implement new m... |
112 |
int size; |
cc5e196e0 Correct map_sysme... |
113 |
void *buf, *start; |
0628ab8ec sandbox: Change m... |
114 |
ulong bytes; |
3863585bb Initial revision |
115 |
|
47e26b1bf cmd_usage(): simp... |
116 |
if ((argc < 3) || (argc > 4)) |
4c12eeb8b Convert cmd_usage... |
117 |
return CMD_RET_USAGE; |
3863585bb Initial revision |
118 119 120 |
/* Check for size specification. */ |
27b207fd0 * Implement new m... |
121 122 |
if ((size = cmd_get_data_size(argv[0], 4)) < 1) return 1; |
3863585bb Initial revision |
123 124 125 126 127 128 129 130 |
/* Address is specified since argc > 1 */ addr = simple_strtoul(argv[1], NULL, 16); addr += base_address; /* Get the value to write. */ |
4d1fd7f1a Add 64-bit data s... |
131 132 133 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA writeval = simple_strtoull(argv[2], NULL, 16); #else |
3863585bb Initial revision |
134 |
writeval = simple_strtoul(argv[2], NULL, 16); |
4d1fd7f1a Add 64-bit data s... |
135 |
#endif |
3863585bb Initial revision |
136 137 138 139 140 141 142 |
/* Count ? */ if (argc == 4) { count = simple_strtoul(argv[3], NULL, 16); } else { count = 1; } |
0628ab8ec sandbox: Change m... |
143 |
bytes = size * count; |
cc5e196e0 Correct map_sysme... |
144 145 |
start = map_sysmem(addr, bytes); buf = start; |
3863585bb Initial revision |
146 147 |
while (count-- > 0) { if (size == 4) |
76698b4e6 Fix memory comman... |
148 |
*((u32 *)buf) = (u32)writeval; |
4d1fd7f1a Add 64-bit data s... |
149 150 151 152 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA else if (size == 8) *((u64 *)buf) = (u64)writeval; #endif |
3863585bb Initial revision |
153 |
else if (size == 2) |
76698b4e6 Fix memory comman... |
154 |
*((u16 *)buf) = (u16)writeval; |
3863585bb Initial revision |
155 |
else |
76698b4e6 Fix memory comman... |
156 |
*((u8 *)buf) = (u8)writeval; |
0628ab8ec sandbox: Change m... |
157 |
buf += size; |
3863585bb Initial revision |
158 |
} |
cc5e196e0 Correct map_sysme... |
159 |
unmap_sysmem(start); |
3863585bb Initial revision |
160 161 |
return 0; } |
4aaf29b2f memory commands "... |
162 |
#ifdef CONFIG_MX_CYCLIC |
5a8608e58 cmd_mem: add stat... |
163 |
static int do_mem_mdc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
4aaf29b2f memory commands "... |
164 165 166 |
{ int i; ulong count; |
47e26b1bf cmd_usage(): simp... |
167 |
if (argc < 4) |
4c12eeb8b Convert cmd_usage... |
168 |
return CMD_RET_USAGE; |
4aaf29b2f memory commands "... |
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
count = simple_strtoul(argv[3], NULL, 10); for (;;) { do_mem_md (NULL, 0, 3, argv); /* delay for <count> ms... */ for (i=0; i<count; i++) udelay (1000); /* check for ctrl-c to abort... */ if (ctrlc()) { puts("Abort "); return 0; } } return 0; } |
5a8608e58 cmd_mem: add stat... |
189 |
static int do_mem_mwc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
4aaf29b2f memory commands "... |
190 191 192 |
{ int i; ulong count; |
47e26b1bf cmd_usage(): simp... |
193 |
if (argc < 4) |
4c12eeb8b Convert cmd_usage... |
194 |
return CMD_RET_USAGE; |
4aaf29b2f memory commands "... |
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
count = simple_strtoul(argv[3], NULL, 10); for (;;) { do_mem_mw (NULL, 0, 3, argv); /* delay for <count> ms... */ for (i=0; i<count; i++) udelay (1000); /* check for ctrl-c to abort... */ if (ctrlc()) { puts("Abort "); return 0; } } return 0; } #endif /* CONFIG_MX_CYCLIC */ |
088f1b199 common/cmd_*.c: s... |
216 |
static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
217 |
{ |
0628ab8ec sandbox: Change m... |
218 |
ulong addr1, addr2, count, ngood, bytes; |
27b207fd0 * Implement new m... |
219 |
int size; |
3863585bb Initial revision |
220 |
int rcode = 0; |
054ea170f cmd_mem: cmp: uni... |
221 |
const char *type; |
0628ab8ec sandbox: Change m... |
222 |
const void *buf1, *buf2, *base; |
4d1fd7f1a Add 64-bit data s... |
223 224 225 226 227 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA u64 word1, word2; #else ulong word1, word2; #endif |
3863585bb Initial revision |
228 |
|
47e26b1bf cmd_usage(): simp... |
229 |
if (argc != 4) |
4c12eeb8b Convert cmd_usage... |
230 |
return CMD_RET_USAGE; |
3863585bb Initial revision |
231 232 233 |
/* Check for size specification. */ |
27b207fd0 * Implement new m... |
234 235 |
if ((size = cmd_get_data_size(argv[0], 4)) < 0) return 1; |
4d1fd7f1a Add 64-bit data s... |
236 237 238 |
type = size == 8 ? "double word" : size == 4 ? "word" : size == 2 ? "halfword" : "byte"; |
3863585bb Initial revision |
239 240 241 242 243 244 245 246 |
addr1 = simple_strtoul(argv[1], NULL, 16); addr1 += base_address; addr2 = simple_strtoul(argv[2], NULL, 16); addr2 += base_address; count = simple_strtoul(argv[3], NULL, 16); |
0628ab8ec sandbox: Change m... |
247 248 249 |
bytes = size * count; base = buf1 = map_sysmem(addr1, bytes); buf2 = map_sysmem(addr2, bytes); |
feb12a1f6 cmd_mem: cmp: con... |
250 |
for (ngood = 0; ngood < count; ++ngood) { |
3863585bb Initial revision |
251 |
if (size == 4) { |
76698b4e6 Fix memory comman... |
252 253 |
word1 = *(u32 *)buf1; word2 = *(u32 *)buf2; |
4d1fd7f1a Add 64-bit data s... |
254 255 256 257 258 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA } else if (size == 8) { word1 = *(u64 *)buf1; word2 = *(u64 *)buf2; #endif |
054ea170f cmd_mem: cmp: uni... |
259 |
} else if (size == 2) { |
76698b4e6 Fix memory comman... |
260 261 |
word1 = *(u16 *)buf1; word2 = *(u16 *)buf2; |
054ea170f cmd_mem: cmp: uni... |
262 |
} else { |
76698b4e6 Fix memory comman... |
263 264 |
word1 = *(u8 *)buf1; word2 = *(u8 *)buf2; |
3863585bb Initial revision |
265 |
} |
054ea170f cmd_mem: cmp: uni... |
266 |
if (word1 != word2) { |
0628ab8ec sandbox: Change m... |
267 |
ulong offset = buf1 - base; |
4d1fd7f1a Add 64-bit data s... |
268 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA |
e48f3741c sandbox: Fix warn... |
269 270 271 |
printf("%s at 0x%p (%#0*"PRIx64") != %s at 0x%p (%#0*" PRIx64 ") ", |
4d1fd7f1a Add 64-bit data s... |
272 273 274 |
type, (void *)(addr1 + offset), size, word1, type, (void *)(addr2 + offset), size, word2); #else |
054ea170f cmd_mem: cmp: uni... |
275 276 |
printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx) ", |
0628ab8ec sandbox: Change m... |
277 278 |
type, (ulong)(addr1 + offset), size, word1, type, (ulong)(addr2 + offset), size, word2); |
4d1fd7f1a Add 64-bit data s... |
279 |
#endif |
054ea170f cmd_mem: cmp: uni... |
280 281 |
rcode = 1; break; |
3863585bb Initial revision |
282 |
} |
054ea170f cmd_mem: cmp: uni... |
283 |
|
0628ab8ec sandbox: Change m... |
284 285 |
buf1 += size; buf2 += size; |
eaadb44ed cp/cmp: Add WATCH... |
286 287 |
/* reset watchdog from time to time */ |
feb12a1f6 cmd_mem: cmp: con... |
288 |
if ((ngood % (64 << 10)) == 0) |
eaadb44ed cp/cmp: Add WATCH... |
289 |
WATCHDOG_RESET(); |
3863585bb Initial revision |
290 |
} |
0628ab8ec sandbox: Change m... |
291 292 |
unmap_sysmem(buf1); unmap_sysmem(buf2); |
3863585bb Initial revision |
293 |
|
054ea170f cmd_mem: cmp: uni... |
294 295 |
printf("Total of %ld %s(s) were the same ", ngood, type); |
3863585bb Initial revision |
296 297 |
return rcode; } |
088f1b199 common/cmd_*.c: s... |
298 |
static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
299 |
{ |
c2538421b cmd: mem: Use mem... |
300 |
ulong addr, dest, count; |
27b207fd0 * Implement new m... |
301 |
int size; |
3863585bb Initial revision |
302 |
|
47e26b1bf cmd_usage(): simp... |
303 |
if (argc != 4) |
4c12eeb8b Convert cmd_usage... |
304 |
return CMD_RET_USAGE; |
3863585bb Initial revision |
305 306 307 |
/* Check for size specification. */ |
27b207fd0 * Implement new m... |
308 309 |
if ((size = cmd_get_data_size(argv[0], 4)) < 0) return 1; |
3863585bb Initial revision |
310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
addr = simple_strtoul(argv[1], NULL, 16); addr += base_address; dest = simple_strtoul(argv[2], NULL, 16); dest += base_address; count = simple_strtoul(argv[3], NULL, 16); if (count == 0) { puts ("Zero length ??? "); return 1; } |
e856bdcfb flash: complete C... |
324 |
#ifdef CONFIG_MTD_NOR_FLASH |
3863585bb Initial revision |
325 |
/* check if we are copying to Flash */ |
c68c03f52 Drop CONFIG_HAS_D... |
326 |
if (addr2info(dest) != NULL) { |
3863585bb Initial revision |
327 |
int rc; |
4b9206ed5 * Patches by Thom... |
328 |
puts ("Copy to Flash... "); |
3863585bb Initial revision |
329 |
|
77ddac948 Cleanup for GCC-4.x |
330 |
rc = flash_write ((char *)addr, dest, count*size); |
3863585bb Initial revision |
331 332 333 334 335 336 337 338 339 |
if (rc != 0) { flash_perror (rc); return (1); } puts ("done "); return 0; } #endif |
c2538421b cmd: mem: Use mem... |
340 |
memcpy((void *)dest, (void *)addr, count * size); |
a3a4749df cmd_mem: call unm... |
341 |
|
3863585bb Initial revision |
342 343 |
return 0; } |
088f1b199 common/cmd_*.c: s... |
344 345 |
static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
346 347 348 349 350 351 352 353 354 355 356 357 |
{ if (argc > 1) { /* Set new base address. */ base_address = simple_strtoul(argv[1], NULL, 16); } /* Print the current base address. */ printf("Base Address: 0x%08lx ", base_address); return 0; } |
088f1b199 common/cmd_*.c: s... |
358 359 |
static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
360 |
{ |
0628ab8ec sandbox: Change m... |
361 |
ulong addr, length, i, bytes; |
27b207fd0 * Implement new m... |
362 |
int size; |
4d1fd7f1a Add 64-bit data s... |
363 364 365 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA volatile u64 *llp; #endif |
76698b4e6 Fix memory comman... |
366 367 368 |
volatile u32 *longp; volatile u16 *shortp; volatile u8 *cp; |
0628ab8ec sandbox: Change m... |
369 |
const void *buf; |
3863585bb Initial revision |
370 |
|
47e26b1bf cmd_usage(): simp... |
371 |
if (argc < 3) |
4c12eeb8b Convert cmd_usage... |
372 |
return CMD_RET_USAGE; |
3863585bb Initial revision |
373 |
|
85de63e2e cmd_mem.c: Fix so... |
374 375 |
/* * Check for a size specification. |
3863585bb Initial revision |
376 377 |
* Defaults to long if no or incorrect specification. */ |
27b207fd0 * Implement new m... |
378 379 |
if ((size = cmd_get_data_size(argv[0], 4)) < 0) return 1; |
3863585bb Initial revision |
380 381 382 383 384 385 386 387 |
/* Address is always specified. */ addr = simple_strtoul(argv[1], NULL, 16); /* Length is the number of objects, not number of bytes. */ length = simple_strtoul(argv[2], NULL, 16); |
0628ab8ec sandbox: Change m... |
388 389 |
bytes = size * length; buf = map_sysmem(addr, bytes); |
3863585bb Initial revision |
390 391 392 393 |
/* We want to optimize the loops to run as fast as possible. * If we have only one object, just run infinite loops. */ if (length == 1) { |
4d1fd7f1a Add 64-bit data s... |
394 395 396 397 398 399 400 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA if (size == 8) { llp = (u64 *)buf; for (;;) i = *llp; } #endif |
3863585bb Initial revision |
401 |
if (size == 4) { |
76698b4e6 Fix memory comman... |
402 |
longp = (u32 *)buf; |
3863585bb Initial revision |
403 404 405 406 |
for (;;) i = *longp; } if (size == 2) { |
76698b4e6 Fix memory comman... |
407 |
shortp = (u16 *)buf; |
3863585bb Initial revision |
408 409 410 |
for (;;) i = *shortp; } |
76698b4e6 Fix memory comman... |
411 |
cp = (u8 *)buf; |
3863585bb Initial revision |
412 413 414 |
for (;;) i = *cp; } |
4d1fd7f1a Add 64-bit data s... |
415 416 417 418 419 420 421 422 423 424 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA if (size == 8) { for (;;) { llp = (u64 *)buf; i = length; while (i-- > 0) *llp++; } } #endif |
3863585bb Initial revision |
425 426 |
if (size == 4) { for (;;) { |
76698b4e6 Fix memory comman... |
427 |
longp = (u32 *)buf; |
3863585bb Initial revision |
428 429 |
i = length; while (i-- > 0) |
f3b3c3df1 GCC4.6: Squash wa... |
430 |
*longp++; |
3863585bb Initial revision |
431 432 433 434 |
} } if (size == 2) { for (;;) { |
76698b4e6 Fix memory comman... |
435 |
shortp = (u16 *)buf; |
3863585bb Initial revision |
436 437 |
i = length; while (i-- > 0) |
f3b3c3df1 GCC4.6: Squash wa... |
438 |
*shortp++; |
3863585bb Initial revision |
439 440 441 |
} } for (;;) { |
76698b4e6 Fix memory comman... |
442 |
cp = (u8 *)buf; |
3863585bb Initial revision |
443 444 |
i = length; while (i-- > 0) |
f3b3c3df1 GCC4.6: Squash wa... |
445 |
*cp++; |
3863585bb Initial revision |
446 |
} |
0628ab8ec sandbox: Change m... |
447 |
unmap_sysmem(buf); |
92765f420 Fix missing retur... |
448 449 |
return 0; |
3863585bb Initial revision |
450 |
} |
56523f128 * Patch by Martin... |
451 |
#ifdef CONFIG_LOOPW |
5a8608e58 cmd_mem: add stat... |
452 453 |
static int do_mem_loopw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
56523f128 * Patch by Martin... |
454 |
{ |
4d1fd7f1a Add 64-bit data s... |
455 |
ulong addr, length, i, bytes; |
56523f128 * Patch by Martin... |
456 |
int size; |
4d1fd7f1a Add 64-bit data s... |
457 458 459 460 461 462 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA volatile u64 *llp; u64 data; #else ulong data; #endif |
76698b4e6 Fix memory comman... |
463 464 465 |
volatile u32 *longp; volatile u16 *shortp; volatile u8 *cp; |
0628ab8ec sandbox: Change m... |
466 |
void *buf; |
810509266 * Cleanup |
467 |
|
47e26b1bf cmd_usage(): simp... |
468 |
if (argc < 4) |
4c12eeb8b Convert cmd_usage... |
469 |
return CMD_RET_USAGE; |
56523f128 * Patch by Martin... |
470 |
|
85de63e2e cmd_mem.c: Fix so... |
471 472 |
/* * Check for a size specification. |
56523f128 * Patch by Martin... |
473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
* Defaults to long if no or incorrect specification. */ if ((size = cmd_get_data_size(argv[0], 4)) < 0) return 1; /* Address is always specified. */ addr = simple_strtoul(argv[1], NULL, 16); /* Length is the number of objects, not number of bytes. */ length = simple_strtoul(argv[2], NULL, 16); /* data to write */ |
4d1fd7f1a Add 64-bit data s... |
487 488 489 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA data = simple_strtoull(argv[3], NULL, 16); #else |
56523f128 * Patch by Martin... |
490 |
data = simple_strtoul(argv[3], NULL, 16); |
4d1fd7f1a Add 64-bit data s... |
491 |
#endif |
810509266 * Cleanup |
492 |
|
0628ab8ec sandbox: Change m... |
493 494 |
bytes = size * length; buf = map_sysmem(addr, bytes); |
56523f128 * Patch by Martin... |
495 496 497 498 |
/* We want to optimize the loops to run as fast as possible. * If we have only one object, just run infinite loops. */ if (length == 1) { |
4d1fd7f1a Add 64-bit data s... |
499 500 501 502 503 504 505 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA if (size == 8) { llp = (u64 *)buf; for (;;) *llp = data; } #endif |
56523f128 * Patch by Martin... |
506 |
if (size == 4) { |
76698b4e6 Fix memory comman... |
507 |
longp = (u32 *)buf; |
56523f128 * Patch by Martin... |
508 509 |
for (;;) *longp = data; |
4d1fd7f1a Add 64-bit data s... |
510 |
} |
56523f128 * Patch by Martin... |
511 |
if (size == 2) { |
76698b4e6 Fix memory comman... |
512 |
shortp = (u16 *)buf; |
56523f128 * Patch by Martin... |
513 514 515 |
for (;;) *shortp = data; } |
76698b4e6 Fix memory comman... |
516 |
cp = (u8 *)buf; |
56523f128 * Patch by Martin... |
517 518 519 |
for (;;) *cp = data; } |
4d1fd7f1a Add 64-bit data s... |
520 521 522 523 524 525 526 527 528 529 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA if (size == 8) { for (;;) { llp = (u64 *)buf; i = length; while (i-- > 0) *llp++ = data; } } #endif |
56523f128 * Patch by Martin... |
530 531 |
if (size == 4) { for (;;) { |
76698b4e6 Fix memory comman... |
532 |
longp = (u32 *)buf; |
56523f128 * Patch by Martin... |
533 534 535 536 537 538 539 |
i = length; while (i-- > 0) *longp++ = data; } } if (size == 2) { for (;;) { |
76698b4e6 Fix memory comman... |
540 |
shortp = (u16 *)buf; |
56523f128 * Patch by Martin... |
541 542 543 544 545 546 |
i = length; while (i-- > 0) *shortp++ = data; } } for (;;) { |
76698b4e6 Fix memory comman... |
547 |
cp = (u8 *)buf; |
56523f128 * Patch by Martin... |
548 549 550 551 552 553 |
i = length; while (i-- > 0) *cp++ = data; } } #endif /* CONFIG_LOOPW */ |
68149e940 cmd_mem.c: Fix wa... |
554 |
#ifdef CONFIG_CMD_MEMTEST |
5512d5b03 sandbox: Update m... |
555 556 |
static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr, vu_long *dummy) |
3863585bb Initial revision |
557 |
{ |
c9638f50f Split out the mem... |
558 |
vu_long *addr; |
c9638f50f Split out the mem... |
559 560 561 |
ulong errs = 0; ulong val, readback; int j; |
c9638f50f Split out the mem... |
562 563 564 565 566 567 |
vu_long offset; vu_long test_offset; vu_long pattern; vu_long temp; vu_long anti_pattern; vu_long num_words; |
3863585bb Initial revision |
568 569 570 571 572 573 574 575 576 577 |
static const ulong bitpattern[] = { 0x00000001, /* single bit */ 0x00000003, /* two adjacent bits */ 0x00000007, /* three adjacent bits */ 0x0000000F, /* four adjacent bits */ 0x00000005, /* two non-adjacent bits */ 0x00000015, /* three non-adjacent bits */ 0x00000055, /* four non-adjacent bits */ 0xaaaaaaaa, /* alternating 1/0 */ }; |
3863585bb Initial revision |
578 |
|
5512d5b03 sandbox: Update m... |
579 |
num_words = (end_addr - start_addr) / sizeof(vu_long); |
8c86bbe00 Reduce casting in... |
580 |
|
7ecbd4d70 Fix mtest indenting |
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
/* * Data line test: write a pattern to the first * location, write the 1's complement to a 'parking' * address (changes the state of the data bus so a * floating bus doesn't give a false OK), and then * read the value back. Note that we read it back * into a variable because the next time we read it, * it might be right (been there, tough to explain to * the quality guys why it prints a failure when the * "is" and "should be" are obviously the same in the * error message). * * Rather than exhaustively testing, we test some * patterns by shifting '1' bits through a field of * '0's and '0' bits through a field of '1's (i.e. * pattern and ~pattern). */ |
5512d5b03 sandbox: Update m... |
598 |
addr = buf; |
7ecbd4d70 Fix mtest indenting |
599 600 601 |
for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) { val = bitpattern[j]; for (; val != 0; val <<= 1) { |
5512d5b03 sandbox: Update m... |
602 |
*addr = val; |
c9638f50f Split out the mem... |
603 |
*dummy = ~val; /* clear the test data off the bus */ |
3863585bb Initial revision |
604 |
readback = *addr; |
7ecbd4d70 Fix mtest indenting |
605 |
if (readback != val) { |
c9638f50f Split out the mem... |
606 607 608 609 610 |
printf("FAILURE (data line): " "expected %08lx, actual %08lx ", val, readback); errs++; |
c44d4386e Bring mtest putc(... |
611 |
if (ctrlc()) |
51209b1f4 Use common mtest ... |
612 |
return -1; |
3863585bb Initial revision |
613 614 615 616 |
} *addr = ~val; *dummy = val; readback = *addr; |
c9638f50f Split out the mem... |
617 618 619 620 621 622 |
if (readback != ~val) { printf("FAILURE (data line): " "Is %08lx, should be %08lx ", readback, ~val); errs++; |
c44d4386e Bring mtest putc(... |
623 |
if (ctrlc()) |
51209b1f4 Use common mtest ... |
624 |
return -1; |
3863585bb Initial revision |
625 |
} |
3863585bb Initial revision |
626 |
} |
7ecbd4d70 Fix mtest indenting |
627 |
} |
3863585bb Initial revision |
628 |
|
7ecbd4d70 Fix mtest indenting |
629 630 631 632 633 634 635 636 637 |
/* * Based on code whose Original Author and Copyright * information follows: Copyright (c) 1998 by Michael * Barr. This software is placed into the public * domain and may be used for any purpose. However, * this notice must not be changed or removed and no * warranty is either expressed or implied by its * publication or distribution. */ |
3863585bb Initial revision |
638 |
|
7ecbd4d70 Fix mtest indenting |
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
/* * Address line test * Description: Test the address bus wiring in a * memory region by performing a walking * 1's test on the relevant bits of the * address and checking for aliasing. * This test will find single-bit * address failures such as stuck-high, * stuck-low, and shorted pins. The base * address and size of the region are * selected by the caller. * Notes: For best results, the selected base * address should have enough LSB 0's to * guarantee single address bit changes. * For example, to test a 64-Kbyte * region, select a base address on a * 64-Kbyte boundary. Also, select the * region size as a power-of-two if at * all possible. * * Returns: 0 if the test succeeds, 1 if the test fails. */ |
7ecbd4d70 Fix mtest indenting |
663 664 |
pattern = (vu_long) 0xaaaaaaaa; anti_pattern = (vu_long) 0x55555555; |
3863585bb Initial revision |
665 |
|
5512d5b03 sandbox: Update m... |
666 667 |
debug("%s:%d: length = 0x%.8lx ", __func__, __LINE__, num_words); |
7ecbd4d70 Fix mtest indenting |
668 669 670 671 |
/* * Write the default pattern at each of the * power-of-two offsets. */ |
5512d5b03 sandbox: Update m... |
672 673 |
for (offset = 1; offset < num_words; offset <<= 1) addr[offset] = pattern; |
3863585bb Initial revision |
674 |
|
7ecbd4d70 Fix mtest indenting |
675 676 677 678 |
/* * Check for address bits stuck high. */ test_offset = 0; |
5512d5b03 sandbox: Update m... |
679 |
addr[test_offset] = anti_pattern; |
3863585bb Initial revision |
680 |
|
5512d5b03 sandbox: Update m... |
681 682 |
for (offset = 1; offset < num_words; offset <<= 1) { temp = addr[offset]; |
7ecbd4d70 Fix mtest indenting |
683 |
if (temp != pattern) { |
c9638f50f Split out the mem... |
684 685 |
printf(" FAILURE: Address bit stuck high @ 0x%.8lx:" |
3863585bb Initial revision |
686 687 |
" expected 0x%.8lx, actual 0x%.8lx ", |
102c051fc fix address of er... |
688 689 |
start_addr + offset*sizeof(vu_long), pattern, temp); |
87b22b778 mem_mtest: fix er... |
690 |
errs++; |
c44d4386e Bring mtest putc(... |
691 |
if (ctrlc()) |
7ecbd4d70 Fix mtest indenting |
692 |
return -1; |
3863585bb Initial revision |
693 |
} |
7ecbd4d70 Fix mtest indenting |
694 |
} |
5512d5b03 sandbox: Update m... |
695 |
addr[test_offset] = pattern; |
7ecbd4d70 Fix mtest indenting |
696 |
WATCHDOG_RESET(); |
3863585bb Initial revision |
697 |
|
7ecbd4d70 Fix mtest indenting |
698 699 700 |
/* * Check for addr bits stuck low or shorted. */ |
5512d5b03 sandbox: Update m... |
701 702 |
for (test_offset = 1; test_offset < num_words; test_offset <<= 1) { addr[test_offset] = anti_pattern; |
3863585bb Initial revision |
703 |
|
5512d5b03 sandbox: Update m... |
704 705 |
for (offset = 1; offset < num_words; offset <<= 1) { temp = addr[offset]; |
3863585bb Initial revision |
706 |
if ((temp != pattern) && (offset != test_offset)) { |
7ecbd4d70 Fix mtest indenting |
707 708 709 710 711 |
printf(" FAILURE: Address bit stuck low or" " shorted @ 0x%.8lx: expected 0x%.8lx," " actual 0x%.8lx ", |
102c051fc fix address of er... |
712 713 |
start_addr + offset*sizeof(vu_long), pattern, temp); |
7ecbd4d70 Fix mtest indenting |
714 |
errs++; |
c44d4386e Bring mtest putc(... |
715 |
if (ctrlc()) |
7ecbd4d70 Fix mtest indenting |
716 |
return -1; |
3863585bb Initial revision |
717 |
} |
3863585bb Initial revision |
718 |
} |
5512d5b03 sandbox: Update m... |
719 |
addr[test_offset] = pattern; |
7ecbd4d70 Fix mtest indenting |
720 |
} |
3863585bb Initial revision |
721 |
|
7ecbd4d70 Fix mtest indenting |
722 723 724 725 726 727 728 729 730 731 732 733 |
/* * Description: Test the integrity of a physical * memory device by performing an * increment/decrement test over the * entire region. In the process every * storage bit in the device is tested * as a zero and a one. The base address * and the size of the region are * selected by the caller. * * Returns: 0 if the test succeeds, 1 if the test fails. */ |
5512d5b03 sandbox: Update m... |
734 |
num_words++; |
3863585bb Initial revision |
735 |
|
7ecbd4d70 Fix mtest indenting |
736 737 738 739 740 |
/* * Fill memory with a known pattern. */ for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { WATCHDOG_RESET(); |
5512d5b03 sandbox: Update m... |
741 |
addr[offset] = pattern; |
7ecbd4d70 Fix mtest indenting |
742 |
} |
3863585bb Initial revision |
743 |
|
7ecbd4d70 Fix mtest indenting |
744 745 746 747 748 |
/* * Check each location and invert it for the second pass. */ for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { WATCHDOG_RESET(); |
5512d5b03 sandbox: Update m... |
749 |
temp = addr[offset]; |
7ecbd4d70 Fix mtest indenting |
750 |
if (temp != pattern) { |
c9638f50f Split out the mem... |
751 752 |
printf(" FAILURE (read/write) @ 0x%.8lx:" |
3863585bb Initial revision |
753 754 |
" expected 0x%.8lx, actual 0x%.8lx) ", |
102c051fc fix address of er... |
755 756 |
start_addr + offset*sizeof(vu_long), pattern, temp); |
87b22b778 mem_mtest: fix er... |
757 |
errs++; |
c44d4386e Bring mtest putc(... |
758 |
if (ctrlc()) |
51209b1f4 Use common mtest ... |
759 |
return -1; |
3863585bb Initial revision |
760 |
} |
7ecbd4d70 Fix mtest indenting |
761 |
anti_pattern = ~pattern; |
5512d5b03 sandbox: Update m... |
762 |
addr[offset] = anti_pattern; |
7ecbd4d70 Fix mtest indenting |
763 764 765 766 767 768 769 770 |
} /* * Check each location for the inverted pattern and zero it. */ for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { WATCHDOG_RESET(); anti_pattern = ~pattern; |
5512d5b03 sandbox: Update m... |
771 |
temp = addr[offset]; |
7ecbd4d70 Fix mtest indenting |
772 |
if (temp != anti_pattern) { |
c9638f50f Split out the mem... |
773 774 |
printf(" FAILURE (read/write): @ 0x%.8lx:" |
3863585bb Initial revision |
775 776 |
" expected 0x%.8lx, actual 0x%.8lx) ", |
102c051fc fix address of er... |
777 778 |
start_addr + offset*sizeof(vu_long), anti_pattern, temp); |
87b22b778 mem_mtest: fix er... |
779 |
errs++; |
c44d4386e Bring mtest putc(... |
780 |
if (ctrlc()) |
51209b1f4 Use common mtest ... |
781 |
return -1; |
3863585bb Initial revision |
782 |
} |
5512d5b03 sandbox: Update m... |
783 |
addr[offset] = 0; |
7ecbd4d70 Fix mtest indenting |
784 |
} |
51209b1f4 Use common mtest ... |
785 |
|
fea6730e1 fix always succes... |
786 |
return errs; |
c9638f50f Split out the mem... |
787 |
} |
5512d5b03 sandbox: Update m... |
788 789 |
static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr, vu_long pattern, int iteration) |
c9638f50f Split out the mem... |
790 |
{ |
5512d5b03 sandbox: Update m... |
791 |
vu_long *end; |
c9638f50f Split out the mem... |
792 |
vu_long *addr; |
c9638f50f Split out the mem... |
793 |
ulong errs = 0; |
5512d5b03 sandbox: Update m... |
794 |
ulong incr, length; |
c9638f50f Split out the mem... |
795 |
ulong val, readback; |
3863585bb Initial revision |
796 |
|
51209b1f4 Use common mtest ... |
797 |
/* Alternate the pattern */ |
3863585bb Initial revision |
798 |
incr = 1; |
51209b1f4 Use common mtest ... |
799 800 801 802 803 804 805 806 807 808 809 810 811 |
if (iteration & 1) { incr = -incr; /* * Flip the pattern each time to make lots of zeros and * then, the next time, lots of ones. We decrement * the "negative" patterns and increment the "positive" * patterns to preserve this feature. */ if (pattern & 0x80000000) pattern = -pattern; /* complement & increment */ else pattern = ~pattern; } |
5512d5b03 sandbox: Update m... |
812 813 |
length = (end_addr - start_addr) / sizeof(ulong); end = buf + length; |
7ecbd4d70 Fix mtest indenting |
814 815 816 817 |
printf("\rPattern %08lX Writing..." "%12s" "\b\b\b\b\b\b\b\b\b\b", pattern, ""); |
3863585bb Initial revision |
818 |
|
5512d5b03 sandbox: Update m... |
819 |
for (addr = buf, val = pattern; addr < end; addr++) { |
7ecbd4d70 Fix mtest indenting |
820 821 822 823 |
WATCHDOG_RESET(); *addr = val; val += incr; } |
3863585bb Initial revision |
824 |
|
7ecbd4d70 Fix mtest indenting |
825 |
puts("Reading..."); |
3863585bb Initial revision |
826 |
|
5512d5b03 sandbox: Update m... |
827 |
for (addr = buf, val = pattern; addr < end; addr++) { |
7ecbd4d70 Fix mtest indenting |
828 829 830 |
WATCHDOG_RESET(); readback = *addr; if (readback != val) { |
5512d5b03 sandbox: Update m... |
831 |
ulong offset = addr - buf; |
7ecbd4d70 Fix mtest indenting |
832 833 834 835 |
printf(" Mem error @ 0x%08X: " "found %08lX, expected %08lX ", |
102c051fc fix address of er... |
836 |
(uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)), |
5512d5b03 sandbox: Update m... |
837 |
readback, val); |
7ecbd4d70 Fix mtest indenting |
838 |
errs++; |
c44d4386e Bring mtest putc(... |
839 |
if (ctrlc()) |
7ecbd4d70 Fix mtest indenting |
840 |
return -1; |
3863585bb Initial revision |
841 |
} |
7ecbd4d70 Fix mtest indenting |
842 843 |
val += incr; } |
3863585bb Initial revision |
844 |
|
fea6730e1 fix always succes... |
845 |
return errs; |
c9638f50f Split out the mem... |
846 847 848 849 850 851 852 853 854 855 |
} /* * Perform a memory test. A more complete alternative test can be * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until * interrupted by ctrl-c or by a failure of one of the sub-tests. */ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { |
8c86bbe00 Reduce casting in... |
856 |
ulong start, end; |
5512d5b03 sandbox: Update m... |
857 |
vu_long *buf, *dummy; |
adcc57059 cmd_mem.c: Update... |
858 |
ulong iteration_limit = 0; |
c9638f50f Split out the mem... |
859 |
int ret; |
51209b1f4 Use common mtest ... |
860 |
ulong errs = 0; /* number of errors, or -1 if interrupted */ |
e37f1eb45 cmd_mem: cleanups... |
861 |
ulong pattern = 0; |
51209b1f4 Use common mtest ... |
862 |
int iteration; |
c9638f50f Split out the mem... |
863 864 865 866 |
#if defined(CONFIG_SYS_ALT_MEMTEST) const int alt_test = 1; #else const int alt_test = 0; |
3863585bb Initial revision |
867 |
#endif |
c9638f50f Split out the mem... |
868 |
|
e37f1eb45 cmd_mem: cleanups... |
869 870 |
start = CONFIG_SYS_MEMTEST_START; end = CONFIG_SYS_MEMTEST_END; |
c9638f50f Split out the mem... |
871 |
if (argc > 1) |
e37f1eb45 cmd_mem: cleanups... |
872 873 |
if (strict_strtoul(argv[1], 16, &start) < 0) return CMD_RET_USAGE; |
c9638f50f Split out the mem... |
874 875 |
if (argc > 2) |
e37f1eb45 cmd_mem: cleanups... |
876 877 |
if (strict_strtoul(argv[2], 16, &end) < 0) return CMD_RET_USAGE; |
c9638f50f Split out the mem... |
878 879 |
if (argc > 3) |
e37f1eb45 cmd_mem: cleanups... |
880 881 |
if (strict_strtoul(argv[3], 16, &pattern) < 0) return CMD_RET_USAGE; |
c9638f50f Split out the mem... |
882 883 |
if (argc > 4) |
e37f1eb45 cmd_mem: cleanups... |
884 885 886 887 888 889 890 891 |
if (strict_strtoul(argv[4], 16, &iteration_limit) < 0) return CMD_RET_USAGE; if (end < start) { printf("Refusing to do empty test "); return -1; } |
c9638f50f Split out the mem... |
892 |
|
dfe461d6b cmd: mem: Show 64... |
893 894 |
printf("Testing %08lx ... %08lx: ", start, end); |
8c86bbe00 Reduce casting in... |
895 896 897 |
debug("%s:%d: start %#08lx end %#08lx ", __func__, __LINE__, start, end); |
51209b1f4 Use common mtest ... |
898 |
|
5512d5b03 sandbox: Update m... |
899 900 |
buf = map_sysmem(start, end - start); dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long)); |
51209b1f4 Use common mtest ... |
901 902 903 904 |
for (iteration = 0; !iteration_limit || iteration < iteration_limit; iteration++) { if (ctrlc()) { |
51209b1f4 Use common mtest ... |
905 906 907 908 909 910 911 |
errs = -1UL; break; } printf("Iteration: %6d\r", iteration + 1); debug(" "); |
5512d5b03 sandbox: Update m... |
912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 |
if (alt_test) { errs = mem_test_alt(buf, start, end, dummy); } else { errs = mem_test_quick(buf, start, end, pattern, iteration); } if (errs == -1UL) break; } /* * Work-around for eldk-4.2 which gives this warning if we try to * case in the unmap_sysmem() call: * warning: initialization discards qualifiers from pointer target type */ { void *vbuf = (void *)buf; void *vdummy = (void *)dummy; unmap_sysmem(vbuf); unmap_sysmem(vdummy); |
51209b1f4 Use common mtest ... |
933 934 935 |
} if (errs == -1UL) { |
c44d4386e Bring mtest putc(... |
936 937 938 |
/* Memory test was aborted - write a newline to finish off */ putc(' '); |
51209b1f4 Use common mtest ... |
939 940 941 942 943 944 945 |
ret = 1; } else { printf("Tested %d iteration(s) with %lu errors. ", iteration, errs); ret = errs != 0; } |
c9638f50f Split out the mem... |
946 |
|
e37f1eb45 cmd_mem: cleanups... |
947 |
return ret; |
3863585bb Initial revision |
948 |
} |
a2681707b Feature Removal: ... |
949 |
#endif /* CONFIG_CMD_MEMTEST */ |
3863585bb Initial revision |
950 951 952 953 |
/* Modify memory. * * Syntax: |
4d1fd7f1a Add 64-bit data s... |
954 955 |
* mm{.b, .w, .l, .q} {addr} * nm{.b, .w, .l, .q} {addr} |
3863585bb Initial revision |
956 957 |
*/ static int |
54841ab50 Make sure that ar... |
958 |
mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
959 |
{ |
4d1fd7f1a Add 64-bit data s... |
960 961 962 963 964 965 |
ulong addr; #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA u64 i; #else ulong i; #endif |
27b207fd0 * Implement new m... |
966 |
int nbytes, size; |
0628ab8ec sandbox: Change m... |
967 |
void *ptr = NULL; |
3863585bb Initial revision |
968 |
|
47e26b1bf cmd_usage(): simp... |
969 |
if (argc != 2) |
4c12eeb8b Convert cmd_usage... |
970 |
return CMD_RET_USAGE; |
3863585bb Initial revision |
971 |
|
b26440f1f Rename bootretry ... |
972 |
bootretry_reset_cmd_timeout(); /* got a good command to get here */ |
3863585bb Initial revision |
973 974 975 976 977 978 979 980 981 982 |
/* 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. */ |
27b207fd0 * Implement new m... |
983 984 |
if ((size = cmd_get_data_size(argv[0], 4)) < 0) return 1; |
3863585bb Initial revision |
985 986 987 988 989 990 991 992 993 994 995 |
/* Address is specified since argc > 1 */ addr = simple_strtoul(argv[1], NULL, 16); addr += base_address; } /* Print the address, followed by value. Then accept input for * the next value. A non-converted value exits. */ do { |
0628ab8ec sandbox: Change m... |
996 |
ptr = map_sysmem(addr, size); |
3863585bb Initial revision |
997 998 |
printf("%08lx:", addr); if (size == 4) |
76698b4e6 Fix memory comman... |
999 |
printf(" %08x", *((u32 *)ptr)); |
4d1fd7f1a Add 64-bit data s... |
1000 1001 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA else if (size == 8) |
e48f3741c sandbox: Fix warn... |
1002 |
printf(" %016" PRIx64, *((u64 *)ptr)); |
4d1fd7f1a Add 64-bit data s... |
1003 |
#endif |
3863585bb Initial revision |
1004 |
else if (size == 2) |
76698b4e6 Fix memory comman... |
1005 |
printf(" %04x", *((u16 *)ptr)); |
3863585bb Initial revision |
1006 |
else |
76698b4e6 Fix memory comman... |
1007 |
printf(" %02x", *((u8 *)ptr)); |
3863585bb Initial revision |
1008 |
|
e1bf824df Add cli_ prefix t... |
1009 |
nbytes = cli_readline(" ? "); |
3863585bb Initial revision |
1010 1011 1012 1013 1014 1015 1016 |
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; |
b26440f1f Rename bootretry ... |
1017 1018 |
/* good enough to not time out */ bootretry_reset_cmd_timeout(); |
3863585bb Initial revision |
1019 1020 1021 1022 1023 1024 1025 1026 |
} #ifdef CONFIG_BOOT_RETRY_TIME else if (nbytes == -2) { break; /* timed out, exit the command */ } #endif else { char *endp; |
4d1fd7f1a Add 64-bit data s... |
1027 1028 1029 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA i = simple_strtoull(console_buffer, &endp, 16); #else |
3863585bb Initial revision |
1030 |
i = simple_strtoul(console_buffer, &endp, 16); |
4d1fd7f1a Add 64-bit data s... |
1031 |
#endif |
3863585bb Initial revision |
1032 1033 |
nbytes = endp - console_buffer; if (nbytes) { |
3863585bb Initial revision |
1034 1035 |
/* good enough to not time out */ |
b26440f1f Rename bootretry ... |
1036 |
bootretry_reset_cmd_timeout(); |
3863585bb Initial revision |
1037 |
if (size == 4) |
76698b4e6 Fix memory comman... |
1038 |
*((u32 *)ptr) = i; |
4d1fd7f1a Add 64-bit data s... |
1039 1040 1041 1042 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA else if (size == 8) *((u64 *)ptr) = i; #endif |
3863585bb Initial revision |
1043 |
else if (size == 2) |
76698b4e6 Fix memory comman... |
1044 |
*((u16 *)ptr) = i; |
3863585bb Initial revision |
1045 |
else |
76698b4e6 Fix memory comman... |
1046 |
*((u8 *)ptr) = i; |
3863585bb Initial revision |
1047 1048 1049 1050 1051 |
if (incrflag) addr += size; } } } while (nbytes); |
0628ab8ec sandbox: Change m... |
1052 1053 |
if (ptr) unmap_sysmem(ptr); |
3863585bb Initial revision |
1054 1055 1056 1057 1058 |
mm_last_addr = addr; mm_last_size = size; return 0; } |
710b99385 crc32: make comma... |
1059 |
#ifdef CONFIG_CMD_CRC32 |
088f1b199 common/cmd_*.c: s... |
1060 |
static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
1061 |
{ |
d20a40de9 Roll crc32 into h... |
1062 |
int flags = 0; |
c26e454df Patches by Pantel... |
1063 |
int ac; |
54841ab50 Make sure that ar... |
1064 |
char * const *av; |
c26e454df Patches by Pantel... |
1065 |
|
d20a40de9 Roll crc32 into h... |
1066 |
if (argc < 3) |
4c12eeb8b Convert cmd_usage... |
1067 |
return CMD_RET_USAGE; |
c26e454df Patches by Pantel... |
1068 1069 1070 |
av = argv + 1; ac = argc - 1; |
221a949eb Kconfig: Finish m... |
1071 |
#ifdef CONFIG_CRC32_VERIFY |
c26e454df Patches by Pantel... |
1072 |
if (strcmp(*av, "-v") == 0) { |
a69bdba9c Fix broken verify... |
1073 |
flags |= HASH_FLAG_VERIFY | HASH_FLAG_ENV; |
c26e454df Patches by Pantel... |
1074 1075 |
av++; ac--; |
c26e454df Patches by Pantel... |
1076 |
} |
d20a40de9 Roll crc32 into h... |
1077 |
#endif |
c26e454df Patches by Pantel... |
1078 |
|
d20a40de9 Roll crc32 into h... |
1079 |
return hash_command("crc32", flags, cmdtp, flag, ac, av); |
c26e454df Patches by Pantel... |
1080 |
} |
c26e454df Patches by Pantel... |
1081 |
|
710b99385 crc32: make comma... |
1082 |
#endif |
8bde7f776 * Code cleanup: |
1083 |
/**************************************************/ |
0d4983930 Patch by Kenneth ... |
1084 |
U_BOOT_CMD( |
53677ef18 Big white-space c... |
1085 |
md, 3, 1, do_mem_md, |
2fb2604d5 Command usage cle... |
1086 |
"memory display", |
4d1fd7f1a Add 64-bit data s... |
1087 1088 1089 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA "[.b, .w, .l, .q] address [# of objects]" #else |
a89c33db9 General help mess... |
1090 |
"[.b, .w, .l] address [# of objects]" |
4d1fd7f1a Add 64-bit data s... |
1091 |
#endif |
8bde7f776 * Code cleanup: |
1092 |
); |
0d4983930 Patch by Kenneth ... |
1093 |
U_BOOT_CMD( |
53677ef18 Big white-space c... |
1094 |
mm, 2, 1, do_mem_mm, |
a89c33db9 General help mess... |
1095 |
"memory modify (auto-incrementing address)", |
4d1fd7f1a Add 64-bit data s... |
1096 1097 1098 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA "[.b, .w, .l, .q] address" #else |
a89c33db9 General help mess... |
1099 |
"[.b, .w, .l] address" |
4d1fd7f1a Add 64-bit data s... |
1100 |
#endif |
8bde7f776 * Code cleanup: |
1101 |
); |
0d4983930 Patch by Kenneth ... |
1102 |
U_BOOT_CMD( |
53677ef18 Big white-space c... |
1103 |
nm, 2, 1, do_mem_nm, |
2fb2604d5 Command usage cle... |
1104 |
"memory modify (constant address)", |
4d1fd7f1a Add 64-bit data s... |
1105 1106 1107 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA "[.b, .w, .l, .q] address" #else |
a89c33db9 General help mess... |
1108 |
"[.b, .w, .l] address" |
4d1fd7f1a Add 64-bit data s... |
1109 |
#endif |
8bde7f776 * Code cleanup: |
1110 |
); |
0d4983930 Patch by Kenneth ... |
1111 |
U_BOOT_CMD( |
53677ef18 Big white-space c... |
1112 |
mw, 4, 1, do_mem_mw, |
2fb2604d5 Command usage cle... |
1113 |
"memory write (fill)", |
4d1fd7f1a Add 64-bit data s... |
1114 1115 1116 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA "[.b, .w, .l, .q] address value [count]" #else |
a89c33db9 General help mess... |
1117 |
"[.b, .w, .l] address value [count]" |
4d1fd7f1a Add 64-bit data s... |
1118 |
#endif |
8bde7f776 * Code cleanup: |
1119 |
); |
0d4983930 Patch by Kenneth ... |
1120 |
U_BOOT_CMD( |
53677ef18 Big white-space c... |
1121 |
cp, 4, 1, do_mem_cp, |
2fb2604d5 Command usage cle... |
1122 |
"memory copy", |
4d1fd7f1a Add 64-bit data s... |
1123 1124 1125 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA "[.b, .w, .l, .q] source target count" #else |
a89c33db9 General help mess... |
1126 |
"[.b, .w, .l] source target count" |
4d1fd7f1a Add 64-bit data s... |
1127 |
#endif |
8bde7f776 * Code cleanup: |
1128 |
); |
0d4983930 Patch by Kenneth ... |
1129 |
U_BOOT_CMD( |
53677ef18 Big white-space c... |
1130 |
cmp, 4, 1, do_mem_cmp, |
2fb2604d5 Command usage cle... |
1131 |
"memory compare", |
4d1fd7f1a Add 64-bit data s... |
1132 1133 1134 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA "[.b, .w, .l, .q] addr1 addr2 count" #else |
a89c33db9 General help mess... |
1135 |
"[.b, .w, .l] addr1 addr2 count" |
4d1fd7f1a Add 64-bit data s... |
1136 |
#endif |
8bde7f776 * Code cleanup: |
1137 |
); |
710b99385 crc32: make comma... |
1138 |
#ifdef CONFIG_CMD_CRC32 |
221a949eb Kconfig: Finish m... |
1139 |
#ifndef CONFIG_CRC32_VERIFY |
c26e454df Patches by Pantel... |
1140 |
|
0d4983930 Patch by Kenneth ... |
1141 |
U_BOOT_CMD( |
53677ef18 Big white-space c... |
1142 |
crc32, 4, 1, do_mem_crc, |
2fb2604d5 Command usage cle... |
1143 |
"checksum calculation", |
a89c33db9 General help mess... |
1144 1145 |
"address count [addr] - compute CRC32 checksum [save at addr]" |
8bde7f776 * Code cleanup: |
1146 |
); |
221a949eb Kconfig: Finish m... |
1147 |
#else /* CONFIG_CRC32_VERIFY */ |
c26e454df Patches by Pantel... |
1148 1149 |
U_BOOT_CMD( |
53677ef18 Big white-space c... |
1150 |
crc32, 5, 1, do_mem_crc, |
2fb2604d5 Command usage cle... |
1151 |
"checksum calculation", |
c26e454df Patches by Pantel... |
1152 1153 1154 |
"address count [addr] - compute CRC32 checksum [save at addr] " |
a89c33db9 General help mess... |
1155 1156 |
"-v address count crc - verify crc of memory area" |
c26e454df Patches by Pantel... |
1157 |
); |
221a949eb Kconfig: Finish m... |
1158 |
#endif /* CONFIG_CRC32_VERIFY */ |
c26e454df Patches by Pantel... |
1159 |
|
710b99385 crc32: make comma... |
1160 |
#endif |
15a33e49d Add option to dis... |
1161 |
#ifdef CONFIG_CMD_MEMINFO |
ea11b401b meminfo cmd: Enab... |
1162 |
__weak void board_show_dram(phys_size_t size) |
15a33e49d Add option to dis... |
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 |
{ puts("DRAM: "); print_size(size, " "); } 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 |
0d4983930 Patch by Kenneth ... |
1177 |
U_BOOT_CMD( |
53677ef18 Big white-space c... |
1178 |
base, 2, 1, do_mem_base, |
2fb2604d5 Command usage cle... |
1179 |
"print or set address offset", |
8bde7f776 * Code cleanup: |
1180 1181 1182 |
" - print address offset for memory commands " |
a89c33db9 General help mess... |
1183 1184 |
"base off - set address offset for memory commands to 'off'" |
8bde7f776 * Code cleanup: |
1185 |
); |
0d4983930 Patch by Kenneth ... |
1186 |
U_BOOT_CMD( |
53677ef18 Big white-space c... |
1187 |
loop, 3, 1, do_mem_loop, |
2fb2604d5 Command usage cle... |
1188 |
"infinite loop on address range", |
4d1fd7f1a Add 64-bit data s... |
1189 1190 1191 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA "[.b, .w, .l, .q] address number_of_objects" #else |
a89c33db9 General help mess... |
1192 |
"[.b, .w, .l] address number_of_objects" |
4d1fd7f1a Add 64-bit data s... |
1193 |
#endif |
8bde7f776 * Code cleanup: |
1194 |
); |
56523f128 * Patch by Martin... |
1195 1196 |
#ifdef CONFIG_LOOPW U_BOOT_CMD( |
53677ef18 Big white-space c... |
1197 |
loopw, 4, 1, do_mem_loopw, |
2fb2604d5 Command usage cle... |
1198 |
"infinite write loop on address range", |
4d1fd7f1a Add 64-bit data s... |
1199 1200 1201 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA "[.b, .w, .l, .q] address number_of_objects data_to_write" #else |
a89c33db9 General help mess... |
1202 |
"[.b, .w, .l] address number_of_objects data_to_write" |
4d1fd7f1a Add 64-bit data s... |
1203 |
#endif |
56523f128 * Patch by Martin... |
1204 1205 |
); #endif /* CONFIG_LOOPW */ |
a2681707b Feature Removal: ... |
1206 |
#ifdef CONFIG_CMD_MEMTEST |
0d4983930 Patch by Kenneth ... |
1207 |
U_BOOT_CMD( |
b6fc6fd49 common: Iteration... |
1208 |
mtest, 5, 1, do_mem_mtest, |
a89c33db9 General help mess... |
1209 1210 |
"simple RAM read/write test", "[start [end [pattern [iterations]]]]" |
8bde7f776 * Code cleanup: |
1211 |
); |
a2681707b Feature Removal: ... |
1212 |
#endif /* CONFIG_CMD_MEMTEST */ |
8bde7f776 * Code cleanup: |
1213 |
|
4aaf29b2f memory commands "... |
1214 1215 |
#ifdef CONFIG_MX_CYCLIC U_BOOT_CMD( |
53677ef18 Big white-space c... |
1216 |
mdc, 4, 1, do_mem_mdc, |
2fb2604d5 Command usage cle... |
1217 |
"memory display cyclic", |
4d1fd7f1a Add 64-bit data s... |
1218 1219 1220 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA "[.b, .w, .l, .q] address count delay(ms)" #else |
a89c33db9 General help mess... |
1221 |
"[.b, .w, .l] address count delay(ms)" |
4d1fd7f1a Add 64-bit data s... |
1222 |
#endif |
4aaf29b2f memory commands "... |
1223 1224 1225 |
); U_BOOT_CMD( |
53677ef18 Big white-space c... |
1226 |
mwc, 4, 1, do_mem_mwc, |
2fb2604d5 Command usage cle... |
1227 |
"memory write cyclic", |
4d1fd7f1a Add 64-bit data s... |
1228 1229 1230 |
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA "[.b, .w, .l, .q] address value delay(ms)" #else |
a89c33db9 General help mess... |
1231 |
"[.b, .w, .l] address value delay(ms)" |
4d1fd7f1a Add 64-bit data s... |
1232 |
#endif |
4aaf29b2f memory commands "... |
1233 1234 |
); #endif /* CONFIG_MX_CYCLIC */ |
15a33e49d Add option to dis... |
1235 1236 1237 1238 1239 1240 1241 1242 |
#ifdef CONFIG_CMD_MEMINFO U_BOOT_CMD( meminfo, 3, 1, do_mem_info, "display memory information", "" ); #endif |