Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "data_handler.hpp" |
Patrick Venture | 8f6fb60 | 2019-04-30 16:43:18 -0700 | [diff] [blame^] | 4 | #include "internal/sys.hpp" |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 5 | |
| 6 | #include <cstdint> |
| 7 | #include <vector> |
| 8 | |
| 9 | namespace blobs |
| 10 | { |
| 11 | |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 12 | /** P2A configuration response. */ |
| 13 | struct 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 Venture | 8f6fb60 | 2019-04-30 16:43:18 -0700 | [diff] [blame^] | 20 | * |
| 21 | * @note: Currently implemented to support only aspeed-p2a-ctrl. |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 22 | */ |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 23 | class PciDataHandler : public DataInterface |
| 24 | { |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 25 | public: |
Patrick Venture | 8f6fb60 | 2019-04-30 16:43:18 -0700 | [diff] [blame^] | 26 | PciDataHandler(std::uint32_t regionAddress, |
| 27 | const internal::Sys* sys = &internal::sys_impl) : |
| 28 | regionAddress(regionAddress), |
| 29 | sys(sys){}; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 30 | |
Patrick Venture | 0d2a813 | 2018-11-09 11:34:21 -0800 | [diff] [blame] | 31 | bool open() override; |
Patrick Venture | 0fbabf2 | 2018-11-09 11:54:12 -0800 | [diff] [blame] | 32 | bool close() override; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 33 | std::vector<std::uint8_t> copyFrom(std::uint32_t length) override; |
Patrick Venture | 7430464 | 2019-01-17 09:31:04 -0800 | [diff] [blame] | 34 | bool writeMeta(const std::vector<std::uint8_t>& configuration) override; |
| 35 | std::vector<std::uint8_t> readMeta() override; |
Patrick Venture | b0c84d0 | 2018-11-09 12:00:31 -0800 | [diff] [blame] | 36 | |
| 37 | private: |
| 38 | std::uint32_t regionAddress; |
Patrick Venture | 8f6fb60 | 2019-04-30 16:43:18 -0700 | [diff] [blame^] | 39 | const internal::Sys* sys; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | } // namespace blobs |