oem-ibm: Sync boot side file with bios attributes
This change adds support to update the boot side file to keep it
in sync with boot side bios attributes
Change-Id: I2bea293500c69a883f400ddaadc436705bbe5ab4
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/oem/ibm/libpldmresponder/inband_code_update.cpp b/oem/ibm/libpldmresponder/inband_code_update.cpp
index 855258d..d031855 100644
--- a/oem/ibm/libpldmresponder/inband_code_update.cpp
+++ b/oem/ibm/libpldmresponder/inband_code_update.cpp
@@ -24,6 +24,7 @@
namespace responder
{
using namespace oem_ibm_platform;
+using namespace oem_ibm_bios;
/** @brief Directory where the lid files without a header are stored */
auto lidDirPath = fs::path(LID_STAGING_DIR) / "lid";
@@ -40,9 +41,6 @@
/** @brief The file name of the hostfw image */
constexpr auto hostfwImageName = "image-hostfw";
-/** @brief The filename of the file where bootside data will be saved */
-constexpr auto bootSideFileName = "bootSide";
-
/** @brief The path to the code update tarball file */
auto tarImagePath = fs::path(imageDirPath) / tarImageName;
@@ -59,9 +57,6 @@
/** @brief Next boot side */
constexpr auto bootNextSideAttrName = "fw_boot_side";
-/** @brief The filepath of file where bootside data will be saved */
-auto bootSideDirPath = fs::path("/var/lib/pldm/") / bootSideFileName;
-
std::string CodeUpdate::fetchCurrentBootSide()
{
return currBootSide;
@@ -202,6 +197,7 @@
static constexpr auto activeObjPath =
"/xyz/openbmc_project/software/active";
static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
+ static constexpr auto pathIntf = "xyz.openbmc_project.Common.FilePath";
auto& bus = dBusIntf->getBus();
try
@@ -215,6 +211,9 @@
reply.read(paths);
runningVersion = std::get<std::vector<std::string>>(paths)[0];
+ auto runningPathPropValue = dBusIntf->getDbusPropertyVariant(
+ runningVersion.c_str(), "Path", pathIntf);
+ const auto& runningPath = std::get<std::string>(runningPathPropValue);
auto method1 =
bus.new_method_call(mapperService, activeObjPath, propIntf, "Get");
@@ -249,12 +248,13 @@
else
{
info(
- "Boot side is not initialized yet, so setting default value");
+ "Boot side is not initialized yet, so setting default value(Temp). Request was ignored to set the Boot side to {SIDE}",
+ "SIDE", nextBootSideBiosValue);
nextBootSideBiosValue = "Temp";
}
pldmBootSideData.current_boot_side = nextBootSideBiosValue;
pldmBootSideData.next_boot_side = nextBootSideBiosValue;
- pldmBootSideData.running_version_object = runningVersion;
+ pldmBootSideData.running_version_object = runningPath;
writeBootSideFile(pldmBootSideData);
biosAttrList.emplace_back(std::make_pair(
@@ -270,11 +270,11 @@
else
{
pldm_boot_side_data pldmBootSideData = readBootSideFile();
- if (pldmBootSideData.running_version_object != runningVersion)
+ if (pldmBootSideData.running_version_object != runningPath)
{
info(
"BMC have booted with the new image runningPath={RUNN_PATH}",
- "RUNN_PATH", runningVersion.c_str());
+ "RUNN_PATH", runningPath.c_str());
info("Previous Image was: {RUNN_VERS}", "RUNN_VERS",
pldmBootSideData.running_version_object);
auto current_boot_side =
@@ -282,7 +282,7 @@
: "Temp");
pldmBootSideData.current_boot_side = current_boot_side;
pldmBootSideData.next_boot_side = current_boot_side;
- pldmBootSideData.running_version_object = runningVersion;
+ pldmBootSideData.running_version_object = runningPath;
writeBootSideFile(pldmBootSideData);
biosAttrList.emplace_back(std::make_pair(
bootSideAttrName,
@@ -489,12 +489,12 @@
{
try
{
- fs::create_directories(bootSideDirPath.parent_path());
+ fs::create_directories(fs::path(bootSideDirPath).parent_path());
std::ofstream writeFile(bootSideDirPath, std::ios::out);
if (!writeFile.is_open())
{
error("Failed to open bootside file {FILE} for writing", "FILE",
- bootSideDirPath.string());
+ bootSideDirPath);
return;
}
@@ -527,7 +527,7 @@
{
pldm_boot_side_data pldmBootSideDataRead{};
- std::ifstream readFile(bootSideDirPath.string(), std::ios::in);
+ std::ifstream readFile(bootSideDirPath, std::ios::in);
if (!readFile)
{
@@ -551,6 +551,7 @@
void CodeUpdate::processPriorityChangeNotification(
const DbusChangedProps& chProperties)
{
+ error("Processing priority change notification");
static constexpr auto propName = "Priority";
const auto it = chProperties.find(propName);
if (it == chProperties.end())
@@ -558,8 +559,31 @@
return;
}
uint8_t newVal = std::get<uint8_t>(it->second);
- nextBootSide = (newVal == 0) ? currBootSide
- : ((currBootSide == Tside) ? Pside : Tside);
+
+ pldm_boot_side_data pldmBootSideData = readBootSideFile();
+ pldmBootSideData.next_boot_side =
+ (newVal == 0)
+ ? pldmBootSideData.current_boot_side
+ : ((pldmBootSideData.current_boot_side == "Temp") ? "Perm"
+ : "Temp");
+ writeBootSideFile(pldmBootSideData);
+ nextBootSide = (pldmBootSideData.next_boot_side == "Temp" ? Tside : Pside);
+ std::string currNextBootSide;
+ auto attributeValue = getBiosAttrValue<std::string>(bootNextSideAttrName);
+ if (attributeValue.has_value())
+ {
+ currNextBootSide = attributeValue.value();
+ }
+
+ if (currNextBootSide == nextBootSide)
+ {
+ return;
+ }
+ PendingAttributesList biosAttrList;
+ biosAttrList.push_back(std::make_pair(
+ bootNextSideAttrName,
+ std::make_tuple(EnumAttribute, pldmBootSideData.next_boot_side)));
+ setBiosAttr(biosAttrList);
}
void CodeUpdate::setOemPlatformHandler(