blob: 26052943fcc5e69a1e77f924f76dad9bc119f537 [file] [log] [blame]
vishwac93d6d42015-12-16 11:55:16 -06001#ifndef __IPMI_FRU_AREA_H__
2#define __IPMI_FRU_AREA_H__
3
Ratan Gupta19c617b2017-02-10 15:39:40 +05304#include "frup.hpp"
Matthew Barth155c34f2016-10-18 14:33:17 -05005#include "writefrudata.hpp"
vishwac93d6d42015-12-16 11:55:16 -06006
Patrick Ventureb4c333f2018-10-20 20:16:39 -07007#include <cstdint>
Patrick Venturec9508db2018-10-16 17:18:43 -07008#include <memory>
9#include <string>
10#include <vector>
11
Patrick Ventureb4c333f2018-10-20 20:16:39 -070012using std::uint8_t;
13
Patrick Venture9eb82cf2018-10-20 19:36:01 -070014class IPMIFruArea
vishwac93d6d42015-12-16 11:55:16 -060015{
Patrick Venturec9508db2018-10-16 17:18:43 -070016 public:
Patrick Ventureac988992018-10-21 08:37:18 -070017 IPMIFruArea() = delete;
18
Patrick Venturec9508db2018-10-16 17:18:43 -070019 // constructor
Patrick Venture9eb82cf2018-10-20 19:36:01 -070020 IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type,
21 bool bmc_fru = false);
vishwac93d6d42015-12-16 11:55:16 -060022
Patrick Venturec9508db2018-10-16 17:18:43 -070023 // Destructor
Patrick Venture9eb82cf2018-10-20 19:36:01 -070024 virtual ~IPMIFruArea();
vishwac93d6d42015-12-16 11:55:16 -060025
Patrick Venturec9508db2018-10-16 17:18:43 -070026 // Sets the present bit
Patrick Venturef22b36a2018-10-20 20:59:07 -070027 inline void setPresent(const bool present)
Patrick Venturec9508db2018-10-16 17:18:43 -070028 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070029 isPresent = present;
Patrick Venturec9508db2018-10-16 17:18:43 -070030 }
vishwac93d6d42015-12-16 11:55:16 -060031
Patrick Venturec9508db2018-10-16 17:18:43 -070032 // returns fru id;
Patrick Venturef22b36a2018-10-20 20:59:07 -070033 uint8_t getFruID() const
Patrick Venturec9508db2018-10-16 17:18:43 -070034 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070035 return fruid;
Patrick Venturec9508db2018-10-16 17:18:43 -070036 }
vishwac93d6d42015-12-16 11:55:16 -060037
Patrick Venturec9508db2018-10-16 17:18:43 -070038 // Returns the length.
Patrick Venturef22b36a2018-10-20 20:59:07 -070039 size_t getLength() const
Patrick Venturec9508db2018-10-16 17:18:43 -070040 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070041 return len;
Patrick Venturec9508db2018-10-16 17:18:43 -070042 }
vishwac93d6d42015-12-16 11:55:16 -060043
Patrick Venturec9508db2018-10-16 17:18:43 -070044 // Returns the type of the current fru area
Patrick Venturef22b36a2018-10-20 20:59:07 -070045 ipmi_fru_area_type getType() const
Patrick Venturec9508db2018-10-16 17:18:43 -070046 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070047 return type;
Patrick Venturec9508db2018-10-16 17:18:43 -070048 }
vishwac93d6d42015-12-16 11:55:16 -060049
Patrick Venturec9508db2018-10-16 17:18:43 -070050 // Returns the name
Patrick Venturef22b36a2018-10-20 20:59:07 -070051 const char* getName() const
Patrick Venturec9508db2018-10-16 17:18:43 -070052 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070053 return name.c_str();
Patrick Venturec9508db2018-10-16 17:18:43 -070054 }
vishwac93d6d42015-12-16 11:55:16 -060055
Patrick Venturec9508db2018-10-16 17:18:43 -070056 // Returns SD bus name
Patrick Venturef22b36a2018-10-20 20:59:07 -070057 const char* getBusName() const
Patrick Venturec9508db2018-10-16 17:18:43 -070058 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070059 return bus_name.c_str();
Patrick Venturec9508db2018-10-16 17:18:43 -070060 }
vishwac93d6d42015-12-16 11:55:16 -060061
Patrick Venturec9508db2018-10-16 17:18:43 -070062 // Retrns SD bus object path
Patrick Venturef22b36a2018-10-20 20:59:07 -070063 const char* getObjectPath() const
Patrick Venturec9508db2018-10-16 17:18:43 -070064 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070065 return obj_path.c_str();
Patrick Venturec9508db2018-10-16 17:18:43 -070066 }
vishwac93d6d42015-12-16 11:55:16 -060067
Patrick Venturec9508db2018-10-16 17:18:43 -070068 // Returns SD bus interface name
Patrick Venturef22b36a2018-10-20 20:59:07 -070069 const char* getInterfaceName() const
Patrick Venturec9508db2018-10-16 17:18:43 -070070 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070071 return intf_name.c_str();
Patrick Venturec9508db2018-10-16 17:18:43 -070072 }
vishwac93d6d42015-12-16 11:55:16 -060073
Patrick Venturec9508db2018-10-16 17:18:43 -070074 // Returns the data portion
Patrick Venturef22b36a2018-10-20 20:59:07 -070075 inline uint8_t* getData() const
Patrick Venturec9508db2018-10-16 17:18:43 -070076 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070077 return data;
Patrick Venturec9508db2018-10-16 17:18:43 -070078 }
vishwac93d6d42015-12-16 11:55:16 -060079
Patrick Venturec9508db2018-10-16 17:18:43 -070080 // Accepts a pointer to data and sets it in the object.
Patrick Venturef22b36a2018-10-20 20:59:07 -070081 void setData(const uint8_t*, const size_t);
vishwac93d6d42015-12-16 11:55:16 -060082
Patrick Venturec9508db2018-10-16 17:18:43 -070083 // Sets the dbus parameters
Patrick Venturef22b36a2018-10-20 20:59:07 -070084 void updateDbusPaths(const char*, const char*, const char*);
Patrick Venture524ba9c2018-10-20 20:52:27 -070085
86 private:
87 // Unique way of identifying a FRU
88 uint8_t fruid = 0;
89
90 // Type of the fru matching offsets in common header
91 ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE;
92
93 // Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
94 std::string name;
95
96 // Length of a specific fru area.
97 size_t len = 0;
98
99 // Special bit for BMC readable eeprom only.
100 bool bmc_fru = false;
101
102 // If a FRU is physically present.
103 bool isPresent = false;
104
105 // Whether a particular area is valid ?
106 bool isValid = false;
107
108 // Actual area data.
109 uint8_t* data = nullptr;
110
111 // fru inventory dbus name
112 std::string bus_name;
113
114 // fru inventory dbus object path
115 std::string obj_path;
116
117 // fru inventory dbus interface name
118 std::string intf_name;
vishwac93d6d42015-12-16 11:55:16 -0600119};
120
121#endif