mem.c 32 KB

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