blob: bb9e429b25d419211886c6ce7e613ae9ab83cf13 [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>
7#include <vector>
8
9namespace blobs
10{
11
Patrick Venture8c535332018-11-08 15:58:00 -080012/** P2A configuration response. */
13struct PciConfigResponse
14{
15 std::uint32_t address;
16} __attribute__((packed));
17
18/**
19 * Data handler for reading and writing data via the P2A bridge.
Patrick Venture8f6fb602019-04-30 16:43:18 -070020 *
21 * @note: Currently implemented to support only aspeed-p2a-ctrl.
Patrick Venture8c535332018-11-08 15:58:00 -080022 */
Patrick Venture1cde5f92018-11-07 08:26:47 -080023class PciDataHandler : public DataInterface
24{
Patrick Venture1cde5f92018-11-07 08:26:47 -080025 public:
Patrick Venture8f6fb602019-04-30 16:43:18 -070026 PciDataHandler(std::uint32_t regionAddress,
27 const internal::Sys* sys = &internal::sys_impl) :
28 regionAddress(regionAddress),
29 sys(sys){};
Patrick Venture1cde5f92018-11-07 08:26:47 -080030
Patrick Venture0d2a8132018-11-09 11:34:21 -080031 bool open() override;
Patrick Venture0fbabf22018-11-09 11:54:12 -080032 bool close() override;
Patrick Venture1cde5f92018-11-07 08:26:47 -080033 std::vector<std::uint8_t> copyFrom(std::uint32_t length) override;
Patrick Venture74304642019-01-17 09:31:04 -080034 bool writeMeta(const std::vector<std::uint8_t>& configuration) override;
35 std::vector<std::uint8_t> readMeta() override;
Patrick Ventureb0c84d02018-11-09 12:00:31 -080036
37 private:
38 std::uint32_t regionAddress;
Patrick Venture8f6fb602019-04-30 16:43:18 -070039 const internal::Sys* sys;
Patrick Venture1cde5f92018-11-07 08:26:47 -080040};
41
42} // namespace blobs