blob: 038e237692ab61b9294eb0de1790ed161ab8acaf [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 // sd_bus handle
55 sd_bus* iv_bus_type = nullptr;
vishwac93d6d42015-12-16 11:55:16 -060056
Patrick Venturec9508db2018-10-16 17:18:43 -070057 // Default constructor disabled.
58 ipmi_fru();
vishwac93d6d42015-12-16 11:55:16 -060059
Patrick Venturec9508db2018-10-16 17:18:43 -070060 public:
61 // constructor
62 ipmi_fru(const uint8_t fruid, const ipmi_fru_area_type type,
63 sd_bus* bus_type, bool bmc_fru = false);
vishwac93d6d42015-12-16 11:55:16 -060064
Patrick Venturec9508db2018-10-16 17:18:43 -070065 // Destructor
66 virtual ~ipmi_fru();
vishwac93d6d42015-12-16 11:55:16 -060067
Patrick Venturec9508db2018-10-16 17:18:43 -070068 // If a particular area has been marked valid / invalid
69 inline bool is_valid() const
70 {
71 return iv_valid;
72 }
vishwac93d6d42015-12-16 11:55:16 -060073
Patrick Venturec9508db2018-10-16 17:18:43 -070074 // Sets the present bit
75 inline void set_present(const bool present)
76 {
77 iv_present = present;
78 }
vishwac93d6d42015-12-16 11:55:16 -060079
Patrick Venturec9508db2018-10-16 17:18:43 -070080 // Sets the valid bit for a corresponding area.
81 inline void set_valid(const bool valid)
82 {
83 iv_valid = valid;
84 }
vishwac93d6d42015-12-16 11:55:16 -060085
Patrick Venturec9508db2018-10-16 17:18:43 -070086 // If a particular area accessible only by BMC
87 inline bool is_bmc_fru() const
88 {
89 return iv_bmc_fru;
90 }
vishwac93d6d42015-12-16 11:55:16 -060091
Patrick Venturec9508db2018-10-16 17:18:43 -070092 // returns fru id;
93 uint8_t get_fruid() const
94 {
95 return iv_fruid;
96 }
vishwac93d6d42015-12-16 11:55:16 -060097
Patrick Venturec9508db2018-10-16 17:18:43 -070098 // Returns the length.
99 size_t get_len() const
100 {
101 return iv_len;
102 }
vishwac93d6d42015-12-16 11:55:16 -0600103
Patrick Venturec9508db2018-10-16 17:18:43 -0700104 // Returns the type of the current fru area
105 ipmi_fru_area_type get_type() const
106 {
107 return iv_type;
108 }
vishwac93d6d42015-12-16 11:55:16 -0600109
Patrick Venturec9508db2018-10-16 17:18:43 -0700110 // Returns the name
111 const char* get_name() const
112 {
113 return iv_name.c_str();
114 }
vishwac93d6d42015-12-16 11:55:16 -0600115
Patrick Venturec9508db2018-10-16 17:18:43 -0700116 // Returns SD bus name
117 const char* get_bus_name() const
118 {
119 return iv_bus_name.c_str();
120 }
vishwac93d6d42015-12-16 11:55:16 -0600121
Patrick Venturec9508db2018-10-16 17:18:43 -0700122 // Retrns SD bus object path
123 const char* get_obj_path() const
124 {
125 return iv_obj_path.c_str();
126 }
vishwac93d6d42015-12-16 11:55:16 -0600127
Patrick Venturec9508db2018-10-16 17:18:43 -0700128 // Returns SD bus interface name
129 const char* get_intf_name() const
130 {
131 return iv_intf_name.c_str();
132 }
vishwac93d6d42015-12-16 11:55:16 -0600133
Patrick Venturec9508db2018-10-16 17:18:43 -0700134 // Returns the data portion
135 inline uint8_t* get_data() const
136 {
137 return iv_data;
138 }
vishwac93d6d42015-12-16 11:55:16 -0600139
Patrick Venturec9508db2018-10-16 17:18:43 -0700140 // Accepts a pointer to data and sets it in the object.
141 void set_data(const uint8_t*, const size_t);
vishwac93d6d42015-12-16 11:55:16 -0600142
Patrick Venturec9508db2018-10-16 17:18:43 -0700143 // Sets the dbus parameters
144 void update_dbus_paths(const char*, const char*, const char*);
vishwac93d6d42015-12-16 11:55:16 -0600145};
146
147#endif