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.cpp b/extensions/openpower-pels/sbe_ffdc_handler.cpp
new file mode 100644
index 0000000..55e3cbe
--- /dev/null
+++ b/extensions/openpower-pels/sbe_ffdc_handler.cpp
@@ -0,0 +1,74 @@
+/**
+ * Copyright © 2021 IBM Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sbe_ffdc_handler.hpp"
+
+#include <fmt/format.h>
+
+#include <phosphor-logging/log.hpp>
+
+namespace openpower
+{
+namespace pels
+{
+namespace sbe
+{
+
+using namespace phosphor::logging;
+
+SbeFFDC::SbeFFDC(const AdditionalData& aData, const PelFFDC& files)
+{
+    log<level::INFO>("SBE FFDC processing requested");
+
+    // SRC6 field in the additional data contains Processor position
+    // associated to the SBE FFDC
+    //"[0:15] chip position"
+    auto src6 = aData.getValue("SRC6");
+    if (src6 == std::nullopt)
+    {
+        log<level::ERR>("Fail to extract SRC6 data: failing to get proc index");
+        return;
+    }
+    try
+    {
+        procPos = std::stoi((src6.value()).substr(0, 4));
+    }
+    catch (std::exception& err)
+    {
+        log<level::ERR>(
+            fmt::format("Conversion failure errormsg({})", err.what()).c_str());
+        return;
+    }
+
+    if (files.empty())
+    {
+        log<level::INFO>("SbeFFDC : No files found, skipping ffdc processing");
+        return;
+    }
+
+    for (const auto& file : files)
+    {
+        if ((file.format == UserDataFormat::custom) &&
+            (file.subType == sbeFFDCSubType))
+        {
+            // TODO Process SBE file.
+        }
+    }
+}
+
+} // namespace sbe
+} // namespace pels
+} // namespace openpower