blob: 4e73e037ddc2a7f6fa77d52826578024b0766bc0 [file] [log] [blame]
Ben Tyner0205f3b2020-02-24 10:24:47 -06001#include <libpdbg.h>
2
3#include <analyzer/analyzer_main.hpp>
4#include <attn/attn_main.hpp>
Ben Tyner7212d212020-03-31 09:44:41 -05005#include <cli.hpp>
Ben Tyner0205f3b2020-02-24 10:24:47 -06006
7/**
8 * @brief Attention handler application main()
9 *
10 * This is the main interface to the hardware diagnostics application. This
11 * application will either be loaded as a daemon for monitoring the attention
12 * gpio or it will be loaded as an application to analyze hardware and
13 * diagnose hadrware error conditions.
14 *
15 * Command line arguments:
16 *
Ben Tyner3fb52e52020-03-31 10:10:07 -050017 * commands:
18 *
19 * analyze analyze hardware
20 *
21 * options:
22 *
23 * --daemon load application as a daemon
24 * --vital off disable vital attention handling (daemon mode)
25 * --checkstop off disable checkstop attention handling (daemon mode)
26 * --terminate off disable TI attention handling (daemon mode)
27 * --breakpoints off disable breakpoint attention handling (daemon mode)
28 *
29 * example:
30 *
31 * openpower-hw-diags --daemon --terminate off
Ben Tyner0205f3b2020-02-24 10:24:47 -060032 *
33 * @return 0 = success
34 */
35int main(int argc, char* argv[])
36{
37 int rc = 0; // return code
38
Ben Tyner3fb52e52020-03-31 10:10:07 -050039 // attention handler configuration flags
40 bool vital_enable = true;
41 bool checkstop_enable = true;
42 bool ti_enable = true;
43 bool bp_enable = true;
44
Ben Tyner0205f3b2020-02-24 10:24:47 -060045 // initialize pdbg targets
46 pdbg_targets_init(nullptr);
47
Ben Tyner3fb52e52020-03-31 10:10:07 -050048 // get configuration options
49 parseConfig(argv, argv + argc, vital_enable, checkstop_enable, ti_enable,
50 bp_enable);
Ben Tyner0205f3b2020-02-24 10:24:47 -060051
52 // check if we are being loaded as a daemon
53 if (true == getCliOption(argv, argv + argc, "--daemon"))
54 {
Ben Tyner3fb52e52020-03-31 10:10:07 -050055 attn::Config config(vital_enable, checkstop_enable, ti_enable,
56 bp_enable);
Ben Tyner0205f3b2020-02-24 10:24:47 -060057
58 // Configure and start attention monitor
Ben Tyner3fb52e52020-03-31 10:10:07 -050059 attn::attnDaemon(&config);
Ben Tyner0205f3b2020-02-24 10:24:47 -060060 }
Ben Tyner3fb52e52020-03-31 10:10:07 -050061 // we are being loaded as an application
Ben Tyner0205f3b2020-02-24 10:24:47 -060062 else
63 {
64 // Request to analyze the hardware for error conditions
65 if (true == getCliOption(argv, argv + argc, "analyze"))
66 {
67 analyzer::analyzeHardware();
68 }
69 }
70
71 return rc;
72}