1 #pragma once 2 3 #include "data_interface.hpp" 4 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 /** 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 regionSize; 33 34 std::unique_ptr<stdplus::fd::Fd> fd; 35 stdplus::fd::MMap mmap; 36 }; 37 38 } // namespace bios_bmc_smm_error_logger 39