1 #pragma once
2 
3 #include "file_io_by_type.hpp"
4 
5 namespace pldm
6 {
7 namespace responder
8 {
9 
10 using namespace pldm::responder::dma;
11 
12 /** @class PelHandler
13  *
14  *  @brief Inherits and implements FileHandler. This class is used
15  *  to read/write pels.
16  */
17 class PelHandler : public FileHandler
18 {
19   public:
20     /** @brief PelHandler constructor
21      */
22     PelHandler(uint32_t fileHandle) : FileHandler(fileHandle)
23     {}
24 
25     virtual int writeFromMemory(uint32_t offset, uint32_t length,
26                                 uint64_t address);
27     virtual int readIntoMemory(uint32_t offset, uint32_t& length,
28                                uint64_t address);
29     virtual int read(uint32_t offset, uint32_t& length, Response& response);
30 
31     virtual int write(const char* /*buffer*/, uint32_t /*offset*/,
32                       uint32_t& /*length*/)
33     {
34         return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
35     }
36 
37     virtual int fileAck(uint8_t fileStatus);
38 
39     /** @brief method to store a pel file in tempfs and send
40      *  d-bus notification to pel daemon that it is ready for consumption
41      *
42      *  @param[in] pelFileName - the pel file path
43      */
44     virtual int storePel(std::string&& pelFileName);
45 
46     virtual int newFileAvailable(uint64_t /*length*/)
47     {
48         return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
49     }
50 
51     /** @brief PelHandler destructor
52      */
53     ~PelHandler()
54     {}
55 };
56 
57 } // namespace responder
58 } // namespace pldm
59