Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2002 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * Diagnostics support |
| 9 | */ |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 10 | #include <command.h> |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 11 | #include <post.h> |
| 12 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 13 | int do_diag(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 14 | { |
| 15 | unsigned int i; |
| 16 | |
| 17 | if (argc == 1 || strcmp (argv[1], "run") != 0) { |
| 18 | /* List test info */ |
| 19 | if (argc == 1) { |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 20 | puts ("Available hardware tests:\n"); |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 21 | post_info (NULL); |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 22 | puts ("Use 'diag [<test1> [<test2> ...]]'" |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 23 | " to get more info.\n"); |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 24 | puts ("Use 'diag run [<test1> [<test2> ...]]'" |
wdenk | a46d821 | 2002-09-12 22:01:13 +0000 | [diff] [blame] | 25 | " to run tests.\n"); |
| 26 | } else { |
| 27 | for (i = 1; i < argc; i++) { |
| 28 | if (post_info (argv[i]) != 0) |
| 29 | printf ("%s - no such test\n", argv[i]); |
| 30 | } |
| 31 | } |
| 32 | } else { |
| 33 | /* Run tests */ |
| 34 | if (argc == 2) { |
| 35 | post_run (NULL, POST_RAM | POST_MANUAL); |
| 36 | } else { |
| 37 | for (i = 2; i < argc; i++) { |
| 38 | if (post_run (argv[i], POST_RAM | POST_MANUAL) != 0) |
| 39 | printf ("%s - unable to execute the test\n", |
| 40 | argv[i]); |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return 0; |
| 46 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 47 | /***************************************************/ |
| 48 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 49 | U_BOOT_CMD( |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 50 | diag, CONFIG_SYS_MAXARGS, 0, do_diag, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 51 | "perform board diagnostics", |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 52 | " - print list of available tests\n" |
| 53 | "diag [test1 [test2]]\n" |
| 54 | " - print information about specified tests\n" |
| 55 | "diag run - run all available tests\n" |
| 56 | "diag run [test1 [test2]]\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 57 | " - run specified tests" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 58 | ); |