diag.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * (C) Copyright 2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. /*
  8. * Diagnostics support
  9. */
  10. #include <common.h>
  11. #include <command.h>
  12. #include <post.h>
  13. int do_diag (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  14. {
  15. unsigned int i;
  16. if (argc == 1 || strcmp (argv[1], "run") != 0) {
  17. /* List test info */
  18. if (argc == 1) {
  19. puts ("Available hardware tests:\n");
  20. post_info (NULL);
  21. puts ("Use 'diag [<test1> [<test2> ...]]'"
  22. " to get more info.\n");
  23. puts ("Use 'diag run [<test1> [<test2> ...]]'"
  24. " to run tests.\n");
  25. } else {
  26. for (i = 1; i < argc; i++) {
  27. if (post_info (argv[i]) != 0)
  28. printf ("%s - no such test\n", argv[i]);
  29. }
  30. }
  31. } else {
  32. /* Run tests */
  33. if (argc == 2) {
  34. post_run (NULL, POST_RAM | POST_MANUAL);
  35. } else {
  36. for (i = 2; i < argc; i++) {
  37. if (post_run (argv[i], POST_RAM | POST_MANUAL) != 0)
  38. printf ("%s - unable to execute the test\n",
  39. argv[i]);
  40. }
  41. }
  42. }
  43. return 0;
  44. }
  45. /***************************************************/
  46. U_BOOT_CMD(
  47. diag, CONFIG_SYS_MAXARGS, 0, do_diag,
  48. "perform board diagnostics",
  49. " - print list of available tests\n"
  50. "diag [test1 [test2]]\n"
  51. " - print information about specified tests\n"
  52. "diag run - run all available tests\n"
  53. "diag run [test1 [test2]]\n"
  54. " - run specified tests"
  55. );