Ben Tyner | 117af99 | 2020-05-22 13:32:11 -0500 | [diff] [blame] | 1 | #include <libpdbg.h> |
| 2 | |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 3 | #include <analyzer/analyzer_main.hpp> |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 4 | #include <attn/attention.hpp> |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 5 | #include <attn/attn_config.hpp> |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 6 | #include <attn/attn_handler.hpp> |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 7 | #include <attn/attn_main.hpp> |
| 8 | #include <cli.hpp> |
| 9 | |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 10 | // FIXME TEMP CODE - begin |
| 11 | |
| 12 | namespace attn |
| 13 | { |
| 14 | int handleCheckstop(Attention* i_attention); |
| 15 | } // namespace attn |
| 16 | |
| 17 | // FIXME TEMP CODE - end |
| 18 | |
| 19 | // |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 20 | /** |
| 21 | * @brief Attention handler application main() |
| 22 | * |
| 23 | * This is the main interface to the hardware diagnostics application. This |
| 24 | * application can be loaded as a daemon for monitoring the attention |
| 25 | * gpio or it can be loaded as an application to analyze hardware and |
| 26 | * diagnose hardware error conditions. |
| 27 | * |
| 28 | * Usage: |
| 29 | * --analyze: Analyze the hardware |
| 30 | * --daemon: Start the attention handler daemon |
| 31 | * |
| 32 | * @return 0 = success |
| 33 | */ |
| 34 | int main(int argc, char* argv[]) |
| 35 | { |
| 36 | int rc = 0; // assume success |
| 37 | |
| 38 | if (argc == 1) |
| 39 | { |
| 40 | printf("openpower-hw-diags <options>\n"); |
| 41 | printf("options:\n"); |
| 42 | printf(" --analyze: Analyze the hardware\n"); |
| 43 | printf(" --daemon: Start the attn handler daemon\n"); |
| 44 | } |
| 45 | else |
| 46 | { |
Ben Tyner | 87eabc6 | 2020-05-14 17:56:54 -0500 | [diff] [blame] | 47 | // Pdbg targets should only be initialized once according to |
| 48 | // libpdbg documentation. Initializing them here will make sure |
| 49 | // they are initialized for the attention handler, invocation of |
| 50 | // the analyzer via attention handler and direct invocation of |
| 51 | // the analyzer via command line (--analyze). |
| 52 | |
| 53 | pdbg_targets_init(nullptr); // nullptr == use default fdt |
| 54 | |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 55 | // Either analyze (application mode) or daemon mode |
| 56 | if (true == getCliOption(argv, argv + argc, "--analyze")) |
| 57 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 58 | // errors that were isolated |
| 59 | std::map<std::string, std::string> errors; |
| 60 | |
| 61 | rc = analyzer::analyzeHardware(errors); // analyze hardware |
| 62 | |
Ben Tyner | 87eabc6 | 2020-05-14 17:56:54 -0500 | [diff] [blame] | 63 | printf("analyzer isolated %i error(s)\n", (int)errors.size()); |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 64 | } |
| 65 | // daemon mode |
| 66 | else |
| 67 | { |
| 68 | if (true == getCliOption(argv, argv + argc, "--daemon")) |
| 69 | { |
| 70 | attn::Config attnConfig; // default config |
| 71 | |
Ben Tyner | 117af99 | 2020-05-22 13:32:11 -0500 | [diff] [blame] | 72 | pdbg_targets_init(nullptr); // initialize pdbg targets |
| 73 | |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 74 | attn::attnDaemon(&attnConfig); // start daemon |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | return rc; |
| 80 | } |