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 | * |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame^] | 17 | * 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 Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 32 | * |
| 33 | * @return 0 = success |
| 34 | */ |
| 35 | int main(int argc, char* argv[]) |
| 36 | { |
| 37 | int rc = 0; // return code |
| 38 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame^] | 39 | // 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 Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 45 | // initialize pdbg targets |
| 46 | pdbg_targets_init(nullptr); |
| 47 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame^] | 48 | // get configuration options |
| 49 | parseConfig(argv, argv + argc, vital_enable, checkstop_enable, ti_enable, |
| 50 | bp_enable); |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 51 | |
| 52 | // check if we are being loaded as a daemon |
| 53 | if (true == getCliOption(argv, argv + argc, "--daemon")) |
| 54 | { |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame^] | 55 | attn::Config config(vital_enable, checkstop_enable, ti_enable, |
| 56 | bp_enable); |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 57 | |
| 58 | // Configure and start attention monitor |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame^] | 59 | attn::attnDaemon(&config); |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 60 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame^] | 61 | // we are being loaded as an application |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 62 | 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 | } |