oem-ibm: inband: Handle BMC lids
If the file is a BMC lid, strip off the header and concatenate
it. The BMC lids are a tarball file divided into chunks.
Change-Id: I36e622231d07658524225a36b932c983f0df2538
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/oem/ibm/libpldmresponder/inband_code_update.cpp b/oem/ibm/libpldmresponder/inband_code_update.cpp
index 101025e..93e137b 100644
--- a/oem/ibm/libpldmresponder/inband_code_update.cpp
+++ b/oem/ibm/libpldmresponder/inband_code_update.cpp
@@ -23,6 +23,15 @@
/** @brief Directory where the lid files without a header are stored */
auto lidDirPath = fs::path(LID_STAGING_DIR) / "lid";
+/** @brief Directory where the image files are stored as they are built */
+auto imageDirPath = fs::path(LID_STAGING_DIR) / "image";
+
+/** @brief The file name of the code update tarball */
+constexpr auto tarImageName = "image.tar";
+
+/** @brief The path to the code update tarball file */
+auto tarImagePath = fs::path(imageDirPath) / tarImageName;
+
std::string CodeUpdate::fetchCurrentBootSide()
{
return currBootSide;
@@ -262,17 +271,32 @@
return PLDM_ERROR;
}
+ fs::create_directories(imageDirPath);
fs::create_directories(lidDirPath);
- std::stringstream lidFileName;
- lidFileName << std::hex << htonl(header.lidNumber) << ".lid";
- auto lidNoHeaderPath = fs::path(lidDirPath) / lidFileName.str();
- std::ofstream ofs(lidNoHeaderPath,
- std::ios::out | std::ios::binary | std::ios::trunc);
- ifs.seekg(htonl(header.headerSize));
- ofs << ifs.rdbuf();
- ofs.flush();
- ofs.close();
+ constexpr auto bmcClass = 0x2000;
+ if (htons(header.lidClass) == bmcClass)
+ {
+ // Skip the header and concatenate the BMC LIDs into a tar file
+ std::ofstream ofs(tarImagePath,
+ std::ios::out | std::ios::binary | std::ios::app);
+ ifs.seekg(htonl(header.headerSize));
+ ofs << ifs.rdbuf();
+ ofs.flush();
+ ofs.close();
+ }
+ else
+ {
+ std::stringstream lidFileName;
+ lidFileName << std::hex << htonl(header.lidNumber) << ".lid";
+ auto lidNoHeaderPath = fs::path(lidDirPath) / lidFileName.str();
+ std::ofstream ofs(lidNoHeaderPath,
+ std::ios::out | std::ios::binary | std::ios::trunc);
+ ifs.seekg(htonl(header.headerSize));
+ ofs << ifs.rdbuf();
+ ofs.flush();
+ ofs.close();
+ }
ifs.close();
fs::remove(filePath);