diag.c 1.4 KB

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