summaryrefslogtreecommitdiffstats
path: root/extensions/openpower-pels
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-12-02 15:42:01 -0600
committerMatt Spinler <spinler@us.ibm.com>2019-12-09 13:47:57 -0600
commitcad9c2bd9e8ffb6e6db297d8d71b9733aae96e1e (patch)
tree07c0e2ba7986d03776735f32d4dbd05f185ecbe5 /extensions/openpower-pels
parent86c703629d8d70434b7d9cc642578f70a78818bc (diff)
downloadphosphor-logging-cad9c2bd9e8ffb6e6db297d8d71b9733aae96e1e.tar.gz
phosphor-logging-cad9c2bd9e8ffb6e6db297d8d71b9733aae96e1e.zip
PEL: Add APIs to read the FW versions
Add methods to the DataInterface class to read the BMC and server firmware versions. The server firmware version represents the version of all firmware images that are in the flash image, not just the BMC. There is nowhere to get that version yet, so this commit just has a placeholder. These will be used by the ExtendedUserHeader section. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I47389714c987337cb96c72b6bf2b270c78003357
Diffstat (limited to 'extensions/openpower-pels')
-rw-r--r--extensions/openpower-pels/data_interface.cpp27
-rw-r--r--extensions/openpower-pels/data_interface.hpp42
2 files changed, 69 insertions, 0 deletions
diff --git a/extensions/openpower-pels/data_interface.cpp b/extensions/openpower-pels/data_interface.cpp
index 66442c5..7342dc0 100644
--- a/extensions/openpower-pels/data_interface.cpp
+++ b/extensions/openpower-pels/data_interface.cpp
@@ -13,8 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "config.h"
+
#include "data_interface.hpp"
+#include <fstream>
#include <xyz/openbmc_project/State/OperatingSystem/Status/server.hpp>
namespace openpower
@@ -48,6 +51,8 @@ DataInterface::DataInterface(sdbusplus::bus::bus& bus) : _bus(bus)
{
readMTMS();
readHostState();
+ readBMCFWVersion();
+ readServerFWVersion();
}
void DataInterface::readMTMS()
@@ -217,5 +222,27 @@ void DataInterface::osStatePropChanged(sdbusplus::message::message& msg)
}
}
+void DataInterface::readBMCFWVersion()
+{
+ std::ifstream versionFile{BMC_VERSION_FILE};
+ std::string line;
+ static const auto versionID = "VERSION=";
+
+ while (std::getline(versionFile, line))
+ {
+ if (line.find(versionID) != std::string::npos)
+ {
+ auto pos = line.find_first_of('"') + 1;
+ _bmcFWVersion = line.substr(pos, line.find_last_of('"') - pos);
+ break;
+ }
+ }
+}
+
+void DataInterface::readServerFWVersion()
+{
+ // Not available yet
+}
+
} // namespace pels
} // namespace openpower
diff --git a/extensions/openpower-pels/data_interface.hpp b/extensions/openpower-pels/data_interface.hpp
index a3c118e..ff0aa75 100644
--- a/extensions/openpower-pels/data_interface.hpp
+++ b/extensions/openpower-pels/data_interface.hpp
@@ -91,6 +91,26 @@ class DataInterfaceBase
_hostChangeCallbacks.erase(name);
}
+ /**
+ * @brief Returns the BMC firmware version
+ *
+ * @return std::string - The BMC version
+ */
+ virtual std::string getBMCFWVersion() const
+ {
+ return _bmcFWVersion;
+ }
+
+ /**
+ * @brief Returns the server firmware version
+ *
+ * @return std::string - The server firmware version
+ */
+ virtual std::string getServerFWVersion() const
+ {
+ return _serverFWVersion;
+ }
+
protected:
/**
* @brief Sets the host on/off state and runs any
@@ -138,6 +158,16 @@ class DataInterfaceBase
* names to callback functions.
*/
std::map<std::string, HostStateChangeFunc> _hostChangeCallbacks;
+
+ /**
+ * @brief The BMC firmware version string
+ */
+ std::string _bmcFWVersion;
+
+ /**
+ * @brief The server firmware version string
+ */
+ std::string _serverFWVersion;
};
/**
@@ -187,6 +217,18 @@ class DataInterface : public DataInterfaceBase
void readHostState();
/**
+ * @brief Reads the BMC firmware version string and puts it into
+ * _bmcFWVersion.
+ */
+ void readBMCFWVersion();
+
+ /**
+ * @brief Reads the server firmware version string and puts it into
+ * _serverFWVersion.
+ */
+ void readServerFWVersion();
+
+ /**
* @brief Finds the D-Bus service name that hosts the
* passed in path and interface.
*
OpenPOWER on IntegriCloud