Combine attn handler and openpower hwdiags

The main binary is now openpower-hw-diags. This application will take a
command line option --daemon to load it as a daemon. As a daemon it will
register the attention handler portion of application as the attention
gpio event handler. If the application is not loaded as a daemon it will
operate as a stand alone application which accepts command line options
for requesting hardware analyses and diagnostics operations.

Change-Id: I6210b744cb320873d74a0757928f904ca6296846
Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
diff --git a/analyzer/analyzer_main.cpp b/analyzer/analyzer_main.cpp
new file mode 100644
index 0000000..73e8f51
--- /dev/null
+++ b/analyzer/analyzer_main.cpp
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+#include <hei_main.hpp>
+
+namespace analyzer
+{
+
+/** @brief Analyze and isolate hardware errors */
+void analyzeHardware()
+{
+    printf("analyzeHardware()\n");
+}
+
+} // namespace analyzer
diff --git a/analyzer/analyzer_main.hpp b/analyzer/analyzer_main.hpp
new file mode 100644
index 0000000..d7199b5
--- /dev/null
+++ b/analyzer/analyzer_main.hpp
@@ -0,0 +1,14 @@
+#pragma once
+
+namespace analyzer
+{
+
+/**
+ * @brief Analyze and isolate hardware errors
+ *
+ * If any error conditions are found on the host isolate the hardware
+ * component that caused the error(s).
+ */
+void analyzeHardware();
+
+} // namespace analyzer
diff --git a/analyzer/hei_user_defines.hpp b/analyzer/hei_user_defines.hpp
new file mode 100644
index 0000000..e45e18d
--- /dev/null
+++ b/analyzer/hei_user_defines.hpp
@@ -0,0 +1,25 @@
+#pragma once
+
+/**
+ * @file hei_user_defines.hpp
+ * @brief The purpose of this file is to provide defines that are required by
+ *        the hardware error isolator library (libhei)
+ */
+
+#include <assert.h>
+#include <inttypes.h>
+#include <stdio.h>
+
+#define HEI_INF(...)                                                           \
+    {                                                                          \
+        printf("HWDIAGS I> " __VA_ARGS__);                                     \
+        printf("\n");                                                          \
+    }
+
+#define HEI_ERR(...)                                                           \
+    {                                                                          \
+        printf("HWDIAGS E> " __VA_ARGS__);                                     \
+        printf("\n");                                                          \
+    }
+
+#define HEI_ASSERT(expression) assert(expression);
diff --git a/analyzer/meson.build b/analyzer/meson.build
new file mode 100644
index 0000000..fd0f7da
--- /dev/null
+++ b/analyzer/meson.build
@@ -0,0 +1,10 @@
+# Get opennpower-libhei dependencies. If not available via package manager
+# "fallback" to using the local libhei subproject.
+libhei_dep = dependency('libhei', fallback : ['libhei', 'libhei_dep'])
+
+# Create hardware error analyzer library
+analyzer = static_library('analyzer',
+                          'analyzer_main.cpp',
+                          'user_interface.cpp',
+                          dependencies : libhei_dep,
+                          install : true)
diff --git a/analyzer/user_interface.cpp b/analyzer/user_interface.cpp
new file mode 100644
index 0000000..e51b206
--- /dev/null
+++ b/analyzer/user_interface.cpp
@@ -0,0 +1,43 @@
+/**
+ * @file These are implementations of the user interfaces declared in
+ *       hei_user_interface.hpp
+ */
+
+#include <hei_user_interface.hpp>
+
+namespace libhei
+{
+
+//------------------------------------------------------------------------------
+
+ReturnCode registerRead(const Chip& i_chip, void* o_buffer, size_t& io_bufSize,
+                        uint64_t i_regType, uint64_t i_address)
+{
+    ReturnCode rc = RC_SUCCESS;
+
+    //    HEI_INF("registerRead(%p,%p,%lx,%lx,%lx)", i_chip.getChip(),
+    //             o_buffer, io_bufSize, i_regType, i_address);
+
+    return rc;
+}
+
+//------------------------------------------------------------------------------
+
+#ifndef __HEI_READ_ONLY
+
+ReturnCode registerWrite(const Chip& i_chip, void* i_buffer, size_t& io_bufSize,
+                         uint64_t i_regType, uint64_t i_address)
+{
+    ReturnCode rc = RC_SUCCESS;
+
+    //    HEI_INF("registerWrite(%p,%p,%lx,%lx,%lx)", i_chip.getChip(),
+    //             i_buffer, io_bufSize, i_regType, i_address);
+
+    return rc;
+}
+
+#endif
+
+//------------------------------------------------------------------------------
+
+} // namespace libhei