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 | 9b37b09 | 2020-05-28 20:58:57 -0700 | [diff] [blame] | 36 | {} |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 37 | |
Patrick Venture | 0d2a813 | 2018-11-09 11:34:21 -0800 | [diff] [blame] | 38 | bool open() override; |
Patrick Venture | 0fbabf2 | 2018-11-09 11:54:12 -0800 | [diff] [blame] | 39 | bool close() override; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 40 | std::vector<std::uint8_t> copyFrom(std::uint32_t length) override; |
Patrick Venture | 7430464 | 2019-01-17 09:31:04 -0800 | [diff] [blame] | 41 | bool writeMeta(const std::vector<std::uint8_t>& configuration) override; |
| 42 | std::vector<std::uint8_t> readMeta() override; |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 43 | |
| 44 | private: |
Patrick Venture | a606550 | 2020-10-26 13:06:40 -0700 | [diff] [blame] | 45 | bool setInitializedAndReturn(bool value); |
Patrick Venture | 09c4f7a | 2018-11-16 20:28:04 -0800 | [diff] [blame] | 46 | |
Patrick Venture | 5251da9 | 2019-01-17 11:25:26 -0800 | [diff] [blame] | 47 | std::unique_ptr<HardwareMapperInterface> mapper; |
Patrick Venture | 09c4f7a | 2018-11-16 20:28:04 -0800 | [diff] [blame] | 48 | bool initialized; |
Patrick Venture | 36bffb4 | 2019-06-24 10:47:47 -0700 | [diff] [blame] | 49 | /* The LPC Handler does not take ownership of this, in case there's cleanup |
| 50 | * required for close() |
| 51 | */ |
| 52 | MemorySet memory = {}; |
| 53 | |
| 54 | /* Offset in reserved memory at which host data arrives. */ |
| 55 | /* Size of the chunk of the memory region in use by the host (e.g. |
| 56 | * mapped over external block mechanism). |
| 57 | */ |
| 58 | WindowMapResult mappingResult = {}; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 59 | }; |
| 60 | |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 61 | } // namespace ipmi_flash |