xref: /openbmc/ipmi-fru-parser/fru_area.hpp (revision 524ba9c1)
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 
145c2bd5edSPatrick Venture class IPMIFruArea
155c2bd5edSPatrick Venture {
165c2bd5edSPatrick Venture   public:
175c2bd5edSPatrick Venture     // constructor
185c2bd5edSPatrick Venture     IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type,
195c2bd5edSPatrick Venture                 bool bmc_fru = false);
205c2bd5edSPatrick Venture 
215c2bd5edSPatrick Venture     // Destructor
225c2bd5edSPatrick Venture     virtual ~IPMIFruArea();
235c2bd5edSPatrick Venture 
245c2bd5edSPatrick Venture     // Sets the present bit
255c2bd5edSPatrick Venture     inline void set_present(const bool present)
265c2bd5edSPatrick Venture     {
27b9d33736SPatrick Venture         isPresent = present;
285c2bd5edSPatrick Venture     }
295c2bd5edSPatrick Venture 
305c2bd5edSPatrick Venture     // returns fru id;
315c2bd5edSPatrick Venture     uint8_t get_fruid() const
325c2bd5edSPatrick Venture     {
33b9d33736SPatrick Venture         return fruid;
345c2bd5edSPatrick Venture     }
355c2bd5edSPatrick Venture 
365c2bd5edSPatrick Venture     // Returns the length.
375c2bd5edSPatrick Venture     size_t get_len() const
385c2bd5edSPatrick Venture     {
39b9d33736SPatrick Venture         return len;
405c2bd5edSPatrick Venture     }
415c2bd5edSPatrick Venture 
425c2bd5edSPatrick Venture     // Returns the type of the current fru area
435c2bd5edSPatrick Venture     ipmi_fru_area_type get_type() const
445c2bd5edSPatrick Venture     {
45b9d33736SPatrick Venture         return type;
465c2bd5edSPatrick Venture     }
475c2bd5edSPatrick Venture 
485c2bd5edSPatrick Venture     // Returns the name
495c2bd5edSPatrick Venture     const char* get_name() const
505c2bd5edSPatrick Venture     {
51b9d33736SPatrick Venture         return name.c_str();
525c2bd5edSPatrick Venture     }
535c2bd5edSPatrick Venture 
545c2bd5edSPatrick Venture     // Returns SD bus name
555c2bd5edSPatrick Venture     const char* get_bus_name() const
565c2bd5edSPatrick Venture     {
57b9d33736SPatrick Venture         return bus_name.c_str();
585c2bd5edSPatrick Venture     }
595c2bd5edSPatrick Venture 
605c2bd5edSPatrick Venture     // Retrns SD bus object path
615c2bd5edSPatrick Venture     const char* get_obj_path() const
625c2bd5edSPatrick Venture     {
63b9d33736SPatrick Venture         return obj_path.c_str();
645c2bd5edSPatrick Venture     }
655c2bd5edSPatrick Venture 
665c2bd5edSPatrick Venture     // Returns SD bus interface name
675c2bd5edSPatrick Venture     const char* get_intf_name() const
685c2bd5edSPatrick Venture     {
69b9d33736SPatrick Venture         return intf_name.c_str();
705c2bd5edSPatrick Venture     }
715c2bd5edSPatrick Venture 
725c2bd5edSPatrick Venture     // Returns the data portion
735c2bd5edSPatrick Venture     inline uint8_t* get_data() const
745c2bd5edSPatrick Venture     {
75b9d33736SPatrick Venture         return data;
765c2bd5edSPatrick Venture     }
775c2bd5edSPatrick Venture 
785c2bd5edSPatrick Venture     // Accepts a pointer to data and sets it in the object.
795c2bd5edSPatrick Venture     void set_data(const uint8_t*, const size_t);
805c2bd5edSPatrick Venture 
815c2bd5edSPatrick Venture     // Sets the dbus parameters
825c2bd5edSPatrick Venture     void update_dbus_paths(const char*, const char*, const char*);
83*524ba9c1SPatrick Venture 
84*524ba9c1SPatrick Venture   private:
85*524ba9c1SPatrick Venture     // Unique way of identifying a FRU
86*524ba9c1SPatrick Venture     uint8_t fruid = 0;
87*524ba9c1SPatrick Venture 
88*524ba9c1SPatrick Venture     // Type of the fru matching offsets in common header
89*524ba9c1SPatrick Venture     ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE;
90*524ba9c1SPatrick Venture 
91*524ba9c1SPatrick Venture     // Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
92*524ba9c1SPatrick Venture     std::string name;
93*524ba9c1SPatrick Venture 
94*524ba9c1SPatrick Venture     // Length of a specific fru area.
95*524ba9c1SPatrick Venture     size_t len = 0;
96*524ba9c1SPatrick Venture 
97*524ba9c1SPatrick Venture     // Special bit for BMC readable eeprom only.
98*524ba9c1SPatrick Venture     bool bmc_fru = false;
99*524ba9c1SPatrick Venture 
100*524ba9c1SPatrick Venture     // If a FRU is physically present.
101*524ba9c1SPatrick Venture     bool isPresent = false;
102*524ba9c1SPatrick Venture 
103*524ba9c1SPatrick Venture     // Whether a particular area is valid ?
104*524ba9c1SPatrick Venture     bool isValid = false;
105*524ba9c1SPatrick Venture 
106*524ba9c1SPatrick Venture     // Actual area data.
107*524ba9c1SPatrick Venture     uint8_t* data = nullptr;
108*524ba9c1SPatrick Venture 
109*524ba9c1SPatrick Venture     // fru inventory dbus name
110*524ba9c1SPatrick Venture     std::string bus_name;
111*524ba9c1SPatrick Venture 
112*524ba9c1SPatrick Venture     // fru inventory dbus object path
113*524ba9c1SPatrick Venture     std::string obj_path;
114*524ba9c1SPatrick Venture 
115*524ba9c1SPatrick Venture     // fru inventory dbus interface name
116*524ba9c1SPatrick Venture     std::string intf_name;
117*524ba9c1SPatrick Venture 
118*524ba9c1SPatrick Venture     // Default constructor disabled.
119*524ba9c1SPatrick Venture     IPMIFruArea();
1205c2bd5edSPatrick Venture };
1215c2bd5edSPatrick Venture 
1225c2bd5edSPatrick Venture #endif
123