blob: fce830d065e29bed50347fc435660018d29ee398 [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 Venturec9508db2018-10-16 17:18:43 -07007#include <stddef.h>
8#include <stdint.h>
9#include <systemd/sd-bus.h>
10
11#include <memory>
12#include <string>
13#include <vector>
14
vishwac93d6d42015-12-16 11:55:16 -060015class ipmi_fru;
16typedef std::vector<std::unique_ptr<ipmi_fru>> fru_area_vec_t;
17
18class ipmi_fru
19{
Patrick Venturec9508db2018-10-16 17:18:43 -070020 private:
21 // Unique way of identifying a FRU
22 uint8_t iv_fruid = 0;
vishwac93d6d42015-12-16 11:55:16 -060023
Patrick Venturec9508db2018-10-16 17:18:43 -070024 // Type of the fru matching offsets in common header
25 ipmi_fru_area_type iv_type = IPMI_FRU_AREA_INTERNAL_USE;
vishwac93d6d42015-12-16 11:55:16 -060026
Patrick Venturec9508db2018-10-16 17:18:43 -070027 // Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
28 std::string iv_name;
vishwac93d6d42015-12-16 11:55:16 -060029
Patrick Venturec9508db2018-10-16 17:18:43 -070030 // Length of a specific fru area.
31 size_t iv_len = 0;
vishwac93d6d42015-12-16 11:55:16 -060032
Patrick Venturec9508db2018-10-16 17:18:43 -070033 // Special bit for BMC readable eeprom only.
34 bool iv_bmc_fru = false;
vishwac93d6d42015-12-16 11:55:16 -060035
Patrick Venturec9508db2018-10-16 17:18:43 -070036 // If a FRU is physically present.
37 bool iv_present = false;
vishwac93d6d42015-12-16 11:55:16 -060038
Patrick Venturec9508db2018-10-16 17:18:43 -070039 // Whether a particular area is valid ?
40 bool iv_valid = false;
vishwac93d6d42015-12-16 11:55:16 -060041
Patrick Venturec9508db2018-10-16 17:18:43 -070042 // Actual area data.
43 uint8_t* iv_data = nullptr;
vishwac93d6d42015-12-16 11:55:16 -060044
Patrick Venturec9508db2018-10-16 17:18:43 -070045 // fru inventory dbus name
46 std::string iv_bus_name;
vishwac93d6d42015-12-16 11:55:16 -060047
Patrick Venturec9508db2018-10-16 17:18:43 -070048 // fru inventory dbus object path
49 std::string iv_obj_path;
vishwac93d6d42015-12-16 11:55:16 -060050
Patrick Venturec9508db2018-10-16 17:18:43 -070051 // fru inventory dbus interface name
52 std::string iv_intf_name;
vishwac93d6d42015-12-16 11:55:16 -060053
Patrick Venturec9508db2018-10-16 17:18:43 -070054 // Default constructor disabled.
55 ipmi_fru();
vishwac93d6d42015-12-16 11:55:16 -060056
Patrick Venturec9508db2018-10-16 17:18:43 -070057 public:
58 // constructor
59 ipmi_fru(const uint8_t fruid, const ipmi_fru_area_type type,
Patrick Ventured9af7b42018-10-20 19:23:36 -070060 bool bmc_fru = false);
vishwac93d6d42015-12-16 11:55:16 -060061
Patrick Venturec9508db2018-10-16 17:18:43 -070062 // Destructor
63 virtual ~ipmi_fru();
vishwac93d6d42015-12-16 11:55:16 -060064
Patrick Venturec9508db2018-10-16 17:18:43 -070065 // If a particular area has been marked valid / invalid
66 inline bool is_valid() const
67 {
68 return iv_valid;
69 }
vishwac93d6d42015-12-16 11:55:16 -060070
Patrick Venturec9508db2018-10-16 17:18:43 -070071 // Sets the present bit
72 inline void set_present(const bool present)
73 {
74 iv_present = present;
75 }
vishwac93d6d42015-12-16 11:55:16 -060076
Patrick Venturec9508db2018-10-16 17:18:43 -070077 // Sets the valid bit for a corresponding area.
78 inline void set_valid(const bool valid)
79 {
80 iv_valid = valid;
81 }
vishwac93d6d42015-12-16 11:55:16 -060082
Patrick Venturec9508db2018-10-16 17:18:43 -070083 // If a particular area accessible only by BMC
84 inline bool is_bmc_fru() const
85 {
86 return iv_bmc_fru;
87 }
vishwac93d6d42015-12-16 11:55:16 -060088
Patrick Venturec9508db2018-10-16 17:18:43 -070089 // returns fru id;
90 uint8_t get_fruid() const
91 {
92 return iv_fruid;
93 }
vishwac93d6d42015-12-16 11:55:16 -060094
Patrick Venturec9508db2018-10-16 17:18:43 -070095 // Returns the length.
96 size_t get_len() const
97 {
98 return iv_len;
99 }
vishwac93d6d42015-12-16 11:55:16 -0600100
Patrick Venturec9508db2018-10-16 17:18:43 -0700101 // Returns the type of the current fru area
102 ipmi_fru_area_type get_type() const
103 {
104 return iv_type;
105 }
vishwac93d6d42015-12-16 11:55:16 -0600106
Patrick Venturec9508db2018-10-16 17:18:43 -0700107 // Returns the name
108 const char* get_name() const
109 {
110 return iv_name.c_str();
111 }
vishwac93d6d42015-12-16 11:55:16 -0600112
Patrick Venturec9508db2018-10-16 17:18:43 -0700113 // Returns SD bus name
114 const char* get_bus_name() const
115 {
116 return iv_bus_name.c_str();
117 }
vishwac93d6d42015-12-16 11:55:16 -0600118
Patrick Venturec9508db2018-10-16 17:18:43 -0700119 // Retrns SD bus object path
120 const char* get_obj_path() const
121 {
122 return iv_obj_path.c_str();
123 }
vishwac93d6d42015-12-16 11:55:16 -0600124
Patrick Venturec9508db2018-10-16 17:18:43 -0700125 // Returns SD bus interface name
126 const char* get_intf_name() const
127 {
128 return iv_intf_name.c_str();
129 }
vishwac93d6d42015-12-16 11:55:16 -0600130
Patrick Venturec9508db2018-10-16 17:18:43 -0700131 // Returns the data portion
132 inline uint8_t* get_data() const
133 {
134 return iv_data;
135 }
vishwac93d6d42015-12-16 11:55:16 -0600136
Patrick Venturec9508db2018-10-16 17:18:43 -0700137 // Accepts a pointer to data and sets it in the object.
138 void set_data(const uint8_t*, const size_t);
vishwac93d6d42015-12-16 11:55:16 -0600139
Patrick Venturec9508db2018-10-16 17:18:43 -0700140 // Sets the dbus parameters
141 void update_dbus_paths(const char*, const char*, const char*);
vishwac93d6d42015-12-16 11:55:16 -0600142};
143
144#endif