blob: ae7bfdce65971441861a2d74322ac3f811542342 [file] [log] [blame]
Brandon Kim55dcada2022-03-09 02:18:01 -08001#pragma once
2
Brandon Kim1d0c3562022-06-06 20:50:57 -07003#include "data_interface.hpp"
4
Brandon Kim55dcada2022-03-09 02:18:01 -08005#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
13namespace bios_bmc_smm_error_logger
14{
15
16/**
Brandon Kim55dcada2022-03-09 02:18:01 -080017 * Data handler for reading and writing data via the PCI bridge.
18 *
19 */
20class 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