blob: d00bfcd329c58a620b4b1284d9e2ba0c1bce3151 [file] [log] [blame]
Patrick Venturee7728422018-11-14 20:16:33 -08001#pragma once
2
3#include <cstdint>
4#include <utility>
Patrick Venture517710d2019-01-17 11:37:40 -08005#include <vector>
Patrick Venturee7728422018-11-14 20:16:33 -08006
7namespace blobs
8{
9
10/**
Patrick Venture5251da92019-01-17 11:25:26 -080011 * 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 Venturee7728422018-11-14 20:16:33 -080014 */
Patrick Venture5251da92019-01-17 11:25:26 -080015class HardwareMapperInterface
Patrick Venturee7728422018-11-14 20:16:33 -080016{
17 public:
Patrick Venture5251da92019-01-17 11:25:26 -080018 virtual ~HardwareMapperInterface() = default;
Patrick Venturee7728422018-11-14 20:16:33 -080019
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 Venture517710d2019-01-17 11:37:40 -080033
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 Venturee7728422018-11-14 20:16:33 -080041};
42
43} // namespace blobs