diff options
Diffstat (limited to 'extensions/openpower-pels')
-rw-r--r-- | extensions/openpower-pels/data_interface.cpp | 27 | ||||
-rw-r--r-- | extensions/openpower-pels/data_interface.hpp | 42 |
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. * |