blob: f3608d092e233faff1d2bc0a5d10b61a9d92b78d [file] [log] [blame]
Patrick Venturee7728422018-11-14 20:16:33 -08001#pragma once
2
Patrick Venture7b91cbc2018-11-28 14:24:41 -08003#include "internal/sys.hpp"
Patrick Venture5251da92019-01-17 11:25:26 -08004#include "window_hw_interface.hpp"
Patrick Venturee7728422018-11-14 20:16:33 -08005
Patrick Venturec9c60882019-01-17 11:44:47 -08006#include <cstdint>
Patrick Venture92973f12018-11-16 21:00:44 -08007#include <memory>
Patrick Venturebf064632019-01-17 12:20:21 -08008#include <string>
Patrick Venturec9c60882019-01-17 11:44:47 -08009#include <utility>
10#include <vector>
Patrick Venture92973f12018-11-16 21:00:44 -080011
Patrick Venturee7728422018-11-14 20:16:33 -080012namespace blobs
13{
14
Patrick Venture5251da92019-01-17 11:25:26 -080015class LpcMapperAspeed : public HardwareMapperInterface
Patrick Venturee7728422018-11-14 20:16:33 -080016{
17 public:
Patrick Venture5251da92019-01-17 11:25:26 -080018 static std::unique_ptr<HardwareMapperInterface>
Patrick Venture78b1a662019-01-17 12:38:26 -080019 createAspeedMapper(std::uint32_t regionAddress, std::size_t regionSize);
Patrick Venturee7728422018-11-14 20:16:33 -080020
Patrick Venture78b1a662019-01-17 12:38:26 -080021 LpcMapperAspeed(std::uint32_t regionAddress, std::size_t regionSize,
Patrick Venturefa9d0c92018-12-13 16:38:27 -080022 const internal::Sys* sys = &internal::sys_impl) :
Patrick Venture78b1a662019-01-17 12:38:26 -080023 regionAddress(regionAddress),
24 regionSize(regionSize), sys(sys){};
Patrick Venturee7728422018-11-14 20:16:33 -080025
26 std::pair<std::uint32_t, std::uint32_t>
27 mapWindow(std::uint32_t address, std::uint32_t length) override;
Patrick Venture7b91cbc2018-11-28 14:24:41 -080028
Patrick Venture517710d2019-01-17 11:37:40 -080029 std::vector<std::uint8_t> copyFrom(std::uint32_t length) override;
30
Patrick Venture7b91cbc2018-11-28 14:24:41 -080031 private:
Patrick Venturebf064632019-01-17 12:20:21 -080032 static const std::string lpcControlPath;
Patrick Venture5d96c352019-01-17 12:44:06 -080033 int mappedFd = -1;
Patrick Venture78b1a662019-01-17 12:38:26 -080034 std::uint32_t regionAddress;
Patrick Venture28abae72018-12-14 09:44:02 -080035 std::size_t regionSize;
Patrick Venturefa9d0c92018-12-13 16:38:27 -080036 const internal::Sys* sys;
Patrick Venturee7728422018-11-14 20:16:33 -080037};
38
39} // namespace blobs