| 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 |  | 
|  | 7 | namespace blobs | 
|  | 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 | /** | 
|  | 21 | * Returns a windowOffset and windowSize if the requested window was mapped. | 
|  | 22 | * | 
|  | 23 | * TODO: If the length requested is too large, windowSize will be written | 
|  | 24 | * with the max size that the BMC can map and returns false. | 
|  | 25 | * | 
|  | 26 | * @param[in] address - The address for mapping (passed to LPC window) | 
|  | 27 | * @param[in] length - The length of the region | 
|  | 28 | * @return windowOffset, windowSize - The offset into the window and | 
|  | 29 | * length of the region.  On failure, length is set to 0. | 
|  | 30 | */ | 
|  | 31 | virtual std::pair<std::uint32_t, std::uint32_t> | 
|  | 32 | mapWindow(std::uint32_t address, std::uint32_t length) = 0; | 
| Patrick Venture | 517710d | 2019-01-17 11:37:40 -0800 | [diff] [blame^] | 33 |  | 
|  | 34 | /** | 
|  | 35 | * Returns the bytes from the mapped window. | 
|  | 36 | * | 
|  | 37 | * @param[in] length - the number of bytes to copy. | 
|  | 38 | * @return the bytes copied out of the region. | 
|  | 39 | */ | 
|  | 40 | virtual std::vector<std::uint8_t> copyFrom(std::uint32_t length) = 0; | 
| Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 41 | }; | 
|  | 42 |  | 
|  | 43 | } // namespace blobs |