From bcd0161bbf097e4dc6721901fd387f183b8f183e Mon Sep 17 00:00:00 2001 From: AppaRao Puli Date: Wed, 9 Oct 2019 18:04:22 +0530 Subject: PFR: PFR manager ad-hoc fixes PFR manager miscellaneous fixes - Updated redfish EventLog ID and Args. - Updated panic/recovery reasons as per new spec. - Corrected referrence pointer in readCpldReg function. Tested: Loaded image in wht and validate Redfish event logs Change-Id: I4bccbfe650271bcfcc24037c50d385c5fa17dbf1 Signed-off-by: AppaRao Puli --- intel-pfr-manager/libpfr/inc/pfr.hpp | 3 +- intel-pfr-manager/libpfr/src/pfr.cpp | 10 ++--- intel-pfr-manager/service/src/mainapp.cpp | 67 ++++++++++++++++--------------- 3 files changed, 41 insertions(+), 39 deletions(-) diff --git a/intel-pfr-manager/libpfr/inc/pfr.hpp b/intel-pfr-manager/libpfr/inc/pfr.hpp index cd1b4f2..42af3f7 100644 --- a/intel-pfr-manager/libpfr/inc/pfr.hpp +++ b/intel-pfr-manager/libpfr/inc/pfr.hpp @@ -41,9 +41,10 @@ enum class ActionType minorError }; +std::string toHexString(const uint8_t val); std::string getVersionInfoCPLD(ImageType &imgType); int getProvisioningStatus(bool &ufmLocked, bool &ufmProvisioned); -int readCpldReg(const ActionType &action, uint8_t value); +int readCpldReg(const ActionType &action, uint8_t &value); int setBMCBootCheckpoint(const uint8_t checkPoint); } // namespace pfr diff --git a/intel-pfr-manager/libpfr/src/pfr.cpp b/intel-pfr-manager/libpfr/src/pfr.cpp index c30ef5b..955b6d7 100644 --- a/intel-pfr-manager/libpfr/src/pfr.cpp +++ b/intel-pfr-manager/libpfr/src/pfr.cpp @@ -54,11 +54,11 @@ static constexpr uint8_t bmcRecoveryMinorVersion = 0x1F; static constexpr uint8_t ufmLockedMask = (0x1 << 0x04); static constexpr uint8_t ufmProvisionedMask = (0x1 << 0x05); -template std::string int_to_hexstring(T i) +std::string toHexString(const uint8_t val) { std::stringstream stream; - stream << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex - << static_cast(i); + stream << std::setfill('0') << std::setw(2) << std::hex + << static_cast(val); return stream.str(); } @@ -110,7 +110,7 @@ std::string getVersionInfoCPLD(ImageType& imgType) uint8_t majorVer = cpldDev.i2cReadByteData(majorReg); uint8_t minorVer = cpldDev.i2cReadByteData(minorReg); std::string version = - int_to_hexstring(majorVer) + "." + int_to_hexstring(minorVer); + toHexString(majorVer) + "." + toHexString(minorVer); return version; } catch (const std::exception& e) @@ -141,7 +141,7 @@ int getProvisioningStatus(bool& ufmLocked, bool& ufmProvisioned) } } -int readCpldReg(const ActionType& action, uint8_t value) +int readCpldReg(const ActionType& action, uint8_t& value) { uint8_t cpldReg; diff --git a/intel-pfr-manager/service/src/mainapp.cpp b/intel-pfr-manager/service/src/mainapp.cpp index 103ab22..ae92f65 100644 --- a/intel-pfr-manager/service/src/mainapp.cpp +++ b/intel-pfr-manager/service/src/mainapp.cpp @@ -56,33 +56,32 @@ static std::vector> static std::map recoveryReasonMap = { {0x01, "PCH active authentication failure"}, {0x02, "PCH recovery authentication failure"}, - {0x03, "ACM launch failure"}, - {0x04, "IBB launch failure"}, - {0x05, "OBB launch failure"}, - {0x06, "BMC active authentication failure"}, - {0x07, "BMC recovery authentication failure"}, - {0x08, "BMC launch failure"}, - {0x09, "CPLD watchdog expired"}}; + {0x03, "ME launch failure"}, + {0x04, "ACM launch failure"}, + {0x05, "IBB launch failure"}, + {0x06, "OBB launch failure"}, + {0x07, "BMC active authentication failure"}, + {0x08, "BMC recovery authentication failure"}, + {0x09, "BMC launch failure"}, + {0x0A, "CPLD watchdog expired"}}; // Panic Reason map. { , } static std::map panicReasonMap = { - {0x01, "CPLD WDT expired"}, - {0x02, "BMC WDT expired"}, - {0x03, "ME WDT expired"}, - {0x04, "ACM WDT expired"}, - {0x05, "IBB WDT expired"}, - {0x06, "OBB WDT expired"}, + {0x01, "CPLD watchdog expired"}, + {0x02, "BMC watchdog expired"}, + {0x03, "ME watchdog expired"}, + {0x04, "ACM watchdog expired"}, + {0x05, "IBB watchdog expired"}, + {0x06, "OBB watchdog expired"}, {0x07, "BMC active authentication failure"}, {0x08, "BMC recovery authentication failure"}, {0x09, "PCH active authentication failure"}, {0x0A, "PCH recovery authentication failure"}, - {0x0B, "IBB authentication failure"}, - {0x0C, "OBB authentication failure"}, - {0x0D, "BMC authentication failure"}, - {0x0E, "PCH active update intent"}, - {0x0F, "BMC active update intent"}, - {0x10, "PCH recovery update intent"}, - {0x11, "BMC recovery update intent"}}; + {0x0B, "ME authentication failure"}, + {0x0C, "ACM or IBB or OBB authentication failure"}, + {0x0D, "PCH update intent"}, + {0x0E, "BMC update intent"}, + {0x0F, "BMC reset detected"}}; static void updateDbusPropertiesCache() { @@ -115,10 +114,10 @@ static void logLastRecoveryEvent() return; } - sd_journal_send("MESSAGE=%s", "Platform firmware recovered.", "PRIORITY=%i", - LOG_ERR, "REDFISH_MESSAGE_ID=%s", - "OpenBMC.0.1.PlatformFWRecovered", - "REDFISH_MESSAGE_ARGS=%s", it->second.c_str(), NULL); + sd_journal_send( + "MESSAGE=%s", "Platform firmware recovered.", "PRIORITY=%i", LOG_ERR, + "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.PlatformFirmwareEvent", + "REDFISH_MESSAGE_ARGS=%s,%s", "recovery", it->second.c_str(), NULL); } static void logLastPanicEvent() @@ -138,10 +137,10 @@ static void logLastPanicEvent() return; } - sd_journal_send("MESSAGE=%s", "Platform panic event triggered.", - "PRIORITY=%i", LOG_ERR, "REDFISH_MESSAGE_ID=%s", - "OpenBMC.0.1.PlatformFWPanicTriggered", - "REDFISH_MESSAGE_ARGS=%s", it->second.c_str(), NULL); + sd_journal_send( + "MESSAGE=%s", "Platform panic event triggered.", "PRIORITY=%i", LOG_ERR, + "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.PlatformFirmwareEvent", + "REDFISH_MESSAGE_ARGS=%s,%s", "panic", it->second.c_str(), NULL); } static void checkAndLogEvents() @@ -184,11 +183,13 @@ static void checkAndLogEvents() if (majorErr || minorErr) { - sd_journal_send( - "MESSAGE=%s", "Error occurred on platform firmware.", - "PRIORITY=%i", LOG_ERR, "REDFISH_MESSAGE_ID=%s", - "OpenBMC.0.1.PlatformFWErrorOccurred", - "REDFISH_MESSAGE_ARGS=%i,%i", majorErr, minorErr, NULL); + std::string errorStr = + toHexString(majorErr) + "." + toHexString(minorErr); + sd_journal_send("MESSAGE=%s", + "Error occurred on platform firmware.", + "PRIORITY=%i", LOG_ERR, "REDFISH_MESSAGE_ID=%s", + "OpenBMC.0.1.PlatformFirmwareError", + "REDFISH_MESSAGE_ARGS=%s", errorStr, NULL); } } } -- cgit v1.2.3