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