Guard support for PELs

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Ib32a3ccbf165bb9a541fa37fcdaf9da4c8e63f81
diff --git a/analyzer/create_pel.cpp b/analyzer/create_pel.cpp
index 64463b2..9295dca 100644
--- a/analyzer/create_pel.cpp
+++ b/analyzer/create_pel.cpp
@@ -26,6 +26,7 @@
 {
     FFDC_SIGNATURES    = 0x01,
     FFDC_REGISTER_DUMP = 0x02,
+    FFDC_GUARD         = 0x03,
 
     // For the callout section, the value of '0xCA' is required per the
     // phosphor-logging openpower-pel extention spec.
@@ -109,6 +110,24 @@
 
 //------------------------------------------------------------------------------
 
+void __addGuardList(const ServiceData& i_servData,
+                    std::vector<util::FFDCFile>& io_userDataFiles)
+{
+    // Get the JSON output for the guard list.
+    nlohmann::json json;
+    i_servData.getGuardList(json);
+
+    // Create a new entry for the user data section containing the guard list.
+    io_userDataFiles.emplace_back(util::FFDCFormat::JSON, FFDC_GUARD,
+                                  FFDC_VERSION1);
+
+    // Use a file stream to write the JSON to file.
+    std::ofstream o{io_userDataFiles.back().getPath()};
+    o << json;
+}
+
+//------------------------------------------------------------------------------
+
 void __captureSignatureList(const libhei::IsolationData& i_isoData,
                             std::vector<util::FFDCFile>& io_userDataFiles)
 {
@@ -278,6 +297,9 @@
     // Add the list of callouts to the PEL.
     __addCalloutList(i_servData, userDataFiles);
 
+    // Add the list of guard requests to the PEL.
+    __addGuardList(i_servData, userDataFiles);
+
     // Capture the complete signature list.
     __captureSignatureList(i_isoData, userDataFiles);