uboot/common/cmd_diag.c
<<
>>
Prefs
   1/*
   2 * (C) Copyright 2002
   3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
   4 *
   5 * SPDX-License-Identifier:     GPL-2.0+
   6 */
   7
   8/*
   9 * Diagnostics support
  10 */
  11#include <common.h>
  12#include <command.h>
  13#include <post.h>
  14
  15int do_diag (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  16{
  17        unsigned int i;
  18
  19        if (argc == 1 || strcmp (argv[1], "run") != 0) {
  20                /* List test info */
  21                if (argc == 1) {
  22                        puts ("Available hardware tests:\n");
  23                        post_info (NULL);
  24                        puts ("Use 'diag [<test1> [<test2> ...]]'"
  25                                        " to get more info.\n");
  26                        puts ("Use 'diag run [<test1> [<test2> ...]]'"
  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}
  49/***************************************************/
  50
  51U_BOOT_CMD(
  52        diag,   CONFIG_SYS_MAXARGS,     0,      do_diag,
  53        "perform board diagnostics",
  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"
  59        "         - run specified tests"
  60);
  61