FruUtils: Add support for finding FRU at an offset
This change adds findFRUHeader which can detect non-IPMI headers to
identify the offset for IPMI FRU data. An implementation for "$TYAN$"
has been added. The new findFRUHeader is now used by readFRUContents
to generically read IPMI FRU both at offset 0 and at a offset as
determined by findFRUHeader.
Signed-off-by: Oskar Senft <osk@google.com>
Change-Id: I4325aac7737db59aaa11359ad7a0d575957f16e7
diff --git a/include/FruUtils.hpp b/include/FruUtils.hpp
index 74f80e4..906b77e 100644
--- a/include/FruUtils.hpp
+++ b/include/FruUtils.hpp
@@ -126,6 +126,23 @@
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 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,
+ std::array<uint8_t, I2C_SMBUS_BLOCK_MAX>& blockData,
+ uint16_t& baseOffset);
+
/// \brief Read and validate FRU contents.
/// \param flag the flag required for raw i2c
/// \param file the open file handle