Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <cstdint> |
| 4 | #include <utility> |
Patrick Venture | 517710d | 2019-01-17 11:37:40 -0800 | [diff] [blame] | 5 | #include <vector> |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 6 | |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame^] | 7 | namespace ipmi_flash |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 8 | { |
| 9 | |
| 10 | /** |
Patrick Venture | 5251da9 | 2019-01-17 11:25:26 -0800 | [diff] [blame] | 11 | * Different LPC (or P2a) memory map implementations may require different |
| 12 | * mechanisms for specific tasks such as mapping the memory window or copying |
| 13 | * out data. |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 14 | */ |
Patrick Venture | 5251da9 | 2019-01-17 11:25:26 -0800 | [diff] [blame] | 15 | class HardwareMapperInterface |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 16 | { |
| 17 | public: |
Patrick Venture | 5251da9 | 2019-01-17 11:25:26 -0800 | [diff] [blame] | 18 | virtual ~HardwareMapperInterface() = default; |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 19 | |
| 20 | /** |
Patrick Venture | 2343cfc | 2019-01-17 13:04:36 -0800 | [diff] [blame] | 21 | * Close the mapper. This could mean, send an ioctl to turn off the region, |
| 22 | * or unmap anything mmapped. |
| 23 | */ |
| 24 | virtual void close() = 0; |
| 25 | |
| 26 | /** |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 27 | * Returns a windowOffset and windowSize if the requested window was mapped. |
| 28 | * |
| 29 | * TODO: If the length requested is too large, windowSize will be written |
| 30 | * with the max size that the BMC can map and returns false. |
| 31 | * |
| 32 | * @param[in] address - The address for mapping (passed to LPC window) |
| 33 | * @param[in] length - The length of the region |
| 34 | * @return windowOffset, windowSize - The offset into the window and |
| 35 | * length of the region. On failure, length is set to 0. |
| 36 | */ |
| 37 | virtual std::pair<std::uint32_t, std::uint32_t> |
| 38 | mapWindow(std::uint32_t address, std::uint32_t length) = 0; |
Patrick Venture | 517710d | 2019-01-17 11:37:40 -0800 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Returns the bytes from the mapped window. |
| 42 | * |
| 43 | * @param[in] length - the number of bytes to copy. |
| 44 | * @return the bytes copied out of the region. |
| 45 | */ |
| 46 | virtual std::vector<std::uint8_t> copyFrom(std::uint32_t length) = 0; |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 47 | }; |
| 48 | |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame^] | 49 | } // namespace ipmi_flash |