blob: b725ddf462f7b7fd6e797d1b2bfc4704be51bce1 [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 private:
17 // Unique way of identifying a FRU
18 uint8_t iv_fruid = 0;
vishwac93d6d42015-12-16 11:55:16 -060019
Patrick Venturec9508db2018-10-16 17:18:43 -070020 // Type of the fru matching offsets in common header
21 ipmi_fru_area_type iv_type = IPMI_FRU_AREA_INTERNAL_USE;
vishwac93d6d42015-12-16 11:55:16 -060022
Patrick Venturec9508db2018-10-16 17:18:43 -070023 // Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
24 std::string iv_name;
vishwac93d6d42015-12-16 11:55:16 -060025
Patrick Venturec9508db2018-10-16 17:18:43 -070026 // Length of a specific fru area.
27 size_t iv_len = 0;
vishwac93d6d42015-12-16 11:55:16 -060028
Patrick Venturec9508db2018-10-16 17:18:43 -070029 // Special bit for BMC readable eeprom only.
30 bool iv_bmc_fru = false;
vishwac93d6d42015-12-16 11:55:16 -060031
Patrick Venturec9508db2018-10-16 17:18:43 -070032 // If a FRU is physically present.
33 bool iv_present = false;
vishwac93d6d42015-12-16 11:55:16 -060034
Patrick Venturec9508db2018-10-16 17:18:43 -070035 // Whether a particular area is valid ?
36 bool iv_valid = false;
vishwac93d6d42015-12-16 11:55:16 -060037
Patrick Venturec9508db2018-10-16 17:18:43 -070038 // Actual area data.
39 uint8_t* iv_data = nullptr;
vishwac93d6d42015-12-16 11:55:16 -060040
Patrick Venturec9508db2018-10-16 17:18:43 -070041 // fru inventory dbus name
42 std::string iv_bus_name;
vishwac93d6d42015-12-16 11:55:16 -060043
Patrick Venturec9508db2018-10-16 17:18:43 -070044 // fru inventory dbus object path
45 std::string iv_obj_path;
vishwac93d6d42015-12-16 11:55:16 -060046
Patrick Venturec9508db2018-10-16 17:18:43 -070047 // fru inventory dbus interface name
48 std::string iv_intf_name;
vishwac93d6d42015-12-16 11:55:16 -060049
Patrick Venturec9508db2018-10-16 17:18:43 -070050 // Default constructor disabled.
Patrick Venture9eb82cf2018-10-20 19:36:01 -070051 IPMIFruArea();
vishwac93d6d42015-12-16 11:55:16 -060052
Patrick Venturec9508db2018-10-16 17:18:43 -070053 public:
54 // constructor
Patrick Venture9eb82cf2018-10-20 19:36:01 -070055 IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type,
56 bool bmc_fru = false);
vishwac93d6d42015-12-16 11:55:16 -060057
Patrick Venturec9508db2018-10-16 17:18:43 -070058 // Destructor
Patrick Venture9eb82cf2018-10-20 19:36:01 -070059 virtual ~IPMIFruArea();
vishwac93d6d42015-12-16 11:55:16 -060060
Patrick Venturec9508db2018-10-16 17:18:43 -070061 // If a particular area has been marked valid / invalid
62 inline bool is_valid() const
63 {
64 return iv_valid;
65 }
vishwac93d6d42015-12-16 11:55:16 -060066
Patrick Venturec9508db2018-10-16 17:18:43 -070067 // Sets the present bit
68 inline void set_present(const bool present)
69 {
70 iv_present = present;
71 }
vishwac93d6d42015-12-16 11:55:16 -060072
Patrick Venturec9508db2018-10-16 17:18:43 -070073 // Sets the valid bit for a corresponding area.
74 inline void set_valid(const bool valid)
75 {
76 iv_valid = valid;
77 }
vishwac93d6d42015-12-16 11:55:16 -060078
Patrick Venturec9508db2018-10-16 17:18:43 -070079 // If a particular area accessible only by BMC
80 inline bool is_bmc_fru() const
81 {
82 return iv_bmc_fru;
83 }
vishwac93d6d42015-12-16 11:55:16 -060084
Patrick Venturec9508db2018-10-16 17:18:43 -070085 // returns fru id;
86 uint8_t get_fruid() const
87 {
88 return iv_fruid;
89 }
vishwac93d6d42015-12-16 11:55:16 -060090
Patrick Venturec9508db2018-10-16 17:18:43 -070091 // Returns the length.
92 size_t get_len() const
93 {
94 return iv_len;
95 }
vishwac93d6d42015-12-16 11:55:16 -060096
Patrick Venturec9508db2018-10-16 17:18:43 -070097 // Returns the type of the current fru area
98 ipmi_fru_area_type get_type() const
99 {
100 return iv_type;
101 }
vishwac93d6d42015-12-16 11:55:16 -0600102
Patrick Venturec9508db2018-10-16 17:18:43 -0700103 // Returns the name
104 const char* get_name() const
105 {
106 return iv_name.c_str();
107 }
vishwac93d6d42015-12-16 11:55:16 -0600108
Patrick Venturec9508db2018-10-16 17:18:43 -0700109 // Returns SD bus name
110 const char* get_bus_name() const
111 {
112 return iv_bus_name.c_str();
113 }
vishwac93d6d42015-12-16 11:55:16 -0600114
Patrick Venturec9508db2018-10-16 17:18:43 -0700115 // Retrns SD bus object path
116 const char* get_obj_path() const
117 {
118 return iv_obj_path.c_str();
119 }
vishwac93d6d42015-12-16 11:55:16 -0600120
Patrick Venturec9508db2018-10-16 17:18:43 -0700121 // Returns SD bus interface name
122 const char* get_intf_name() const
123 {
124 return iv_intf_name.c_str();
125 }
vishwac93d6d42015-12-16 11:55:16 -0600126
Patrick Venturec9508db2018-10-16 17:18:43 -0700127 // Returns the data portion
128 inline uint8_t* get_data() const
129 {
130 return iv_data;
131 }
vishwac93d6d42015-12-16 11:55:16 -0600132
Patrick Venturec9508db2018-10-16 17:18:43 -0700133 // Accepts a pointer to data and sets it in the object.
134 void set_data(const uint8_t*, const size_t);
vishwac93d6d42015-12-16 11:55:16 -0600135
Patrick Venturec9508db2018-10-16 17:18:43 -0700136 // Sets the dbus parameters
137 void update_dbus_paths(const char*, const char*, const char*);
vishwac93d6d42015-12-16 11:55:16 -0600138};
139
140#endif