blob: eabcd0941ecfb739350d3ca7e223182135858f1c [file] [log] [blame]
Patrick Venturee7728422018-11-14 20:16:33 -08001#pragma once
2
Patrick Venture8b588562018-11-18 08:44:33 -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 Venturec9c60882019-01-17 11:44:47 -08008#include <utility>
Patrick Venture517710d2019-01-17 11:37:40 -08009#include <vector>
Patrick Venture92973f12018-11-16 21:00:44 -080010
Patrick Venture1d5a31c2019-05-20 11:38:22 -070011namespace ipmi_flash
Patrick Venturee7728422018-11-14 20:16:33 -080012{
13
Patrick Venture5251da92019-01-17 11:25:26 -080014class LpcMapperNuvoton : public HardwareMapperInterface
Patrick Venturee7728422018-11-14 20:16:33 -080015{
16 public:
Patrick Venture78b1a662019-01-17 12:38:26 -080017 static std::unique_ptr<HardwareMapperInterface>
18 createNuvotonMapper(std::uint32_t regionAddress);
Patrick Venturee7728422018-11-14 20:16:33 -080019
Patrick Venture8b588562018-11-18 08:44:33 -080020 /**
21 * Create an LpcMapper for Nuvoton.
22 *
Patrick Venture78b1a662019-01-17 12:38:26 -080023 * @param[in] regionAddress - where to map the window into BMC memory.
Patrick Venture8b588562018-11-18 08:44:33 -080024 * @param[in] a sys call interface pointer.
25 * @todo Needs reserved memory region's physical address and size.
26 */
Patrick Venture78b1a662019-01-17 12:38:26 -080027 LpcMapperNuvoton(std::uint32_t regionAddress,
28 const internal::Sys* sys = &internal::sys_impl) :
29 regionAddress(regionAddress),
Patrick Venture8b588562018-11-18 08:44:33 -080030 sys(sys){};
Patrick Venturee7728422018-11-14 20:16:33 -080031
Patrick Venture2343cfc2019-01-17 13:04:36 -080032 void close() override;
33
Patrick Venturee7728422018-11-14 20:16:33 -080034 std::pair<std::uint32_t, std::uint32_t>
35 mapWindow(std::uint32_t address, std::uint32_t length) override;
Patrick Venture8b588562018-11-18 08:44:33 -080036
Patrick Venture517710d2019-01-17 11:37:40 -080037 std::vector<std::uint8_t> copyFrom(std::uint32_t length) override;
38
Patrick Venture8b588562018-11-18 08:44:33 -080039 private:
Patrick Venture78b1a662019-01-17 12:38:26 -080040 std::uint32_t regionAddress;
Patrick Venturefa9d0c92018-12-13 16:38:27 -080041 const internal::Sys* sys;
Patrick Venturee7728422018-11-14 20:16:33 -080042};
43
Patrick Venture1d5a31c2019-05-20 11:38:22 -070044} // namespace ipmi_flash