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