Deepak Kodihalli | f6d3a83 | 2019-11-19 07:00:29 -0600 | [diff] [blame] | 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 | |
Deepak Kodihalli | 75e02f8 | 2019-11-20 02:51:05 -0600 | [diff] [blame] | 41 | virtual int readIntoMemory(uint32_t offset, uint32_t& length, |
Deepak Kodihalli | f6d3a83 | 2019-11-19 07:00:29 -0600 | [diff] [blame] | 42 | uint64_t address) |
| 43 | { |
| 44 | return transferFileData(lidPath, true, offset, length, address); |
| 45 | } |
| 46 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 47 | virtual int write(const char* /*buffer*/, uint32_t /*offset*/, |
| 48 | uint32_t& /*length*/) |
| 49 | { |
| 50 | return PLDM_ERROR_UNSUPPORTED_PLDM_CMD; |
| 51 | } |
| 52 | |
Deepak Kodihalli | 75e02f8 | 2019-11-20 02:51:05 -0600 | [diff] [blame] | 53 | virtual int read(uint32_t offset, uint32_t& length, Response& response) |
| 54 | { |
| 55 | return readFile(lidPath, offset, length, response); |
| 56 | } |
| 57 | |
Deepak Kodihalli | 2da1bfe | 2019-12-14 08:28:09 -0600 | [diff] [blame] | 58 | virtual int fileAck(uint8_t /*fileStatus*/) |
| 59 | { |
| 60 | return PLDM_ERROR_UNSUPPORTED_PLDM_CMD; |
| 61 | } |
| 62 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 63 | virtual int newFileAvailable(uint64_t /*length*/) |
| 64 | |
| 65 | { |
| 66 | return PLDM_ERROR_UNSUPPORTED_PLDM_CMD; |
| 67 | } |
| 68 | |
Deepak Kodihalli | f6d3a83 | 2019-11-19 07:00:29 -0600 | [diff] [blame] | 69 | /** @brief LidHandler destructor |
| 70 | */ |
| 71 | ~LidHandler() |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | protected: |
| 76 | std::string lidPath; |
| 77 | }; |
| 78 | |
| 79 | } // namespace responder |
| 80 | } // namespace pldm |