Brandon Kim | 1d0c356 | 2022-06-06 20:50:57 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <cstdint> |
| 4 | #include <span> |
| 5 | #include <vector> |
| 6 | |
| 7 | namespace bios_bmc_smm_error_logger |
| 8 | { |
| 9 | |
| 10 | /** |
| 11 | * Each data transport mechanism must implement the DataInterface. |
| 12 | */ |
| 13 | class DataInterface |
| 14 | { |
| 15 | public: |
| 16 | virtual ~DataInterface() = default; |
| 17 | |
| 18 | /** |
| 19 | * Read bytes from shared buffer (blocking call). |
| 20 | * |
Brandon Kim | 35d4335 | 2022-06-16 11:13:36 -0700 | [diff] [blame] | 21 | * @param[in] offset - offset to read from relative to MMIO space |
Brandon Kim | 1d0c356 | 2022-06-06 20:50:57 -0700 | [diff] [blame] | 22 | * @param[in] length - number of bytes to read |
| 23 | * @return the bytes read |
| 24 | */ |
| 25 | virtual std::vector<uint8_t> read(const uint32_t offset, |
| 26 | const uint32_t length) = 0; |
| 27 | |
| 28 | /** |
| 29 | * Write bytes to shared buffer. |
| 30 | * |
Brandon Kim | 35d4335 | 2022-06-16 11:13:36 -0700 | [diff] [blame] | 31 | * @param[in] offset - offset to write to relative to MMIO space |
Brandon Kim | 1d0c356 | 2022-06-06 20:50:57 -0700 | [diff] [blame] | 32 | * @param[in] bytes - byte vector of data. |
| 33 | * @return return the byte length written |
| 34 | */ |
| 35 | virtual uint32_t write(const uint32_t offset, |
| 36 | const std::span<const uint8_t> bytes) = 0; |
| 37 | |
| 38 | /** |
| 39 | * Getter for Memory Region Size |
| 40 | * |
| 41 | * @return return Memory Region size allocated |
| 42 | */ |
| 43 | virtual uint32_t getMemoryRegionSize() = 0; |
| 44 | }; |
| 45 | |
| 46 | } // namespace bios_bmc_smm_error_logger |