xref: /openbmc/ipmi-fru-parser/fru_area.hpp (revision 9f65a08f)
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:
17ac988990SPatrick Venture     IPMIFruArea() = delete;
18ac988990SPatrick Venture 
195c2bd5edSPatrick Venture     // constructor
20*9f65a08fSPatrick Venture     IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type,
21*9f65a08fSPatrick Venture                 bool bmcOnlyFru = false);
225c2bd5edSPatrick Venture 
235c2bd5edSPatrick Venture     // Destructor
245c2bd5edSPatrick Venture     virtual ~IPMIFruArea();
255c2bd5edSPatrick Venture 
265c2bd5edSPatrick Venture     // Sets the present bit
27f22b36a0SPatrick Venture     inline void setPresent(const bool present)
285c2bd5edSPatrick Venture     {
29b9d33736SPatrick Venture         isPresent = present;
305c2bd5edSPatrick Venture     }
315c2bd5edSPatrick Venture 
325c2bd5edSPatrick Venture     // returns fru id;
33f22b36a0SPatrick Venture     uint8_t getFruID() const
345c2bd5edSPatrick Venture     {
35*9f65a08fSPatrick Venture         return fruID;
365c2bd5edSPatrick Venture     }
375c2bd5edSPatrick Venture 
385c2bd5edSPatrick Venture     // Returns the length.
39f22b36a0SPatrick Venture     size_t getLength() const
405c2bd5edSPatrick Venture     {
41b9d33736SPatrick Venture         return len;
425c2bd5edSPatrick Venture     }
435c2bd5edSPatrick Venture 
445c2bd5edSPatrick Venture     // Returns the type of the current fru area
45f22b36a0SPatrick Venture     ipmi_fru_area_type getType() const
465c2bd5edSPatrick Venture     {
47b9d33736SPatrick Venture         return type;
485c2bd5edSPatrick Venture     }
495c2bd5edSPatrick Venture 
505c2bd5edSPatrick Venture     // Returns the name
51f22b36a0SPatrick Venture     const char* getName() const
525c2bd5edSPatrick Venture     {
53b9d33736SPatrick Venture         return name.c_str();
545c2bd5edSPatrick Venture     }
555c2bd5edSPatrick Venture 
565c2bd5edSPatrick Venture     // Returns SD bus name
57f22b36a0SPatrick Venture     const char* getBusName() const
585c2bd5edSPatrick Venture     {
59*9f65a08fSPatrick Venture         return busName.c_str();
605c2bd5edSPatrick Venture     }
615c2bd5edSPatrick Venture 
625c2bd5edSPatrick Venture     // Retrns SD bus object path
63f22b36a0SPatrick Venture     const char* getObjectPath() const
645c2bd5edSPatrick Venture     {
65*9f65a08fSPatrick Venture         return objectPath.c_str();
665c2bd5edSPatrick Venture     }
675c2bd5edSPatrick Venture 
685c2bd5edSPatrick Venture     // Returns SD bus interface name
69f22b36a0SPatrick Venture     const char* getInterfaceName() const
705c2bd5edSPatrick Venture     {
71*9f65a08fSPatrick Venture         return interfaceName.c_str();
725c2bd5edSPatrick Venture     }
735c2bd5edSPatrick Venture 
745c2bd5edSPatrick Venture     // Returns the data portion
75f22b36a0SPatrick Venture     inline uint8_t* getData() const
765c2bd5edSPatrick Venture     {
77b9d33736SPatrick Venture         return data;
785c2bd5edSPatrick Venture     }
795c2bd5edSPatrick Venture 
805c2bd5edSPatrick Venture     // Accepts a pointer to data and sets it in the object.
81f22b36a0SPatrick Venture     void setData(const uint8_t*, const size_t);
825c2bd5edSPatrick Venture 
835c2bd5edSPatrick Venture     // Sets the dbus parameters
84f22b36a0SPatrick Venture     void updateDbusPaths(const char*, const char*, const char*);
85524ba9c1SPatrick Venture 
86524ba9c1SPatrick Venture   private:
87524ba9c1SPatrick Venture     // Unique way of identifying a FRU
88*9f65a08fSPatrick Venture     uint8_t fruID = 0;
89524ba9c1SPatrick Venture 
90524ba9c1SPatrick Venture     // Type of the fru matching offsets in common header
91524ba9c1SPatrick Venture     ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE;
92524ba9c1SPatrick Venture 
93524ba9c1SPatrick Venture     // Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
94524ba9c1SPatrick Venture     std::string name;
95524ba9c1SPatrick Venture 
96524ba9c1SPatrick Venture     // Length of a specific fru area.
97524ba9c1SPatrick Venture     size_t len = 0;
98524ba9c1SPatrick Venture 
99524ba9c1SPatrick Venture     // Special bit for BMC readable eeprom only.
100*9f65a08fSPatrick Venture     bool bmcOnlyFru = false;
101524ba9c1SPatrick Venture 
102524ba9c1SPatrick Venture     // If a FRU is physically present.
103524ba9c1SPatrick Venture     bool isPresent = false;
104524ba9c1SPatrick Venture 
105524ba9c1SPatrick Venture     // Whether a particular area is valid ?
106524ba9c1SPatrick Venture     bool isValid = false;
107524ba9c1SPatrick Venture 
108524ba9c1SPatrick Venture     // Actual area data.
109524ba9c1SPatrick Venture     uint8_t* data = nullptr;
110524ba9c1SPatrick Venture 
111524ba9c1SPatrick Venture     // fru inventory dbus name
112*9f65a08fSPatrick Venture     std::string busName;
113524ba9c1SPatrick Venture 
114524ba9c1SPatrick Venture     // fru inventory dbus object path
115*9f65a08fSPatrick Venture     std::string objectPath;
116524ba9c1SPatrick Venture 
117524ba9c1SPatrick Venture     // fru inventory dbus interface name
118*9f65a08fSPatrick Venture     std::string interfaceName;
1195c2bd5edSPatrick Venture };
1205c2bd5edSPatrick Venture 
1215c2bd5edSPatrick Venture #endif
122