cmd_diag.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * (C) Copyright 2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /*
  24. * Diagnostics support
  25. */
  26. #include <common.h>
  27. #include <command.h>
  28. #include <post.h>
  29. #if (CONFIG_COMMANDS & CFG_CMD_DIAG) && defined(CONFIG_POST)
  30. int do_diag (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  31. {
  32. unsigned int i;
  33. if (argc == 1 || strcmp (argv[1], "run") != 0) {
  34. /* List test info */
  35. if (argc == 1) {
  36. puts ("Available hardware tests:\n");
  37. post_info (NULL);
  38. puts ("Use 'diag [<test1> [<test2> ...]]'"
  39. " to get more info.\n");
  40. puts ("Use 'diag run [<test1> [<test2> ...]]'"
  41. " to run tests.\n");
  42. } else {
  43. for (i = 1; i < argc; i++) {
  44. if (post_info (argv[i]) != 0)
  45. printf ("%s - no such test\n", argv[i]);
  46. }
  47. }
  48. } else {
  49. /* Run tests */
  50. if (argc == 2) {
  51. post_run (NULL, POST_RAM | POST_MANUAL);
  52. } else {
  53. for (i = 2; i < argc; i++) {
  54. if (post_run (argv[i], POST_RAM | POST_MANUAL) != 0)
  55. printf ("%s - unable to execute the test\n",
  56. argv[i]);
  57. }
  58. }
  59. }
  60. return 0;
  61. }
  62. /***************************************************/
  63. U_BOOT_CMD(
  64. diag, CFG_MAXARGS, 0, do_diag,
  65. "diag - perform board diagnostics\n",
  66. " - print list of available tests\n"
  67. "diag [test1 [test2]]\n"
  68. " - print information about specified tests\n"
  69. "diag run - run all available tests\n"
  70. "diag run [test1 [test2]]\n"
  71. " - run specified tests\n"
  72. );
  73. #endif /* CFG_CMD_DIAG */