blob: 14ae04f2a681afc60c3e96297484289867d52585 [file] [log] [blame]
wdenka46d8212002-09-12 22:01:13 +00001/*
2 * (C) Copyright 2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenka46d8212002-09-12 22:01:13 +00006 */
7
8/*
9 * Diagnostics support
10 */
11#include <common.h>
12#include <command.h>
wdenka46d8212002-09-12 22:01:13 +000013#include <post.h>
14
Wolfgang Denk54841ab2010-06-28 22:00:46 +020015int do_diag (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
wdenka46d8212002-09-12 22:01:13 +000016{
17 unsigned int i;
18
19 if (argc == 1 || strcmp (argv[1], "run") != 0) {
20 /* List test info */
21 if (argc == 1) {
wdenk4b9206e2004-03-23 22:14:11 +000022 puts ("Available hardware tests:\n");
wdenka46d8212002-09-12 22:01:13 +000023 post_info (NULL);
wdenk4b9206e2004-03-23 22:14:11 +000024 puts ("Use 'diag [<test1> [<test2> ...]]'"
wdenka46d8212002-09-12 22:01:13 +000025 " to get more info.\n");
wdenk4b9206e2004-03-23 22:14:11 +000026 puts ("Use 'diag run [<test1> [<test2> ...]]'"
wdenka46d8212002-09-12 22:01:13 +000027 " to run tests.\n");
28 } else {
29 for (i = 1; i < argc; i++) {
30 if (post_info (argv[i]) != 0)
31 printf ("%s - no such test\n", argv[i]);
32 }
33 }
34 } else {
35 /* Run tests */
36 if (argc == 2) {
37 post_run (NULL, POST_RAM | POST_MANUAL);
38 } else {
39 for (i = 2; i < argc; i++) {
40 if (post_run (argv[i], POST_RAM | POST_MANUAL) != 0)
41 printf ("%s - unable to execute the test\n",
42 argv[i]);
43 }
44 }
45 }
46
47 return 0;
48}
wdenk8bde7f72003-06-27 21:31:46 +000049/***************************************************/
50
wdenk0d498392003-07-01 21:06:45 +000051U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020052 diag, CONFIG_SYS_MAXARGS, 0, do_diag,
Peter Tyser2fb26042009-01-27 18:03:12 -060053 "perform board diagnostics",
wdenk8bde7f72003-06-27 21:31:46 +000054 " - print list of available tests\n"
55 "diag [test1 [test2]]\n"
56 " - print information about specified tests\n"
57 "diag run - run all available tests\n"
58 "diag run [test1 [test2]]\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +020059 " - run specified tests"
wdenk8bde7f72003-06-27 21:31:46 +000060);