blob: 45d4f73235356dcf660da596f4f7db382c4eb6f7 [file] [log] [blame]
Deepak Kodihallif6d3a832019-11-19 07:00:29 -06001#pragma once
2
3#include "config.h"
4
5#include "file_io_by_type.hpp"
6
7#include <sstream>
8#include <string>
9
10namespace pldm
11{
12namespace responder
13{
14
15using 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 */
22class 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 /** @brief LidHandler destructor
48 */
49 ~LidHandler()
50 {
51 }
52
53 protected:
54 std::string lidPath;
55};
56
57} // namespace responder
58} // namespace pldm