PHAL: Added processor CFAM register data in the clock daily data logger

Informational log includes all the present processor CFAM register
information required for clock debug.

Tested:
    "Proc0": "Functional",
    "Proc0 EC": "0x0000000020",
    "Proc0 Location Code": "Ufcs-P0-C61",
    "Proc0 REG 0x1007": "0x00200004",
    "Proc0 REG 0x2804": "0x3c000020",
    "Proc0 REG 0x2810": "0x80ff6007",
    "Proc0 REG 0x2813": "0xefeeeeff",
    "Proc0 REG 0x2814": "0x000000e4",
    "Proc0 REG 0x2815": "0xc0000000",
    "Proc0 REG 0x2816": "0xff000000",
    "Proc0 REG 0x281d": "0x00000000",
    "Proc0 REG 0x281e": "0x00000000",

Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Change-Id: I47289a7c95ca9e64598eb26bbb5b49bf4fc2b680
diff --git a/extensions/phal/clock_logger.cpp b/extensions/phal/clock_logger.cpp
index 4bda427..399b01f 100644
--- a/extensions/phal/clock_logger.cpp
+++ b/extensions/phal/clock_logger.cpp
@@ -150,10 +150,44 @@
         ssECVal << "0x" << std::setfill('0') << std::setw(10) << std::hex
                 << (uint16_t)ecVal;
         clockDataLog.push_back(std::make_pair(ssEC.str(), ssECVal.str()));
+
+        // Add CFAM register information.
+        addCFAMData(procTarget, clockDataLog);
     }
 
     openpower::pel::createPEL("org.open_power.PHAL.Info.ClockDailyLog",
                               clockDataLog);
 }
 
+void Manager::addCFAMData(struct pdbg_target* proc,
+                          openpower::pel::FFDCData& clockDataLog)
+{
+
+    // collect Processor CFAM register data
+    const std::vector<int> procCFAMAddr = {
+        0x1007, 0x2804, 0x2810, 0x2813, 0x2814, 0x2815, 0x2816, 0x281D, 0x281E};
+
+    auto index = std::to_string(pdbg_target_index(proc));
+
+    for (int addr : procCFAMAddr)
+    {
+        auto val = 0xDEADBEEF;
+        try
+        {
+            val = openpower::phal::pdbg::getCFAM(proc, addr);
+        }
+        catch (const std::exception& e)
+        {
+            error("getCFAM on {TARGET} thrown exception({ERROR}): Addr ({REG})",
+                  "TARGET", pdbg_target_path(proc), "ERROR", e, "REG", addr);
+        }
+        std::stringstream ssData;
+        ssData << "0x" << std::setfill('0') << std::setw(8) << std::hex << val;
+        std::stringstream ssAddr;
+        ssAddr << "Proc" << index << " REG 0x" << std::hex << addr;
+        // update the data
+        clockDataLog.push_back(make_pair(ssAddr.str(), ssData.str()));
+    }
+}
+
 } // namespace openpower::phal::clock
diff --git a/extensions/phal/clock_logger.hpp b/extensions/phal/clock_logger.hpp
index a9982d1..2d56cef 100644
--- a/extensions/phal/clock_logger.hpp
+++ b/extensions/phal/clock_logger.hpp
@@ -66,6 +66,15 @@
      */
     void createClockDataLog();
 
+    /**
+     * @brief Add processor specific CFAM data to daily logger.
+     *
+     * @param[in] proc - pdbg processor target
+     * @param[out] ffdcData - reference to clock data log
+     */
+    void addCFAMData(struct pdbg_target* proc,
+                     openpower::pel::FFDCData& clockDataLog);
+
   private:
     /* The sdeventplus even loop to use */
     sdeventplus::Event _event;