Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 1 | #include <libpdbg.h> |
| 2 | |
| 3 | #include <analyzer/analyzer_main.hpp> |
| 4 | #include <attn/attn_main.hpp> |
Ben Tyner | 7212d21 | 2020-03-31 09:44:41 -0500 | [diff] [blame^] | 5 | #include <cli.hpp> |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 6 | |
| 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 | */ |
| 23 | int 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 | } |