blob: 91c976b6afac322af2208df6bd9905c1207c8ccd [file] [log] [blame]
Patrick Venture1cde5f92018-11-07 08:26:47 -08001#pragma once
2
3#include "data_handler.hpp"
Patrick Venturee7728422018-11-14 20:16:33 -08004#include "lpc_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 */
34 explicit LpcDataHandler(std::unique_ptr<LpcMapperInterface> mapper) :
35 mapper(std::move(mapper))
36 {
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 Venture8c535332018-11-08 15:58:00 -080042 bool write(const std::vector<std::uint8_t>& configuration) override;
43 std::vector<std::uint8_t> read() override;
Patrick Venturee7728422018-11-14 20:16:33 -080044
45 private:
46 std::unique_ptr<LpcMapperInterface> mapper;
Patrick Venture1cde5f92018-11-07 08:26:47 -080047};
48
49} // namespace blobs