PEL: Write terminating SRC to the progress SRC

Check for incoming pels for severity type 0x51 - Critical error,
System termination. If found, fetch the SRC and add this SRC to
progress SRC interface on dbus. In addition set the terminate bit
in BMC created pels only.

Signed-off-by: Sumit Kumar <sumit_kumar@in.ibm.com>
Change-Id: I26194a26743263183dcb61e097c745c4705fa006
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
index 4279a00..5984287 100644
--- a/extensions/openpower-pels/src.cpp
+++ b/extensions/openpower-pels/src.cpp
@@ -719,6 +719,11 @@
         // The PEL spec calls it a backplane, so call it that here.
         jsonInsert(ps, "Backplane CCIN", ccinString, 1);
 
+        jsonInsert(ps, "Terminate FW Error",
+                   pv::boolString.at(
+                       _hexData[3] &
+                       static_cast<uint32_t>(ErrorStatusFlags::terminateFwErr)),
+                   1);
         jsonInsert(ps, "Deconfigured",
                    pv::boolString.at(
                        _hexData[3] &
@@ -1436,5 +1441,46 @@
     }
 }
 
+std::vector<uint8_t> SRC::getSrcStruct()
+{
+    std::vector<uint8_t> data;
+    Stream stream{data};
+
+    //------ Ref section 4.3 in PEL doc---
+    //------ SRC Structure 40 bytes-------
+    // Byte-0 | Byte-1 | Byte-2 | Byte-3 |
+    // -----------------------------------
+    //   02   |   08   |   00   |   09   | ==> Header
+    //   00   |   00   |   00   |   48   | ==> Header
+    //   00   |   00   |   00   |   00   | ==> Hex data word-2
+    //   00   |   00   |   00   |   00   | ==> Hex data word-3
+    //   00   |   00   |   00   |   00   | ==> Hex data word-4
+    //   20   |   00   |   00   |   00   | ==> Hex data word-5
+    //   00   |   00   |   00   |   00   | ==> Hex data word-6
+    //   00   |   00   |   00   |   00   | ==> Hex data word-7
+    //   00   |   00   |   00   |   00   | ==> Hex data word-8
+    //   00   |   00   |   00   |   00   | ==> Hex data word-9
+    // -----------------------------------
+    //   ASCII string - 8 bytes          |
+    // -----------------------------------
+    //   ASCII space NULL - 24 bytes     |
+    // -----------------------------------
+    //_size = Base SRC struct: 8 byte header + hex data section + ASCII string
+
+    uint8_t flags = (_flags | postOPPanel);
+
+    stream << _version << flags << _reserved1B << _wordCount << _reserved2B
+           << _size;
+
+    for (auto& word : _hexData)
+    {
+        stream << word;
+    }
+
+    _asciiString->flatten(stream);
+
+    return data;
+}
+
 } // namespace pels
 } // namespace openpower