Brandon Kim | 55dcada | 2022-03-09 02:18:01 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Brandon Kim | 1d0c356 | 2022-06-06 20:50:57 -0700 | [diff] [blame] | 3 | #include "data_interface.hpp" |
| 4 | |
Brandon Kim | 55dcada | 2022-03-09 02:18:01 -0800 | [diff] [blame] | 5 | #include <stdplus/fd/managed.hpp> |
| 6 | #include <stdplus/fd/mmap.hpp> |
| 7 | |
| 8 | #include <cstdint> |
| 9 | #include <memory> |
| 10 | #include <span> |
| 11 | #include <vector> |
| 12 | |
| 13 | namespace bios_bmc_smm_error_logger |
| 14 | { |
| 15 | |
| 16 | /** |
Brandon Kim | 55dcada | 2022-03-09 02:18:01 -0800 | [diff] [blame] | 17 | * Data handler for reading and writing data via the PCI bridge. |
| 18 | * |
| 19 | */ |
| 20 | class PciDataHandler : public DataInterface |
| 21 | { |
| 22 | public: |
| 23 | explicit PciDataHandler(uint32_t regionAddress, size_t regionSize, |
| 24 | std::unique_ptr<stdplus::fd::Fd> fd); |
| 25 | |
| 26 | std::vector<uint8_t> read(uint32_t offset, uint32_t length) override; |
| 27 | uint32_t write(const uint32_t offset, |
| 28 | const std::span<const uint8_t> bytes) override; |
| 29 | uint32_t getMemoryRegionSize() override; |
| 30 | |
| 31 | private: |
| 32 | uint32_t regionAddress; |
| 33 | uint32_t regionSize; |
| 34 | |
| 35 | std::unique_ptr<stdplus::fd::Fd> fd; |
| 36 | stdplus::fd::MMap mmap; |
| 37 | }; |
| 38 | |
| 39 | } // namespace bios_bmc_smm_error_logger |