mem.c 31 KB

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