Attention Handler gpio monitor

Register an async-io service for monitoring the attention GPIO and use the attention handler as the GPIO event handler. The GPIO monitor will respond to changes on the attention GPIO and in response will call the attention handler base logic to handle the attention events.

Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: I3cdc0cb34bc3067b54cb64ab49d98fa2182e7fa1
diff --git a/attn/attn_main.cpp b/attn/attn_main.cpp
index dda1fc8..e4766f0 100644
--- a/attn/attn_main.cpp
+++ b/attn/attn_main.cpp
@@ -1,6 +1,7 @@
 #include <libpdbg.h>
 
 #include <attn_handler.hpp>
+#include <attn_monitor.hpp>
 
 /**
  * @brief Attention handler application main()
@@ -14,8 +15,34 @@
 {
     int rc = 0; // return code
 
+    gpiod_line* line; // gpio line to monitor
+
+    boost::asio::io_service io; // async io monitoring service
+
     // initialize pdbg targets
     pdbg_targets_init(nullptr);
 
+    // GPIO line configuration (falling edge, active low)
+    struct gpiod_line_request_config config
+    {
+        "attention", GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE, 0
+    };
+
+    // get handle to attention GPIO line
+    line = gpiod_line_get("gpiochip0", 74);
+
+    if (nullptr == line)
+    {
+        rc = 1; // error
+    }
+    else
+    {
+        // Creating a vector of one gpio to monitor
+        std::vector<std::unique_ptr<attn::AttnMonitor>> gpios;
+        gpios.push_back(std::make_unique<attn::AttnMonitor>(line, config, io));
+
+        io.run(); // start GPIO monitor
+    }
+
     return rc;
 }