1
1
#pragma once
2
2
3
+ #include " libpldm/file_io.h"
4
+
3
5
#include " oem_ibm_handler.hpp"
4
6
#include " pldmd/pldm_resp_interface.hpp"
5
7
8
+ #include < sdbusplus/bus.hpp>
9
+ #include < sdbusplus/server.hpp>
10
+ #include < sdbusplus/server/object.hpp>
11
+ #include < sdbusplus/timer.hpp>
12
+ #include < sdeventplus/clock.hpp>
13
+ #include < sdeventplus/event.hpp>
14
+ #include < sdeventplus/exception.hpp>
15
+ #include < sdeventplus/source/io.hpp>
16
+ #include < sdeventplus/source/signal.hpp>
17
+ #include < sdeventplus/source/time.hpp>
18
+ #include < stdplus/signal.hpp>
19
+ #include < xyz/openbmc_project/Logging/Entry/server.hpp>
20
+
21
+ #include < vector>
6
22
namespace pldm
7
23
{
8
24
9
25
namespace responder
10
26
{
27
+ using namespace sdeventplus ;
28
+ using namespace sdeventplus ::source;
29
+ constexpr auto clockId = sdeventplus::ClockId::RealTime;
30
+ using Timer = Time<clockId>;
31
+ using Clock = Clock<clockId>;
11
32
12
33
class FileHandler ;
13
34
namespace dma
@@ -33,6 +54,34 @@ namespace fs = std::filesystem;
33
54
*/
34
55
class FileHandler
35
56
{
57
+ protected:
58
+ /* * @brief method to send response to host after completion of DMA operation
59
+ * @param[in] responseHdr - contain response related data
60
+ * @param[in] rStatus - operation status either success/fail/not suppoted.
61
+ * @param[in] length - length to be read/write mentioned by Host
62
+ */
63
+ virtual void dmaResponseToHost (const ResponseHdr& responseHdr,
64
+ const pldm_completion_codes rStatus,
65
+ uint32_t length);
66
+
67
+ /* * @brief method to send response to host after completion of DMA operation
68
+ * @param[in] responseHdr - contain response related data
69
+ * @param[in] rStatus - operation status either success/fail/not suppoted.
70
+ * @param[in] length - length to be read/write mentioned by Host
71
+ */
72
+ virtual void dmaResponseToHost (const ResponseHdr& responseHdr,
73
+ const pldm_fileio_completion_codes rStatus,
74
+ uint32_t length);
75
+
76
+ /* * @brief method to delete all shared pointer object
77
+ * @param[in] responseHdr - contain response related data
78
+ * @param[in] xdmaInterface - interface to transfer data between BMc and
79
+ * Host
80
+ */
81
+ virtual void
82
+ deleteAIOobjects (const std::shared_ptr<dma::DMA>& xdmaInterface,
83
+ const ResponseHdr& responseHdr);
84
+
36
85
public:
37
86
/* * @brief Method to write an oem file type from host memory. Individual
38
87
* file types need to override this method to do the file specific
@@ -44,9 +93,11 @@ class FileHandler
44
93
* tasks
45
94
* @return PLDM status code
46
95
*/
47
- virtual int writeFromMemory (uint32_t offset, uint32_t length,
48
- uint64_t address,
49
- oem_platform::Handler* oemPlatformHandler) = 0;
96
+ virtual void writeFromMemory (uint32_t offset, uint32_t length,
97
+ uint64_t address,
98
+ oem_platform::Handler* oemPlatformHandler,
99
+ ResponseHdr& responseHdr,
100
+ sdeventplus::Event& event) = 0;
50
101
51
102
/* * @brief Method to read an oem file type into host memory. Individual
52
103
* file types need to override this method to do the file specific
@@ -58,9 +109,11 @@ class FileHandler
58
109
* tasks
59
110
* @return PLDM status code
60
111
*/
61
- virtual int readIntoMemory (uint32_t offset, uint32_t & length,
62
- uint64_t address,
63
- oem_platform::Handler* oemPlatformHandler) = 0;
112
+ virtual void readIntoMemory (uint32_t offset, uint32_t & length,
113
+ uint64_t address,
114
+ oem_platform::Handler* oemPlatformHandler,
115
+ ResponseHdr& responseHdr,
116
+ sdeventplus::Event& event) = 0;
64
117
65
118
/* * @brief Method to read an oem file type's content into the PLDM response.
66
119
* @param[in] offset - offset to read
@@ -151,15 +204,28 @@ class FileHandler
151
204
*
152
205
* @return PLDM status code
153
206
*/
154
- virtual int transferFileData (const fs::path& path, bool upstream,
155
- uint32_t offset, uint32_t & length,
156
- uint64_t address);
207
+ virtual void transferFileData (const fs::path& path, bool upstream,
208
+ uint32_t offset, uint32_t & length,
209
+ uint64_t address, ResponseHdr& responseHdr,
210
+ sdeventplus::Event& event);
157
211
158
- virtual int transferFileData (int fd, bool upstream, uint32_t offset,
159
- uint32_t & length, uint64_t address);
212
+ virtual void transferFileData (int fd, bool upstream, uint32_t offset,
213
+ uint32_t & length, uint64_t address,
214
+ ResponseHdr& responseHdr,
215
+ sdeventplus::Event& event);
160
216
161
- virtual int transferFileDataToSocket (int fd, uint32_t & length,
162
- uint64_t address);
217
+ virtual void transferFileDataToSocket (int fd, uint32_t & length,
218
+ uint64_t address,
219
+ ResponseHdr& responseHdr,
220
+ sdeventplus::Event& event);
221
+
222
+ /* * @brief method to do necessary operation according different
223
+ * file type and being call when data transfer completed.
224
+ *
225
+ * @param[in] IsWriteToMemOp - type of operation to decide what operation
226
+ * needs to be done after data transfer.
227
+ */
228
+ virtual void postDataTransferCallBack (bool IsWriteToMemOp) = 0;
163
229
164
230
/* * @brief Constructor to create a FileHandler object
165
231
*/
@@ -181,5 +247,13 @@ class FileHandler
181
247
182
248
std::unique_ptr<FileHandler> getHandlerByType (uint16_t fileType,
183
249
uint32_t fileHandle);
250
+
251
+ /* * @brief Method to create shared file handler objects based on file type
252
+ *
253
+ * @param[in] fileType - type of file
254
+ * @param[in] fileHandle - file handle
255
+ */
256
+ std::shared_ptr<FileHandler> getSharedHandlerByType (uint16_t fileType,
257
+ uint32_t fileHandle);
184
258
} // namespace responder
185
259
} // namespace pldm
0 commit comments