PEL: Support for CheckstopFlag msg reg field

Similiar to the DeconfigFlag field that was recently added, this one
indicates the PEL is for a hardware checkstop and results in a bit in
SRC hex word 5 being set.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ib05de7471ad3e32f48e7f20a5c611abc119fe82a
diff --git a/extensions/openpower-pels/registry.cpp b/extensions/openpower-pels/registry.cpp
index aeba998..a96f661 100644
--- a/extensions/openpower-pels/registry.cpp
+++ b/extensions/openpower-pels/registry.cpp
@@ -195,6 +195,11 @@
     return src["DeconfigFlag"].get<bool>();
 }
 
+bool getSRCCheckstopFlag(const nlohmann::json& src)
+{
+    return src["CheckstopFlag"].get<bool>();
+}
+
 std::optional<std::map<SRC::WordNum, SRC::AdditionalDataField>>
     getSRCHexwordFields(const nlohmann::json& src, const std::string& name)
 {
@@ -745,6 +750,11 @@
                 entry.src.deconfigFlag = helper::getSRCDeconfigFlag(src);
             }
 
+            if (src.contains("CheckstopFlag"))
+            {
+                entry.src.checkstopFlag = helper::getSRCCheckstopFlag(src);
+            }
+
             auto& doc = (*e)["Documentation"];
             entry.doc.message = doc["Message"];
             entry.doc.description = doc["Description"];
diff --git a/extensions/openpower-pels/registry.hpp b/extensions/openpower-pels/registry.hpp
index e72fafb..cd39b3f 100644
--- a/extensions/openpower-pels/registry.hpp
+++ b/extensions/openpower-pels/registry.hpp
@@ -110,7 +110,12 @@
      */
     bool deconfigFlag;
 
-    SRC() : type(0), reasonCode(0), deconfigFlag(false) {}
+    /**
+     * @brief If the checkstop flag should be set in hex word 5
+     */
+    bool checkstopFlag;
+
+    SRC() : type(0), reasonCode(0), deconfigFlag(false), checkstopFlag(false) {}
 };
 
 struct AppCapture
