oem-ibm: add readFileByTypeIntoMemory handler
Add a handler for file type 'LID', which are host firmware image files
on IBM systems. These would be read by the host firmware as it boots.
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: I83e3ee398a4c6a4198a40b8b2188a3c11d0e55c4
diff --git a/oem/ibm/libpldmresponder/file_io_type_lid.hpp b/oem/ibm/libpldmresponder/file_io_type_lid.hpp
new file mode 100644
index 0000000..45d4f73
--- /dev/null
+++ b/oem/ibm/libpldmresponder/file_io_type_lid.hpp
@@ -0,0 +1,58 @@
+#pragma once
+
+#include "config.h"
+
+#include "file_io_by_type.hpp"
+
+#include <sstream>
+#include <string>
+
+namespace pldm
+{
+namespace responder
+{
+
+using namespace pldm::responder::dma;
+
+/** @class LidHandler
+ *
+ * @brief Inherits and implements FileHandler. This class is used
+ * to read/write LIDs.
+ */
+class LidHandler : public FileHandler
+{
+ public:
+ /** @brief LidHandler constructor
+ */
+ LidHandler(uint32_t fileHandle, bool permSide) : FileHandler(fileHandle)
+ {
+ std::string dir = permSide ? LID_PERM_DIR : LID_TEMP_DIR;
+ std::stringstream stream;
+ stream << std::hex << fileHandle;
+ lidPath = std::move(dir) + '/' + stream.str() + ".lid";
+ }
+
+ virtual int writeFromMemory(uint32_t /*offset*/, uint32_t /*length*/,
+ uint64_t /*address*/)
+ {
+ return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
+ }
+
+ virtual int readIntoMemory(uint32_t offset, uint32_t length,
+ uint64_t address)
+ {
+ return transferFileData(lidPath, true, offset, length, address);
+ }
+
+ /** @brief LidHandler destructor
+ */
+ ~LidHandler()
+ {
+ }
+
+ protected:
+ std::string lidPath;
+};
+
+} // namespace responder
+} // namespace pldm