PEL: New D-Bus properties on PEL entry iface

Fill in the 4 newly added properties on the PEL entry D-Bus interface:
- Platform log ID (PLID)
- Deconfig flag from the SRC section
- Guard flag from the SRC section
- Creation timestamp

These were also added to the PELAttributes map in the Repository class
so that each PEL wouldn't have to be reconstructed from a file again
when creating the D-Bus objects.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I7878645f56c634e6111fcecc22ab27673d0c0f5d
diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp
index c6c9243..9f2a13e 100644
--- a/extensions/openpower-pels/manager.cpp
+++ b/extensions/openpower-pels/manager.cpp
@@ -941,6 +941,11 @@
             std::string("ManagementSystemAck"),
             (attr.hmcState == TransmissionState::acked ? true : false));
 
+        varData.emplace("PlatformLogID", attr.plid);
+        varData.emplace("Deconfig", attr.deconfig);
+        varData.emplace("Guard", attr.guard);
+        varData.emplace("Timestamp", attr.creationTime);
+
         // Path to create PELEntry Interface is same as PEL
         auto path = std::string(OBJ_ENTRY) + '/' + std::to_string(obmcLogID);
         // Create Interface for PELEntry and set properties
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp
index 4e16fc5..d0a187c 100644
--- a/extensions/openpower-pels/pel.cpp
+++ b/extensions/openpower-pels/pel.cpp
@@ -585,6 +585,30 @@
     }
 }
 
