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