xref: /openbmc/ipmi-fru-parser/fru_area.hpp (revision b4c333f9)
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 
7*b4c333f9SPatrick Venture #include <cstdint>
85c2bd5edSPatrick Venture #include <memory>
95c2bd5edSPatrick Venture #include <string>
105c2bd5edSPatrick Venture #include <vector>
115c2bd5edSPatrick Venture 
12*b4c333f9SPatrick Venture using std::uint8_t;
13*b4c333f9SPatrick Venture 
145c2bd5edSPatrick Venture class IPMIFruArea
155c2bd5edSPatrick Venture {
165c2bd5edSPatrick Venture   private:
175c2bd5edSPatrick Venture     // Unique way of identifying a FRU
185c2bd5edSPatrick Venture     uint8_t iv_fruid = 0;
195c2bd5edSPatrick Venture 
205c2bd5edSPatrick Venture     // Type of the fru matching offsets in common header
215c2bd5edSPatrick Venture     ipmi_fru_area_type iv_type = IPMI_FRU_AREA_INTERNAL_USE;
225c2bd5edSPatrick Venture 
235c2bd5edSPatrick Venture     // Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
245c2bd5edSPatrick Venture     std::string iv_name;
255c2bd5edSPatrick Venture 
265c2bd5edSPatrick Venture     // Length of a specific fru area.
275c2bd5edSPatrick Venture     size_t iv_len = 0;
285c2bd5edSPatrick Venture 
295c2bd5edSPatrick Venture     // Special bit for BMC readable eeprom only.
305c2bd5edSPatrick Venture     bool iv_bmc_fru = false;
315c2bd5edSPatrick Venture 
325c2bd5edSPatrick Venture     // If a FRU is physically present.
335c2bd5edSPatrick Venture     bool iv_present = false;
345c2bd5edSPatrick Venture 
355c2bd5edSPatrick Venture     // Whether a particular area is valid ?
365c2bd5edSPatrick Venture     bool iv_valid = false;
375c2bd5edSPatrick Venture 
385c2bd5edSPatrick Venture     // Actual area data.
395c2bd5edSPatrick Venture     uint8_t* iv_data = nullptr;
405c2bd5edSPatrick Venture 
415c2bd5edSPatrick Venture     // fru inventory dbus name
425c2bd5edSPatrick Venture     std::string iv_bus_name;
435c2bd5edSPatrick Venture 
445c2bd5edSPatrick Venture     // fru inventory dbus object path
455c2bd5edSPatrick Venture     std::string iv_obj_path;
465c2bd5edSPatrick Venture 
475c2bd5edSPatrick Venture     // fru inventory dbus interface name
485c2bd5edSPatrick Venture     std::string iv_intf_name;
495c2bd5edSPatrick Venture 
505c2bd5edSPatrick Venture     // Default constructor disabled.
515c2bd5edSPatrick Venture     IPMIFruArea();
525c2bd5edSPatrick Venture 
535c2bd5edSPatrick Venture   public:
545c2bd5edSPatrick Venture     // constructor
555c2bd5edSPatrick Venture     IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type,
565c2bd5edSPatrick Venture                 bool bmc_fru = false);
575c2bd5edSPatrick Venture 
585c2bd5edSPatrick Venture     // Destructor
595c2bd5edSPatrick Venture     virtual ~IPMIFruArea();
605c2bd5edSPatrick Venture 
615c2bd5edSPatrick Venture     // If a particular area has been marked valid / invalid
625c2bd5edSPatrick Venture     inline bool is_valid() const
635c2bd5edSPatrick Venture     {
645c2bd5edSPatrick Venture         return iv_valid;
655c2bd5edSPatrick Venture     }
665c2bd5edSPatrick Venture 
675c2bd5edSPatrick Venture     // Sets the present bit
685c2bd5edSPatrick Venture     inline void set_present(const bool present)
695c2bd5edSPatrick Venture     {
705c2bd5edSPatrick Venture         iv_present = present;
715c2bd5edSPatrick Venture     }
725c2bd5edSPatrick Venture 
735c2bd5edSPatrick Venture     // Sets the valid bit for a corresponding area.
745c2bd5edSPatrick Venture     inline void set_valid(const bool valid)
755c2bd5edSPatrick Venture     {
765c2bd5edSPatrick Venture         iv_valid = valid;
775c2bd5edSPatrick Venture     }
785c2bd5edSPatrick Venture 
795c2bd5edSPatrick Venture     // If a particular area accessible only by BMC
805c2bd5edSPatrick Venture     inline bool is_bmc_fru() const
815c2bd5edSPatrick Venture     {
825c2bd5edSPatrick Venture         return iv_bmc_fru;
835c2bd5edSPatrick Venture     }
845c2bd5edSPatrick Venture 
855c2bd5edSPatrick Venture     // returns fru id;
865c2bd5edSPatrick Venture     uint8_t get_fruid() const
875c2bd5edSPatrick Venture     {
885c2bd5edSPatrick Venture         return iv_fruid;
895c2bd5edSPatrick Venture     }
905c2bd5edSPatrick Venture 
915c2bd5edSPatrick Venture     // Returns the length.
925c2bd5edSPatrick Venture     size_t get_len() const
935c2bd5edSPatrick Venture     {
945c2bd5edSPatrick Venture         return iv_len;
955c2bd5edSPatrick Venture     }
965c2bd5edSPatrick Venture 
975c2bd5edSPatrick Venture     // Returns the type of the current fru area
985c2bd5edSPatrick Venture     ipmi_fru_area_type get_type() const
995c2bd5edSPatrick Venture     {
1005c2bd5edSPatrick Venture         return iv_type;
1015c2bd5edSPatrick Venture     }
1025c2bd5edSPatrick Venture 
1035c2bd5edSPatrick Venture     // Returns the name
1045c2bd5edSPatrick Venture     const char* get_name() const
1055c2bd5edSPatrick Venture     {
1065c2bd5edSPatrick Venture         return iv_name.c_str();
1075c2bd5edSPatrick Venture     }
1085c2bd5edSPatrick Venture 
1095c2bd5edSPatrick Venture     // Returns SD bus name
1105c2bd5edSPatrick Venture     const char* get_bus_name() const
1115c2bd5edSPatrick Venture     {
1125c2bd5edSPatrick Venture         return iv_bus_name.c_str();
1135c2bd5edSPatrick Venture     }
1145c2bd5edSPatrick Venture 
1155c2bd5edSPatrick Venture     // Retrns SD bus object path
1165c2bd5edSPatrick Venture     const char* get_obj_path() const
1175c2bd5edSPatrick Venture     {
1185c2bd5edSPatrick Venture         return iv_obj_path.c_str();
1195c2bd5edSPatrick Venture     }
1205c2bd5edSPatrick Venture 
1215c2bd5edSPatrick Venture     // Returns SD bus interface name
1225c2bd5edSPatrick Venture     const char* get_intf_name() const
1235c2bd5edSPatrick Venture     {
1245c2bd5edSPatrick Venture         return iv_intf_name.c_str();
1255c2bd5edSPatrick Venture     }
1265c2bd5edSPatrick Venture 
1275c2bd5edSPatrick Venture     // Returns the data portion
1285c2bd5edSPatrick Venture     inline uint8_t* get_data() const
1295c2bd5edSPatrick Venture     {
1305c2bd5edSPatrick Venture         return iv_data;
1315c2bd5edSPatrick Venture     }
1325c2bd5edSPatrick Venture 
1335c2bd5edSPatrick Venture     // Accepts a pointer to data and sets it in the object.
1345c2bd5edSPatrick Venture     void set_data(const uint8_t*, const size_t);
1355c2bd5edSPatrick Venture 
1365c2bd5edSPatrick Venture     // Sets the dbus parameters
1375c2bd5edSPatrick Venture     void update_dbus_paths(const char*, const char*, const char*);
1385c2bd5edSPatrick Venture };
1395c2bd5edSPatrick Venture 
1405c2bd5edSPatrick Venture #endif
141