blob: bb43990a125eafc5c3162be799579d909ce0eb54 [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 *
17 * analyze analyze hardware
18 * --daemon load application as a daemon
19 * --breakpoints enable breakpoint special attn handling (in daemon mode)
20 *
21 * @return 0 = success
22 */
23int main(int argc, char* argv[])
24{
25 int rc = 0; // return code
26
27 // initialize pdbg targets
28 pdbg_targets_init(nullptr);
29
30 // TODO Handle target init fail
31
32 // check if we are being loaded as a daemon
33 if (true == getCliOption(argv, argv + argc, "--daemon"))
34 {
35 // Check command line args for breakpoint handling enable option
36 bool bp_enable = getCliOption(argv, argv + argc, "--breakpoints");
37
38 // Configure and start attention monitor
39 attn::attnDaemon(bp_enable);
40 }
41 // We are being loaded as an application, so parse the command line
42 // arguments to determine what operation is being requested.
43 else
44 {
45 // Request to analyze the hardware for error conditions
46 if (true == getCliOption(argv, argv + argc, "analyze"))
47 {
48 analyzer::analyzeHardware();
49 }
50 }
51
52 return rc;
53}