15c2bd5edSPatrick Venture #ifndef __IPMI_FRU_AREA_H__ 25c2bd5edSPatrick Venture #define __IPMI_FRU_AREA_H__ 35c2bd5edSPatrick Venture 45c2bd5edSPatrick Venture #include "frup.hpp" 55c2bd5edSPatrick Venture #include "writefrudata.hpp" 65c2bd5edSPatrick Venture 7b4c333f9SPatrick Venture #include <cstdint> 85c2bd5edSPatrick Venture #include <memory> 95c2bd5edSPatrick Venture #include <string> 105c2bd5edSPatrick Venture #include <vector> 115c2bd5edSPatrick Venture 12b4c333f9SPatrick Venture using std::uint8_t; 13b4c333f9SPatrick Venture 14*1816ff30SPatrick Venture /** 15*1816ff30SPatrick Venture * IPMIFruArea represents a piece of a FRU that is accessible over IPMI. 16*1816ff30SPatrick Venture */ 175c2bd5edSPatrick Venture class IPMIFruArea 185c2bd5edSPatrick Venture { 195c2bd5edSPatrick Venture public: 20ac988990SPatrick Venture IPMIFruArea() = delete; 211d00178aSPatrick Venture ~IPMIFruArea() = default; 22ac988990SPatrick Venture 23*1816ff30SPatrick Venture /** 24*1816ff30SPatrick Venture * Construct an IPMIFruArea. 25*1816ff30SPatrick Venture * 26*1816ff30SPatrick Venture * @param[in] fruID - FRU identifier value 27*1816ff30SPatrick Venture * @param[in] type - the type of FRU area. 28*1816ff30SPatrick Venture * @param[in] bmcOnlyFru - Is this FRU only accessible via the BMC 29*1816ff30SPatrick Venture */ 309f65a08fSPatrick Venture IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type, 319f65a08fSPatrick Venture bool bmcOnlyFru = false); 325c2bd5edSPatrick Venture 33*1816ff30SPatrick Venture /** 34*1816ff30SPatrick Venture * Set whether the FRU is present. 35*1816ff30SPatrick Venture * 36*1816ff30SPatrick Venture * @param[in] present - True if present. 37*1816ff30SPatrick Venture */ setPresent(const bool present)38f22b36a0SPatrick Venture inline void setPresent(const bool present) 395c2bd5edSPatrick Venture { 40b9d33736SPatrick Venture isPresent = present; 415c2bd5edSPatrick Venture } 425c2bd5edSPatrick Venture 43*1816ff30SPatrick Venture /** 44*1816ff30SPatrick Venture * Retrieves the FRU's ID. 45*1816ff30SPatrick Venture * 46*1816ff30SPatrick Venture * @return the FRU ID. 47*1816ff30SPatrick Venture */ getFruID() const48f22b36a0SPatrick Venture uint8_t getFruID() const 495c2bd5edSPatrick Venture { 509f65a08fSPatrick Venture return fruID; 515c2bd5edSPatrick Venture } 525c2bd5edSPatrick Venture 53*1816ff30SPatrick Venture /** 54*1816ff30SPatrick Venture * Returns the length of the FRU data. 55*1816ff30SPatrick Venture * 56*1816ff30SPatrick Venture * @return the number of bytes. 57*1816ff30SPatrick Venture */ getLength() const58f22b36a0SPatrick Venture size_t getLength() const 595c2bd5edSPatrick Venture { 60f0f1ab9fSPatrick Venture return data.size(); 615c2bd5edSPatrick Venture } 625c2bd5edSPatrick Venture 63*1816ff30SPatrick Venture /** 64*1816ff30SPatrick Venture * Returns the type of the current FRU area. 65*1816ff30SPatrick Venture * 66*1816ff30SPatrick Venture * @return the type of FRU area 67*1816ff30SPatrick Venture */ getType() const68f22b36a0SPatrick Venture ipmi_fru_area_type getType() const 695c2bd5edSPatrick Venture { 70b9d33736SPatrick Venture return type; 715c2bd5edSPatrick Venture } 725c2bd5edSPatrick Venture 73*1816ff30SPatrick Venture /** 74*1816ff30SPatrick Venture * Returns the FRU area name. 75*1816ff30SPatrick Venture * 76*1816ff30SPatrick Venture * @return the FRU area name 77*1816ff30SPatrick Venture */ getName() const78f22b36a0SPatrick Venture const char* getName() const 795c2bd5edSPatrick Venture { 80b9d33736SPatrick Venture return name.c_str(); 815c2bd5edSPatrick Venture } 825c2bd5edSPatrick Venture 83*1816ff30SPatrick Venture /** 84*1816ff30SPatrick Venture * Returns the data portion. 85*1816ff30SPatrick Venture * 86*1816ff30SPatrick Venture * @return pointer to data 87*1816ff30SPatrick Venture */ getData() const88f0f1ab9fSPatrick Venture inline const uint8_t* getData() const 895c2bd5edSPatrick Venture { 90f0f1ab9fSPatrick Venture return data.data(); 915c2bd5edSPatrick Venture } 925c2bd5edSPatrick Venture 93*1816ff30SPatrick Venture /** 94*1816ff30SPatrick Venture * Accepts a pointer to data and sets it in the object. 95*1816ff30SPatrick Venture * 96*1816ff30SPatrick Venture * @param[in] value - The data to copy into the FRU area 97*1816ff30SPatrick Venture * @param[in] length - the number of bytes value points to 98*1816ff30SPatrick Venture */ 99*1816ff30SPatrick Venture void setData(const uint8_t* value, const size_t length); 1005c2bd5edSPatrick Venture 101524ba9c1SPatrick Venture private: 102524ba9c1SPatrick Venture // Unique way of identifying a FRU 1039f65a08fSPatrick Venture uint8_t fruID = 0; 104524ba9c1SPatrick Venture 105*1816ff30SPatrick Venture // Type of the FRU matching offsets in common header 106524ba9c1SPatrick Venture ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE; 107524ba9c1SPatrick Venture 108*1816ff30SPatrick Venture // Name of the FRU area. ( BOARD/CHASSIS/PRODUCT ) 109524ba9c1SPatrick Venture std::string name; 110524ba9c1SPatrick Venture 111524ba9c1SPatrick Venture // Special bit for BMC readable eeprom only. 1129f65a08fSPatrick Venture bool bmcOnlyFru = false; 113524ba9c1SPatrick Venture 114524ba9c1SPatrick Venture // If a FRU is physically present. 115524ba9c1SPatrick Venture bool isPresent = false; 116524ba9c1SPatrick Venture 117524ba9c1SPatrick Venture // Whether a particular area is valid ? 118524ba9c1SPatrick Venture bool isValid = false; 119524ba9c1SPatrick Venture 120524ba9c1SPatrick Venture // Actual area data. 121f0f1ab9fSPatrick Venture std::vector<uint8_t> data; 1225c2bd5edSPatrick Venture }; 1235c2bd5edSPatrick Venture 1245c2bd5edSPatrick Venture #endif 125