PEL: Add boot progress code to SRC hex data

Add the first 8 characters from the ASCII string field of the current
progress SRC, taken from the xyz.openbmc_project.State.Boot.Raw D-Bus
interface, to SRC hex word 4 when creating a PEL.

This is how the field is defined in the PEL spec, and is to help with
debug so that one can know which part of the boot was occurring when
the PEL was created.  Note that at this point most progress codes are
sent down from one of the host firmware subsystems and not created by
the BMC.

The field is only inserted into the SRC if those characters are present
and represent a valid 4 byte number, such as "C7004000".  This is then
represented as 0xC7004000 in the SRC word. Otherwise, the word is left
at a value of zero.

For example:
...
    "Valid Word Count":         "0x09",
    "Reference Code":           "BD8D1001",
    "Hex Word 2":               "00080455",
    "Hex Word 3":               "2E2D0010",
    "Hex Word 4":               "C7004000", <---Progress code
    "Hex Word 5":               "00000000",
    "Hex Word 6":               "00000005",
    "Hex Word 7":               "00000000",
    "Hex Word 8":               "00000000",
    "Hex Word 9":               "00000000"
...

Signed-off-by: Vijay Lobo <vijaylobo@gmail.com>
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Iba41e88626c0e081e5759b994e3630ef8b12daf4
diff --git a/extensions/openpower-pels/data_interface.cpp b/extensions/openpower-pels/data_interface.cpp
index e6b95a3..0e31b0e 100644
--- a/extensions/openpower-pels/data_interface.cpp
+++ b/extensions/openpower-pels/data_interface.cpp
@@ -44,8 +44,8 @@
 constexpr auto ledGroupManager = "xyz.openbmc_project.LED.GroupManager";
 constexpr auto logSetting = "xyz.openbmc_project.Settings";
 constexpr auto hwIsolation = "org.open_power.HardwareIsolation";
-constexpr auto bootRawProgress = "xyz.openbmc_project.State.Boot.Raw";
 constexpr auto biosConfigMgr = "xyz.openbmc_project.BIOSConfigManager";
+constexpr auto bootRawProgress = "xyz.openbmc_project.State.Boot.Raw";
 } // namespace service_name
 
 namespace object_path
@@ -65,8 +65,8 @@
 constexpr auto vpdManager = "/com/ibm/VPD/Manager";
 constexpr auto logSetting = "/xyz/openbmc_project/logging/settings";
 constexpr auto hwIsolation = "/xyz/openbmc_project/hardware_isolation";
-constexpr auto bootRawSetting = "/xyz/openbmc_project/state/boot/raw0";
 constexpr auto biosConfigMgr = "/xyz/openbmc_project/bios_config/manager";
+constexpr auto bootRawProgress = "/xyz/openbmc_project/state/boot/raw0";
 } // namespace object_path
 
 namespace interface
@@ -96,10 +96,10 @@
 constexpr auto dumpEntry = "xyz.openbmc_project.Dump.Entry";
 constexpr auto dumpProgress = "xyz.openbmc_project.Common.Progress";
 constexpr auto hwIsolationCreate = "org.open_power.HardwareIsolation.Create";
-constexpr auto bootRawProgress = "xyz.openbmc_project.State.Boot.Raw";
 constexpr auto hwIsolationEntry = "xyz.openbmc_project.HardwareIsolation.Entry";
 constexpr auto association = "xyz.openbmc_project.Association";
 constexpr auto biosConfigMgr = "xyz.openbmc_project.BIOSConfig.Manager";
+constexpr auto bootRawProgress = "xyz.openbmc_project.State.Boot.Raw";
 } // namespace interface
 
 using namespace sdbusplus::xyz::openbmc_project::State::Boot::server;
@@ -769,7 +769,7 @@
     DBusValue variant = std::make_tuple(priSRC, srcStruct);
 
     auto method = _bus.new_method_call(service_name::bootRawProgress,
-                                       object_path::bootRawSetting,
+                                       object_path::bootRawProgress,
                                        interface::dbusProperty, "Set");
 
     method.append(interface::bootRawProgress, "Value", variant);
@@ -868,5 +868,18 @@
     }
     return ids;
 }
+
+std::vector<uint8_t> DataInterface::getRawProgressSRC(void) const
+{
+    using RawProgressProperty = std::tuple<uint64_t, std::vector<uint8_t>>;
+
+    DBusValue value;
+    getProperty(service_name::bootRawProgress, object_path::bootRawProgress,
+                interface::bootRawProgress, "Value", value);
+
+    const auto& rawProgress = std::get<RawProgressProperty>(value);
+    return std::get<1>(rawProgress);
+}
+
 } // namespace pels
 } // namespace openpower