blob: 95917c64dc8a2c61d10546a130bc078f885f46cf [file] [log] [blame]
Patrick Venture1cde5f92018-11-07 08:26:47 -08001#pragma once
2
3#include "data_handler.hpp"
Patrick Venture5251da92019-01-17 11:25:26 -08004#include "window_hw_interface.hpp"
Patrick Venture1cde5f92018-11-07 08:26:47 -08005
6#include <cstdint>
Patrick Venturee7728422018-11-14 20:16:33 -08007#include <memory>
Patrick Venture1cde5f92018-11-07 08:26:47 -08008#include <vector>
9
10namespace blobs
11{
12
Patrick Venture8c535332018-11-08 15:58:00 -080013struct 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 Venture1cde5f92018-11-07 08:26:47 -080026class LpcDataHandler : public DataInterface
27{
Patrick Venture1cde5f92018-11-07 08:26:47 -080028 public:
Patrick Venturee7728422018-11-14 20:16:33 -080029 /**
30 * Create an LpcDataHandler.
31 *
32 * @param[in] mapper - pointer to a mapper implementation to use.
33 */
Patrick Venture78b1a662019-01-17 12:38:26 -080034 explicit LpcDataHandler(std::unique_ptr<HardwareMapperInterface> mapper) :
Patrick Venture09c4f7a2018-11-16 20:28:04 -080035 mapper(std::move(mapper)), initialized(false)
Patrick Venturee7728422018-11-14 20:16:33 -080036 {
37 }
Patrick Venture1cde5f92018-11-07 08:26:47 -080038
Patrick Venture0d2a8132018-11-09 11:34:21 -080039 bool open() override;
Patrick Venture0fbabf22018-11-09 11:54:12 -080040 bool close() override;
Patrick Venture1cde5f92018-11-07 08:26:47 -080041 std::vector<std::uint8_t> copyFrom(std::uint32_t length) override;
Patrick Venture74304642019-01-17 09:31:04 -080042 bool writeMeta(const std::vector<std::uint8_t>& configuration) override;
43 std::vector<std::uint8_t> readMeta() override;
Patrick Venturee7728422018-11-14 20:16:33 -080044
45 private:
Patrick Venture09c4f7a2018-11-16 20:28:04 -080046 bool setInitializedAndReturn(bool value)
47 {
48 initialized = value;
49 return value;
50 }
51
Patrick Venture5251da92019-01-17 11:25:26 -080052 std::unique_ptr<HardwareMapperInterface> mapper;
Patrick Venture09c4f7a2018-11-16 20:28:04 -080053 bool initialized;
Patrick Venture1cde5f92018-11-07 08:26:47 -080054};
55
56} // namespace blobs