mem.c 31 KB

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