1 #pragma once 2 3 #include "config.h" 4 5 #include "file_io_by_type.hpp" 6 7 #include <sstream> 8 #include <string> 9 10 namespace pldm 11 { 12 namespace responder 13 { 14 15 using namespace pldm::responder::dma; 16 17 /** @class LidHandler 18 * 19 * @brief Inherits and implements FileHandler. This class is used 20 * to read/write LIDs. 21 */ 22 class LidHandler : public FileHandler 23 { 24 public: 25 /** @brief LidHandler constructor 26 */ 27 LidHandler(uint32_t fileHandle, bool permSide) : FileHandler(fileHandle) 28 { 29 std::string dir = permSide ? LID_PERM_DIR : LID_TEMP_DIR; 30 std::stringstream stream; 31 stream << std::hex << fileHandle; 32 lidPath = std::move(dir) + '/' + stream.str() + ".lid"; 33 } 34 35 virtual int writeFromMemory(uint32_t /*offset*/, uint32_t /*length*/, 36 uint64_t /*address*/) 37 { 38 return PLDM_ERROR_UNSUPPORTED_PLDM_CMD; 39 } 40 41 virtual int readIntoMemory(uint32_t offset, uint32_t& length, 42 uint64_t address) 43 { 44 return transferFileData(lidPath, true, offset, length, address); 45 } 46 47 virtual int read(uint32_t offset, uint32_t& length, Response& response) 48 { 49 return readFile(lidPath, offset, length, response); 50 } 51 52 virtual int fileAck(uint8_t /*fileStatus*/) 53 { 54 return PLDM_ERROR_UNSUPPORTED_PLDM_CMD; 55 } 56 57 /** @brief LidHandler destructor 58 */ 59 ~LidHandler() 60 { 61 } 62 63 protected: 64 std::string lidPath; 65 }; 66 67 } // namespace responder 68 } // namespace pldm 69