+bool PEL::getDeconfigFlag() const
+{
+    auto creator = static_cast<CreatorID>(_ph->creatorID());
+
+    if ((creator == CreatorID::openBMC) || (creator == CreatorID::hostboot))
+    {
+        auto src = primarySRC();
+        return (*src)->getErrorStatusFlag(SRC::ErrorStatusFlags::deconfigured);
+    }
+    return false;
+}
+
+bool PEL::getGuardFlag() const
+{
+    auto creator = static_cast<CreatorID>(_ph->creatorID());
+
+    if ((creator == CreatorID::openBMC) || (creator == CreatorID::hostboot))
+    {
+        auto src = primarySRC();
+        return (*src)->getErrorStatusFlag(SRC::ErrorStatusFlags::guarded);
+    }
+    return false;
+}
+
 void PEL::updateTerminateBitInSRCSection()
 {
     //  Check for pel severity of type - 0x51 = critical error, system
diff --git a/extensions/openpower-pels/pel.hpp b/extensions/openpower-pels/pel.hpp
index d6f76e1..f6ff165 100644
--- a/extensions/openpower-pels/pel.hpp
+++ b/extensions/openpower-pels/pel.hpp
@@ -304,6 +304,30 @@
     void updateSysInfoInExtendedUserDataSection(
         const DataInterfaceBase& dataIface);
 
+    /**
+     * @brief Return the deconfig flag from hex data word 5 of BMC and
+     *        hostboot PELs.
+     *
+     * This only applies to BMC and hostboot PELs because only those
+     * SRC formats have this flag defined.
+     *
+     * @return bool - If the 'one or more resources are deconfigured'
+     *                flag is set.
+     */
+    bool getDeconfigFlag() const;
+
+    /**
+     * @brief Return the guard flag from hex data word 5 of BMC and
+     *        hostboot PELs.
+     *
+     * This only applies to BMC and hostboot PELs because only those
+     * SRC formats have this flag defined.
+     *
+     * @return bool - If the 'one or more resources are guarded'
+     *                flag is set.
+     */
+    bool getGuardFlag() const;
+
   private:
     /**
      * @brief Builds the section objects from a PEL data buffer
diff --git a/extensions/openpower-pels/repository.cpp b/extensions/openpower-pels/repository.cpp
index b19ce7a..fa2020c 100644
--- a/extensions/openpower-pels/repository.cpp
+++ b/extensions/openpower-pels/repository.cpp
@@ -115,14 +115,20 @@
                     }
                 }
 
-                PELAttributes attributes{dirEntry.path(),
-                                         getFileDiskSize(dirEntry.path()),
-                                         pel.privateHeader().creatorID(),
-                                         pel.userHeader().subsystem(),
-                                         pel.userHeader().severity(),
-                                         pel.userHeader().actionFlags(),
-                                         pel.hostTransmissionState(),
-                                         pel.hmcTransmissionState()};
+                PELAttributes attributes{
+                    dirEntry.path(),
+                    getFileDiskSize(dirEntry.path()),
+                    pel.privateHeader().creatorID(),
+                    pel.userHeader().subsystem(),
+                    pel.userHeader().severity(),
+                    pel.userHeader().actionFlags(),
+                    pel.hostTransmissionState(),
+                    pel.hmcTransmissionState(),
+                    pel.plid(),
+                    pel.getDeconfigFlag(),
+                    pel.getGuardFlag(),
+                    getMillisecondsSinceEpoch(
+                        pel.privateHeader().createTimestamp())};
 
                 using pelID = LogID::Pel;
                 using obmcID = LogID::Obmc;
@@ -173,14 +179,19 @@
 
     write(*(pel.get()), path);
 
-    PELAttributes attributes{path,
-                             getFileDiskSize(path),
-                             pel->privateHeader().creatorID(),
-                             pel->userHeader().subsystem(),
-                             pel->userHeader().severity(),
-                             pel->userHeader().actionFlags(),
-                             pel->hostTransmissionState(),
-                             pel->hmcTransmissionState()};
+    PELAttributes attributes{
+        path,
+        getFileDiskSize(path),
+        pel->privateHeader().creatorID(),
+        pel->userHeader().subsystem(),
+        pel->userHeader().severity(),
+        pel->userHeader().actionFlags(),
+        pel->hostTransmissionState(),
+        pel->hmcTransmissionState(),
+        pel->plid(),
+        pel->getDeconfigFlag(),
+        pel->getGuardFlag(),
+        getMillisecondsSinceEpoch(pel->privateHeader().createTimestamp())};
 
     using pelID = LogID::Pel;
     using obmcID = LogID::Obmc;
diff --git a/extensions/openpower-pels/repository.hpp b/extensions/openpower-pels/repository.hpp
index a45a0d4..07a499d 100644
--- a/extensions/openpower-pels/repository.hpp
+++ b/extensions/openpower-pels/repository.hpp
@@ -34,17 +34,23 @@
         std::bitset<16> actionFlags;
         TransmissionState hostState;
         TransmissionState hmcState;
+        uint32_t plid;
+        bool deconfig;
+        bool guard;
+        uint64_t creationTime;
 
         PELAttributes() = delete;
 
         PELAttributes(const std::filesystem::path& p, size_t size,
                       uint8_t creator, uint8_t subsystem, uint8_t sev,
                       uint16_t flags, TransmissionState hostState,
-                      TransmissionState hmcState) :
+                      TransmissionState hmcState, uint32_t plid, bool deconfig,
+                      bool guard, uint64_t creationTime) :
             path(p),
             sizeOnDisk(size), creator(creator), subsystem(subsystem),
             severity(sev), actionFlags(flags), hostState(hostState),
-            hmcState(hmcState)
+            hmcState(hmcState), plid(plid), deconfig(deconfig), guard(guard),
+            creationTime(creationTime)
         {}
     };
 
diff --git a/extensions/openpower-pels/src.hpp b/extensions/openpower-pels/src.hpp
index 3e6e519..f3ce5cc 100644
--- a/extensions/openpower-pels/src.hpp
+++ b/extensions/openpower-pels/src.hpp
@@ -308,6 +308,18 @@
      */
     static uint32_t getProgressCode(std::vector<uint8_t>& rawProgressSRC);
 
+    /**
+     * @brief Return the value of the passed in error status flag.
+     *
+     * @param[in] flag - The flag
+     *
+     * @return bool - If the flag is set.
+     */
+    bool getErrorStatusFlag(ErrorStatusFlags flag) const
+    {
+        return _hexData[3] & static_cast<uint32_t>(flag);
+    }
+
   private:
     /**
      * @brief Fills in the user defined hex words from the