PFR: Setting BMC boot finished checkpoint
Adding support to monitor the StartupFinished systemd
signal and setting the "bmc boot finished" checkpoint
to cpld.
Tested:
Did BMC reset and cross verified bmc boot finished
check-point properly set or not.
Change-Id: I14e6aa8b364b28da6cd6b2473cde8502d1ebd77c
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/libpfr/inc/file.hpp b/libpfr/inc/file.hpp
index c7ef58c..1fbc62a 100644
--- a/libpfr/inc/file.hpp
+++ b/libpfr/inc/file.hpp
@@ -89,6 +89,25 @@
return value;
}
+ /** @brief Writes the byte data to I2C dev
+ *
+ * @param[in] Offset - Offset value
+ * @param[in] Byte data - Data
+ */
+ void i2cWriteByteData(const uint8_t offset, const uint8_t value)
+ {
+ int retries = 3;
+ while (i2c_smbus_write_byte_data(fd, offset, value) < 0)
+ {
+ if (!retries--)
+ {
+ throw std::runtime_error("i2c_smbus_write_byte_data() failed");
+ }
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ }
+ return;
+ }
+
~I2CFile()
{
if (!(fd < 0))
diff --git a/libpfr/inc/pfr.hpp b/libpfr/inc/pfr.hpp
index 012c647..cd1b4f2 100644
--- a/libpfr/inc/pfr.hpp
+++ b/libpfr/inc/pfr.hpp
@@ -44,6 +44,7 @@
std::string getVersionInfoCPLD(ImageType &imgType);
int getProvisioningStatus(bool &ufmLocked, bool &ufmProvisioned);
int readCpldReg(const ActionType &action, uint8_t value);
+int setBMCBootCheckpoint(const uint8_t checkPoint);
} // namespace pfr
} // namespace intel
diff --git a/libpfr/src/pfr.cpp b/libpfr/src/pfr.cpp
index 1ad98b2..2e87fa9 100644
--- a/libpfr/src/pfr.cpp
+++ b/libpfr/src/pfr.cpp
@@ -41,6 +41,7 @@
static constexpr uint8_t majorErrorCode = 0x08;
static constexpr uint8_t minorErrorCode = 0x09;
static constexpr uint8_t provisioningStatus = 0x0A;
+static constexpr uint8_t bmcBootCheckpoint = 0x0F;
static constexpr uint8_t pchActiveMajorVersion = 0x17;
static constexpr uint8_t pchActiveMinorVersion = 0x18;
static constexpr uint8_t bmcActiveMajorVersion = 0x19;
@@ -186,5 +187,22 @@
}
}
+int setBMCBootCheckpoint(const uint8_t checkPoint)
+{
+ try
+ {
+ I2CFile cpldDev(i2cBusNumber, i2cSlaveAddress, O_RDWR | O_CLOEXEC);
+ cpldDev.i2cWriteByteData(bmcBootCheckpoint, checkPoint);
+ return 0;
+ }
+ catch (const std::exception& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Exception caught in setBMCBootCheckout.",
+ phosphor::logging::entry("MSG=%s", e.what()));
+ return -1;
+ }
+}
+
} // namespace pfr
} // namespace intel