blob: f99a811fff1653e77c8d7f87fa696bbc0c199e5c [file] [log] [blame]
Patrick Venture1cde5f92018-11-07 08:26:47 -08001#pragma once
2
3#include "data_handler.hpp"
Patrick Venture8f6fb602019-04-30 16:43:18 -07004#include "internal/sys.hpp"
Patrick Venture1cde5f92018-11-07 08:26:47 -08005
6#include <cstdint>
Patrick Venturebc40c612019-04-30 16:48:19 -07007#include <string>
Patrick Venture1cde5f92018-11-07 08:26:47 -08008#include <vector>
9
10namespace blobs
11{
12
Patrick Venture8c535332018-11-08 15:58:00 -080013/** P2A configuration response. */
14struct PciConfigResponse
15{
16 std::uint32_t address;
17} __attribute__((packed));
18
19/**
20 * Data handler for reading and writing data via the P2A bridge.
Patrick Venture8f6fb602019-04-30 16:43:18 -070021 *
22 * @note: Currently implemented to support only aspeed-p2a-ctrl.
Patrick Venture8c535332018-11-08 15:58:00 -080023 */
Patrick Venture1cde5f92018-11-07 08:26:47 -080024class PciDataHandler : public DataInterface
25{
Patrick Venture1cde5f92018-11-07 08:26:47 -080026 public:
Patrick Venture8f6fb602019-04-30 16:43:18 -070027 PciDataHandler(std::uint32_t regionAddress,
28 const internal::Sys* sys = &internal::sys_impl) :
29 regionAddress(regionAddress),
30 sys(sys){};
Patrick Venture1cde5f92018-11-07 08:26:47 -080031
Patrick Venture0d2a8132018-11-09 11:34:21 -080032 bool open() override;
Patrick Venture0fbabf22018-11-09 11:54:12 -080033 bool close() override;
Patrick Venture1cde5f92018-11-07 08:26:47 -080034 std::vector<std::uint8_t> copyFrom(std::uint32_t length) override;
Patrick Venture74304642019-01-17 09:31:04 -080035 bool writeMeta(const std::vector<std::uint8_t>& configuration) override;
36 std::vector<std::uint8_t> readMeta() override;
Patrick Ventureb0c84d02018-11-09 12:00:31 -080037
38 private:
39 std::uint32_t regionAddress;
Patrick Venture8f6fb602019-04-30 16:43:18 -070040 const internal::Sys* sys;
Patrick Venturebc40c612019-04-30 16:48:19 -070041 static const std::string p2aControlPath;
Patrick Venture1cde5f92018-11-07 08:26:47 -080042};
43
44} // namespace blobs