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 // 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 // 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 { 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 55 // Either analyze (application mode) or daemon mode 56 if (true == getCliOption(argv, argv + argc, "--analyze")) 57 { 58 // errors that were isolated 59 std::map<std::string, std::string> errors; 60 61 rc = analyzer::analyzeHardware(errors); // analyze hardware 62 63 printf("analyzer isolated %i error(s)\n", (int)errors.size()); 64 } 65 // daemon mode 66 else 67 { 68 if (true == getCliOption(argv, argv + argc, "--daemon")) 69 { 70 attn::Config attnConfig; // default config 71 72 pdbg_targets_init(nullptr); // initialize pdbg targets 73 74 attn::attnDaemon(&attnConfig); // start daemon 75 } 76 } 77 } 78 79 return rc; 80 } 81