diff --git a/extensions/openpower-pels/registry/README.md b/extensions/openpower-pels/registry/README.md
index f914bfc..05a35e9 100644
--- a/extensions/openpower-pels/registry/README.md
+++ b/extensions/openpower-pels/registry/README.md
@@ -253,6 +253,15 @@
 "DeconfigFlag": true
 ```
 
+### SRC Checkstop Flag
+
+This is used to indicate the PEL is for a hardware checkstop, and causes bit 0
+in hex word 5 of the SRC to be set.
+
+```json
+"CheckstopFlag": true
+```
+
 ### Documentation Fields
 
 The documentation fields are used by PEL parsers to display a human readable
diff --git a/extensions/openpower-pels/registry/message_registry.json b/extensions/openpower-pels/registry/message_registry.json
index c2b3e91..6c2e807 100644
--- a/extensions/openpower-pels/registry/message_registry.json
+++ b/extensions/openpower-pels/registry/message_registry.json
@@ -1677,6 +1677,7 @@
             "SRC": {
                 "ReasonCode": "0xE510",
                 "SymptomIDFields": ["SRCWord6", "SRCWord7", "SRCWord8"],
+                "CheckstopFlag": true,
                 "Words6To9": {
                     "6": {
                         "AdditionalDataPropSource": "SRC6"
diff --git a/extensions/openpower-pels/registry/schema/schema.json b/extensions/openpower-pels/registry/schema/schema.json
index 11885e5..4c548e5 100644
--- a/extensions/openpower-pels/registry/schema/schema.json
+++ b/extensions/openpower-pels/registry/schema/schema.json
@@ -102,7 +102,9 @@
 
                 "Words6To9": { "$ref": "#/definitions/srcWords6To9" },
 
-                "DeconfigFlag": { "$ref": "#/definitions/deconfigFlag" }
+                "DeconfigFlag": { "$ref": "#/definitions/deconfigFlag" },
+
+                "CheckstopFlag": { "$ref": "#/definitions/checkstopFlag" }
             },
 
             "required": ["ReasonCode", "Words6To9"],
@@ -139,6 +141,11 @@
             "type": "boolean"
         },
 
+        "checkstopFlag": {
+            "description": "Indicates the SRC is for a hardware checkstop.",
+            "type": "boolean"
+        },
+
         "docNotes": {
             "description": "Any notes/comments about the error. An array of strings for manual line wrapping. Optional.",
             "type": "array",
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
index d78c07a..00ea0b8 100644
--- a/extensions/openpower-pels/src.cpp
+++ b/extensions/openpower-pels/src.cpp
@@ -350,6 +350,11 @@
     setBMCPosition();
     setMotherboardCCIN(dataIface);
 
+    if (regEntry.src.checkstopFlag)
+    {
+        setErrorStatusFlag(ErrorStatusFlags::hwCheckstop);
+    }
+
     if (regEntry.src.deconfigFlag)
     {
         setErrorStatusFlag(ErrorStatusFlags::deconfigured);
diff --git a/extensions/openpower-pels/src.hpp b/extensions/openpower-pels/src.hpp
index bc73fa2..a09f286 100644
--- a/extensions/openpower-pels/src.hpp
+++ b/extensions/openpower-pels/src.hpp
@@ -62,8 +62,9 @@
      * @brief Enums for the error status bits in hex word 5
      *        of BMC SRCs.
      */
-    enum class ErrorStatusFlags
+    enum class ErrorStatusFlags : uint32_t
     {
+        hwCheckstop = 0x80000000,
         terminateFwErr = 0x20000000,
         deconfigured = 0x02000000,
         guarded = 0x01000000
diff --git a/test/openpower-pels/registry_test.cpp b/test/openpower-pels/registry_test.cpp
index b33c07e..2f715bb 100644
--- a/test/openpower-pels/registry_test.cpp
+++ b/test/openpower-pels/registry_test.cpp
@@ -86,7 +86,8 @@
                         "AdditionalDataPropSource": "VOLTAGE"
                     }
                 },
-                "DeconfigFlag": true
+                "DeconfigFlag": true,
+                "CheckstopFlag": true
             },
 
             "Documentation":
@@ -224,6 +225,7 @@
     EXPECT_EQ(entry->src.type, 0xBD);
     EXPECT_EQ(entry->src.reasonCode, 0x2333);
     EXPECT_TRUE(entry->src.deconfigFlag);
+    EXPECT_TRUE(entry->src.checkstopFlag);
 
     auto& hexwords = entry->src.hexwordADFields;
     EXPECT_TRUE(hexwords);
@@ -285,6 +287,7 @@
     EXPECT_FALSE(entry->src.hexwordADFields);
     EXPECT_FALSE(entry->src.symptomID);
     EXPECT_FALSE(entry->src.deconfigFlag);
+    EXPECT_FALSE(entry->src.checkstopFlag);
 }
 
 TEST_F(RegistryTest, TestBadJSON)
diff --git a/test/openpower-pels/src_test.cpp b/test/openpower-pels/src_test.cpp
index bb1ba7c..d5d3b16 100644
--- a/test/openpower-pels/src_test.cpp
+++ b/test/openpower-pels/src_test.cpp
@@ -463,6 +463,7 @@
     entry.src.type = 0xBD;
     entry.src.reasonCode = 0xABCD;
     entry.src.deconfigFlag = true;
+    entry.src.checkstopFlag = true;
     entry.subsystem = 0x42;
 
     entry.callouts = R"(
@@ -522,8 +523,13 @@
 
         SRC src{entry, ad, dataIface};
 
+        EXPECT_TRUE(
+            src.getErrorStatusFlag(SRC::ErrorStatusFlags::deconfigured));
+        EXPECT_TRUE(src.getErrorStatusFlag(SRC::ErrorStatusFlags::hwCheckstop));
+
         const auto& hexwords = src.hexwordData();
-        auto mask = static_cast<uint32_t>(SRC::ErrorStatusFlags::deconfigured);
+        auto mask = static_cast<uint32_t>(SRC::ErrorStatusFlags::deconfigured) |
+                    static_cast<uint32_t>(SRC::ErrorStatusFlags::hwCheckstop);
         EXPECT_EQ(hexwords[5 - 2] & mask, mask);
 
         auto& callouts = src.callouts()->callouts();