bmc: lpc: add support for lpc mapping and copying
The lpc handler object now handles copying the data after the window is
mapped, but the hardware specific pieces still play in dealing with the
driver directly.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I2f448411fd4ef9b61b5d1158915c70902b16666b
diff --git a/lpc_nuvoton.hpp b/lpc_nuvoton.hpp
index eabcd09..c66653b 100644
--- a/lpc_nuvoton.hpp
+++ b/lpc_nuvoton.hpp
@@ -15,30 +15,42 @@
{
public:
static std::unique_ptr<HardwareMapperInterface>
- createNuvotonMapper(std::uint32_t regionAddress);
+ createNuvotonMapper(std::uint32_t regionAddress,
+ std::uint32_t regionSize);
/**
* Create an LpcMapper for Nuvoton.
*
* @param[in] regionAddress - where to map the window into BMC memory.
+ * @param[in] regionSize - the size to map for copying data.
* @param[in] a sys call interface pointer.
* @todo Needs reserved memory region's physical address and size.
*/
- LpcMapperNuvoton(std::uint32_t regionAddress,
+ LpcMapperNuvoton(std::uint32_t regionAddress, std::uint32_t regionSize,
const internal::Sys* sys = &internal::sys_impl) :
regionAddress(regionAddress),
- sys(sys){};
+ memoryRegionSize(regionSize), sys(sys){};
+
+ /** Attempt to map the window for copying bytes, after mapWindow is called.
+ * throws MapperException
+ */
+ MemorySet open() override;
void close() override;
- std::pair<std::uint32_t, std::uint32_t>
- mapWindow(std::uint32_t address, std::uint32_t length) override;
-
- std::vector<std::uint8_t> copyFrom(std::uint32_t length) override;
+ WindowMapResult mapWindow(std::uint32_t address,
+ std::uint32_t length) override;
private:
std::uint32_t regionAddress;
+ std::uint32_t memoryRegionSize;
const internal::Sys* sys;
+
+ /* The file handle to /dev/mem. */
+ int mappedFd = -1;
+
+ /* The pointer to the memory-mapped region. */
+ std::uint8_t* mapped = nullptr;
};
} // namespace ipmi_flash