wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * Diagnostics support |
| 10 | */ |
| 11 | #include <common.h> |
| 12 | #include <command.h> |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 13 | #include <post.h> |
| 14 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 15 | int do_diag (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 16 | { |
| 17 | unsigned int i; |
| 18 | |
| 19 | if (argc == 1 || strcmp (argv[1], "run") != 0) { |
| 20 | /* List test info */ |
| 21 | if (argc == 1) { |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 22 | puts ("Available hardware tests:\n"); |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 23 | post_info (NULL); |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 24 | puts ("Use 'diag [<test1> [<test2> ...]]'" |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 25 | " to get more info.\n"); |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 26 | puts ("Use 'diag run [<test1> [<test2> ...]]'" |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 27 | " 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 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 49 | /***************************************************/ |
| 50 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 51 | U_BOOT_CMD( |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 52 | diag, CONFIG_SYS_MAXARGS, 0, do_diag, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 53 | "perform board diagnostics", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 54 | " - 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 Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 59 | " - run specified tests" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 60 | ); |