PEL: Look for JSON Guard & Deconfig fields

There are optional 'Guarded' and 'Deconfigured' fields in the callout
JSON.  If these are set, there are some bits in the SRC that should be
set.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I1bde74094fc596f383d683722d769615cba56975
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
index 1861608..226bc28 100644
--- a/extensions/openpower-pels/src.cpp
+++ b/extensions/openpower-pels/src.cpp
@@ -666,6 +666,18 @@
         }
         // The PEL spec calls it a backplane, so call it that here.
         jsonInsert(ps, "Backplane CCIN", ccinString, 1);
+
+        jsonInsert(ps, "Deconfigured",
+                   pv::boolString.at(
+                       _hexData[3] &
+                       static_cast<uint32_t>(ErrorStatusFlags::deconfigured)),
+                   1);
+
+        jsonInsert(
+            ps, "Guarded",
+            pv::boolString.at(_hexData[3] &
+                              static_cast<uint32_t>(ErrorStatusFlags::guarded)),
+            1);
     }
 
     auto errorDetails = getErrorDetails(registry, DetailLevel::json, true);
@@ -1158,6 +1170,22 @@
         }
 
         addInventoryCallout(inventoryPath, priority, lc, dataIface, mrus);
+
+        if (jsonCallout.contains("Deconfigured"))
+        {
+            if (jsonCallout.at("Deconfigured").get<bool>())
+            {
+                setErrorStatusFlag(ErrorStatusFlags::deconfigured);
+            }
+        }
+
+        if (jsonCallout.contains("Guarded"))
+        {
+            if (jsonCallout.at("Guarded").get<bool>())
+            {
+                setErrorStatusFlag(ErrorStatusFlags::guarded);
+            }
+        }
     }
 
     if (callout)
diff --git a/extensions/openpower-pels/src.hpp b/extensions/openpower-pels/src.hpp
index 9757a92..264fab2 100644
--- a/extensions/openpower-pels/src.hpp
+++ b/extensions/openpower-pels/src.hpp
@@ -57,6 +57,16 @@
         virtualProgressSRC = 0x80
     };
 
+    /**
+     * @brief Enums for the error status bits in hex word 5
+     *        of BMC SRCs.
+     */
+    enum class ErrorStatusFlags
+    {
+        deconfigured = 0x02000000,
+        guarded = 0x01000000
+    };
+
     SRC() = delete;
     ~SRC() = default;
     SRC(const SRC&) = delete;
@@ -340,6 +350,16 @@
     void setMotherboardCCIN(const DataInterfaceBase& dataIface);
 
     /**
+     * @brief Sets an error status bit in the SRC.
+     *
+     * @param[in] flag - The flag to set
+     */
+    void setErrorStatusFlag(ErrorStatusFlags flag)
+    {
+        _hexData[3] |= static_cast<uint32_t>(flag);
+    }
+
+    /**
      * @brief Validates the section contents
      *
      * Updates _valid (in Section) with the results.
diff --git a/test/openpower-pels/src_test.cpp b/test/openpower-pels/src_test.cpp
index 5795ece..fc80d1d 100644
--- a/test/openpower-pels/src_test.cpp
+++ b/test/openpower-pels/src_test.cpp
@@ -977,6 +977,9 @@
     SRC src{entry, ad, jsonCallouts, dataIface};
     ASSERT_TRUE(src.callouts());
 
+    // Check the guarded and deconfigured flags
+    EXPECT_TRUE(src.hexwordData()[3] & 0x03000000);
+
     const auto& callouts = src.callouts()->callouts();
     ASSERT_EQ(callouts.size(), 6);