Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "data_handler.hpp" |
Patrick Venture | 5251da9 | 2019-01-17 11:25:26 -0800 | [diff] [blame] | 4 | #include "window_hw_interface.hpp" |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 5 | |
| 6 | #include <cstdint> |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 7 | #include <memory> |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 10 | namespace ipmi_flash |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 11 | { |
| 12 | |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 13 | struct LpcRegion |
| 14 | { |
| 15 | /* Host LPC address where the chunk is to be mapped. */ |
| 16 | std::uint32_t address; |
| 17 | |
| 18 | /* Size of the chunk to be mapped. */ |
| 19 | std::uint32_t length; |
| 20 | } __attribute__((packed)); |
| 21 | |
| 22 | /** |
| 23 | * Data Handler for configuration the ASPEED LPC memory region, reading and |
| 24 | * writing data. |
| 25 | */ |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 26 | class LpcDataHandler : public DataInterface |
| 27 | { |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 28 | public: |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 29 | /** |
| 30 | * Create an LpcDataHandler. |
| 31 | * |
| 32 | * @param[in] mapper - pointer to a mapper implementation to use. |
| 33 | */ |
Patrick Venture | 78b1a66 | 2019-01-17 12:38:26 -0800 | [diff] [blame] | 34 | explicit LpcDataHandler(std::unique_ptr<HardwareMapperInterface> mapper) : |
Patrick Venture | 09c4f7a | 2018-11-16 20:28:04 -0800 | [diff] [blame] | 35 | mapper(std::move(mapper)), initialized(false) |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 36 | { |
| 37 | } |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 38 | |
Patrick Venture | 0d2a813 | 2018-11-09 11:34:21 -0800 | [diff] [blame] | 39 | bool open() override; |
Patrick Venture | 0fbabf2 | 2018-11-09 11:54:12 -0800 | [diff] [blame] | 40 | bool close() override; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 41 | std::vector<std::uint8_t> copyFrom(std::uint32_t length) override; |
Patrick Venture | 7430464 | 2019-01-17 09:31:04 -0800 | [diff] [blame] | 42 | bool writeMeta(const std::vector<std::uint8_t>& configuration) override; |
| 43 | std::vector<std::uint8_t> readMeta() override; |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 44 | |
| 45 | private: |
Patrick Venture | 09c4f7a | 2018-11-16 20:28:04 -0800 | [diff] [blame] | 46 | bool setInitializedAndReturn(bool value) |
| 47 | { |
| 48 | initialized = value; |
| 49 | return value; |
| 50 | } |
| 51 | |
Patrick Venture | 5251da9 | 2019-01-17 11:25:26 -0800 | [diff] [blame] | 52 | std::unique_ptr<HardwareMapperInterface> mapper; |
Patrick Venture | 09c4f7a | 2018-11-16 20:28:04 -0800 | [diff] [blame] | 53 | bool initialized; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 56 | } // namespace ipmi_flash |