blob: bf179345616c94db81a08675084e85242b3a0625 [file] [log] [blame]
Patrick Venture33bf1692018-11-06 20:19:17 -08001#pragma once
2
Patrick Venture1cde5f92018-11-07 08:26:47 -08003#include <cstdint>
4#include <vector>
5
Patrick Venture1d5a31c2019-05-20 11:38:22 -07006namespace ipmi_flash
Patrick Venture33bf1692018-11-06 20:19:17 -08007{
8
9/**
10 * Each data transport mechanism must implement the DataInterface.
11 */
12class DataInterface
13{
14 public:
15 virtual ~DataInterface() = default;
Patrick Venture1cde5f92018-11-07 08:26:47 -080016
17 /**
Patrick Venture0d2a8132018-11-09 11:34:21 -080018 * Initialize data transport mechanism. Calling this should be idempotent
19 * if possible.
20 *
21 * @return true if successful
22 */
23 virtual bool open() = 0;
24
25 /**
Patrick Venture0fbabf22018-11-09 11:54:12 -080026 * Close the data transport mechanism.
27 *
28 * @return true if successful
29 */
30 virtual bool close() = 0;
31
32 /**
Patrick Venture1cde5f92018-11-07 08:26:47 -080033 * Copy bytes from external interface (blocking call).
34 *
35 * @param[in] length - number of bytes to copy
36 * @return the bytes read
37 */
38 virtual std::vector<std::uint8_t> copyFrom(std::uint32_t length) = 0;
Patrick Venture8c535332018-11-08 15:58:00 -080039
40 /**
41 * set configuration.
42 *
43 * @param[in] configuration - byte vector of data.
44 * @return bool - returns true on success.
45 */
Patrick Venture74304642019-01-17 09:31:04 -080046 virtual bool writeMeta(const std::vector<std::uint8_t>& configuration) = 0;
Patrick Venture8c535332018-11-08 15:58:00 -080047
48 /**
49 * read configuration.
50 *
51 * @return bytes - whatever bytes are required configuration information for
52 * the mechanism.
53 */
Patrick Venture74304642019-01-17 09:31:04 -080054 virtual std::vector<std::uint8_t> readMeta() = 0;
Patrick Venture1cde5f92018-11-07 08:26:47 -080055};
56
57struct DataHandlerPack
58{
59 std::uint16_t bitmask;
60 DataInterface* handler;
Patrick Venture33bf1692018-11-06 20:19:17 -080061};
62
Patrick Venture1d5a31c2019-05-20 11:38:22 -070063} // namespace ipmi_flash