blob: 1eead082ec30e3847108ccb61e374f5ec40a9059 [file] [log] [blame]
Ben Tyner117af992020-05-22 13:32:11 -05001#include <libpdbg.h>
2
Ben Tynerd3cda742020-05-04 08:00:28 -05003#include <analyzer/analyzer_main.hpp>
Ben Tynerb1ebfcb2020-05-08 18:52:48 -05004#include <attn/attention.hpp>
Ben Tynerd3cda742020-05-04 08:00:28 -05005#include <attn/attn_config.hpp>
Ben Tynerb1ebfcb2020-05-08 18:52:48 -05006#include <attn/attn_handler.hpp>
Ben Tynerd3cda742020-05-04 08:00:28 -05007#include <attn/attn_main.hpp>
8#include <cli.hpp>
9
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050010// FIXME TEMP CODE - begin
11
12namespace attn
13{
14int handleCheckstop(Attention* i_attention);
15} // namespace attn
16
17// FIXME TEMP CODE - end
18
19//
Ben Tynerd3cda742020-05-04 08:00:28 -050020/**
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 */
34int 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 // Either analyze (application mode) or daemon mode
48 if (true == getCliOption(argv, argv + argc, "--analyze"))
49 {
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050050 // errors that were isolated
51 std::map<std::string, std::string> errors;
52
53 rc = analyzer::analyzeHardware(errors); // analyze hardware
54
55 printf("analyzer isolated %i errors", (int)errors.size());
Ben Tynerd3cda742020-05-04 08:00:28 -050056 }
57 // daemon mode
58 else
59 {
60 if (true == getCliOption(argv, argv + argc, "--daemon"))
61 {
62 attn::Config attnConfig; // default config
63
Ben Tyner117af992020-05-22 13:32:11 -050064 pdbg_targets_init(nullptr); // initialize pdbg targets
65
Ben Tynerd3cda742020-05-04 08:00:28 -050066 attn::attnDaemon(&attnConfig); // start daemon
67 }
68 }
69 }
70
71 return rc;
72}