fru-device: add FRUReader EEPROM cache

This doesn't provide a huge benefit currently, but is a preparatory step
for adding support for a wider variety of FRU format parsers.  If
parsers for multiple formats are interested in reading the same areas of
an EEPROM, the caching provided by this abstraction avoids the redundant
bus traffic of all of them re-reading the same bytes over and over.

Tested: on an ASRock Rack romed8hm3, fru-device successfully recognizes
and parses the baseboard FRU EEPROM as it did prior to this patch.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I0d774508bc29dbda346309fe7fe42dbdf97bee43
diff --git a/include/fru_utils.hpp b/include/fru_utils.hpp
index c072ae5..ebb2b19 100644
--- a/include/fru_utils.hpp
+++ b/include/fru_utils.hpp
@@ -16,6 +16,7 @@
 /// \file fru_utils.hpp
 
 #pragma once
+#include "fru_reader.hpp"
 #include <boost/container/flat_map.hpp>
 
 #include <cstdint>
@@ -83,10 +84,6 @@
                                      1);
 }
 
-using ReadBlockFunc =
-    std::function<ssize_t(int flag, int file, uint16_t address, off_t offset,
-                          size_t length, uint8_t* outBuf)>;
-
 inline const std::string& getFruAreaName(fruAreas area)
 {
     return fruAreaNames[static_cast<unsigned int>(area)];
@@ -132,30 +129,22 @@
 ssize_t getFieldLength(uint8_t fruFieldTypeLenValue);
 
 /// \brief Find a FRU header.
-/// \param flag the flag required for raw i2c
-/// \param file the open file handle
-/// \param address the i2c device address
-/// \param readBlock a read method
+/// \param reader the FRUReader to read via
 /// \param errorHelp and a helper string for failures
 /// \param blockData buffer to return the last read block
 /// \param baseOffset the offset to start the search at;
 ///        set to 0 to perform search;
 ///        returns the offset at which a header was found
 /// \return whether a header was found
-bool findFRUHeader(int flag, int file, uint16_t address,
-                   const ReadBlockFunc& readBlock, const std::string& errorHelp,
+bool findFRUHeader(FRUReader& reader, const std::string& errorHelp,
                    std::array<uint8_t, I2C_SMBUS_BLOCK_MAX>& blockData,
                    off_t& baseOffset);
 
 /// \brief Read and validate FRU contents.
-/// \param flag the flag required for raw i2c
-/// \param file the open file handle
-/// \param address the i2c device address
-/// \param readBlock a read method
+/// \param reader the FRUReader to read via
 /// \param errorHelp and a helper string for failures
 /// \return the FRU contents from the file
-std::vector<uint8_t> readFRUContents(int flag, int file, uint16_t address,
-                                     const ReadBlockFunc& readBlock,
+std::vector<uint8_t> readFRUContents(FRUReader& reader,
                                      const std::string& errorHelp);
 
 /// \brief Validate an IPMI FRU common header