1 #pragma once 2 3 #include "internal/sys.hpp" 4 #include "window_hw_interface.hpp" 5 6 #include <cstdint> 7 #include <memory> 8 #include <utility> 9 #include <vector> 10 11 namespace ipmi_flash 12 { 13 14 class LpcMapperNuvoton : public HardwareMapperInterface 15 { 16 public: 17 static std::unique_ptr<HardwareMapperInterface> 18 createNuvotonMapper(std::uint32_t regionAddress, 19 std::uint32_t regionSize); 20 21 /** 22 * Create an LpcMapper for Nuvoton. 23 * 24 * @param[in] regionAddress - where to map the window into BMC memory. 25 * @param[in] regionSize - the size to map for copying data. 26 * @param[in] a sys call interface pointer. 27 * @todo Needs reserved memory region's physical address and size. 28 */ 29 LpcMapperNuvoton(std::uint32_t regionAddress, std::uint32_t regionSize, 30 const internal::Sys* sys = &internal::sys_impl) : 31 regionAddress(regionAddress), 32 memoryRegionSize(regionSize), sys(sys){}; 33 34 /** Attempt to map the window for copying bytes, after mapWindow is called. 35 * throws MapperException 36 */ 37 MemorySet open() override; 38 39 void close() override; 40 41 WindowMapResult mapWindow(std::uint32_t address, 42 std::uint32_t length) override; 43 44 private: 45 std::uint32_t regionAddress; 46 std::uint32_t memoryRegionSize; 47 const internal::Sys* sys; 48 49 /* The file handle to /dev/mem. */ 50 int mappedFd = -1; 51 52 /* The pointer to the memory-mapped region. */ 53 std::uint8_t* mapped = nullptr; 54 }; 55 56 } // namespace ipmi_flash 57