PEL: enable base infrastructure for SBE FFDC base PEL create

This commits provides the base infrastructure for SBE FFDC based
on createPELWithFFDCFiles`D-Bus method on the
org.open_power.Logging.PEL.

More details related to usage of this interface is documented
as part of extensions/openpower-pels/README.md.

In the PEL create interface if the type is custom and subtype
is 0xCB, PEL class function invokes SBE FFDC function to process
SBE FFDC to extract Hardware procedure added user data section and
callouts. SBE FFDC class appends the callout json and create
user data file based FFDC information and continue the normal
PEL create function.

SCOPE of this commit:
 - Add base infrastructure and control build only for "phal" supported
   systems. "phal" feature is mandatory requirement for processing
   SBE FFDC.
 - Add SBE FFDC raw information in PEL user data section

To enable this feature use the below meson build options
  meson build -Dopenpower-pel-extension=enabled -Dphal=enabled

Tested:

"Error Details": {
        "Message":"chipop timeout reported during SBE communication",
        "SRC6": [
           "0x2",
           "[0:15] chip position, [16:23] command class,
            [24:31] command type"
        ]
    },

"User Data 2": {
    "Section Version":          "1",
    "Sub-section type":         "203",
    "Created by":               "0x3500",
    "Data": [
        "FF DC 00 12 00 00 A1 01  00 8E CE 72 00 00 FF FE  |  ...........r....",
        "00 00 00 04 00 00 00 00  00 00 00 04 00 00 00 00  |  ................",
        "00 00 00 00 00 00 00 01  00 00 00 00 00 00 00 02  |  ................",
        "00 00 00 04 00 00 00 00  00 00 00 00 00 00 00 04  |  ................",
        "00 00 00 00 00 00 00 00                           |  ........"
    ]
}

Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Change-Id: I2200b3ba9c0977be13e71f25e87f0b16cb50ec5b
diff --git a/extensions/openpower-pels/sbe_ffdc_handler.hpp b/extensions/openpower-pels/sbe_ffdc_handler.hpp
new file mode 100644
index 0000000..efdaa03
--- /dev/null
+++ b/extensions/openpower-pels/sbe_ffdc_handler.hpp
@@ -0,0 +1,109 @@
+#pragma once
+
+#include "additional_data.hpp"
+#include "pel.hpp"
+
+namespace openpower
+{
+namespace pels
+{
+namespace sbe
+{
+
+// SBE FFDC sub type.
+constexpr uint8_t sbeFFDCSubType = 0xCB;
+
+/** @class SbeFFDC
+ *
+ * @brief This class provides higher level interface to process SBE ffdc
+ * for PEL based error logging infrastructure.
+ * Key Functionalities included here
+ *    - Process the SBE FFDC data with the help of FAPI infrastructure and
+ *      and create PEL required format Callout and user data for hardware
+ *      procedure failures specific reason code
+ *    - Add the user data section with SBE FFDC data to support SBE provided
+ *      parser tool usage.
+ *    - Any SBE FFDC processing will result additional log message in journal
+ *      and will continue to create Error log with available data. This is to
+ *      help user to analyse the failure.
+ */
+class SbeFFDC
+{
+  public:
+    SbeFFDC() = delete;
+    SbeFFDC(const SbeFFDC&) = delete;
+    SbeFFDC& operator=(const SbeFFDC&) = delete;
+    SbeFFDC(SbeFFDC&&) = delete;
+    SbeFFDC& operator=(SbeFFDC&&) = delete;
+
+    /**
+     * @brief Constructor
+     *
+     * Create PEL required format data from SBE provided FFDC data.
+     *
+     * @param[in] data - The AdditionalData properties in this PEL event
+     * @param[in] files - FFDC files that go into UserData sections
+     */
+    SbeFFDC(const AdditionalData& data, const PelFFDC& files);
+
+    /**
+     * @brief Destructor
+     *
+     * Deletes the temporary files
+     */
+    ~SbeFFDC()
+    {
+
+        try
+        {
+            for (auto path : paths)
+            {
+                if (!path.empty())
+                {
+                    // Delete temporary file from file system
+                    std::error_code ec;
+                    std::filesystem::remove(path, ec);
+                    // Clear path to indicate file has been deleted
+                    path.clear();
+                }
+            }
+        }
+        catch (...)
+        {
+            // Destructors should not throw exceptions
+        }
+    }
+
+    /**
+     * @brief Helper function to return FFDC files information, which
+     *        includes SBE FFDC specific callout information.
+     *
+     * return PelFFDC - pel formated FFDC files.
+     */
+    const PelFFDC& getSbeFFDC()
+    {
+        return ffdcFiles;
+    }
+
+  private:
+    /**
+     * @brief  Temporary files path information created as part of FFDC
+     *         processing.
+     */
+    std::vector<std::filesystem::path> paths;
+
+    /**
+     * @brief PEL FFDC files, which includes the user data sections and the
+     *        added callout details if any, found during SBE FFDC processing.
+     */
+    PelFFDC ffdcFiles;
+
+    /**
+     * @brief Processor position associated to SBE FFDC
+     */
+    uint32_t procPos;
+};
+
+} // namespace sbe
+} // namespace pels
+} // namespace openpower