blob: 82206bbaf7deaa8e68be4e5dbd8c60a66a6a71d0 [file] [log] [blame]
vishwac93d6d42015-12-16 11:55:16 -06001#ifndef __IPMI_FRU_AREA_H__
2#define __IPMI_FRU_AREA_H__
3
4#include <stdint.h>
5#include <stddef.h>
6#include <systemd/sd-bus.h>
7#include <string>
8#include <vector>
9#include <memory>
10#include "frup.h"
11#include "writefrudata.H"
12
13class ipmi_fru;
14typedef std::vector<std::unique_ptr<ipmi_fru>> fru_area_vec_t;
15
16class ipmi_fru
17{
18 private:
19 // Unique way of identifying a FRU
20 uint8_t iv_fruid;
21
22 // Type of the fru matching offsets in common header
23 ipmi_fru_area_type iv_type;
24
25 // Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
26 std::string iv_name;
27
28 // Length of a specific fru area.
29 size_t iv_len;
30
31 // Special bit for BMC readable eeprom only.
32 bool iv_bmc_fru;
33
34 // If a FRU is physically present.
35 bool iv_present;
36
37 // Whether a particular area is valid ?
38 bool iv_valid;
39
40 // Actual area data.
41 uint8_t *iv_data;
42
43 // fru inventory dbus name
44 std::string iv_bus_name;
45
46 // fru inventory dbus object path
47 std::string iv_obj_path;
48
49 // fru inventory dbus interface name
50 std::string iv_intf_name;
51
52 // sd_bus handle
53 sd_bus *iv_bus_type;
54
55 // Default constructor disabled.
56 ipmi_fru();
57
58 public:
59 // constructor
60 ipmi_fru(const uint8_t fruid, const ipmi_fru_area_type type,
61 sd_bus *bus_type, bool bmc_fru = false);
62
63 // Destructor
64 virtual ~ipmi_fru();
65
66 // If a particular area has been marked valid / invalid
67 inline bool is_valid() const
68 {
69 return iv_valid;
70 }
71
72 // Sets the present bit
73 inline void set_present(const bool present)
74 {
75 iv_present = present;
76 }
77
78 // Sets the valid bit for a corresponding area.
79 inline void set_valid(const bool valid)
80 {
81 iv_valid = valid;
82 }
83
84 // If a particular area accessible only by BMC
85 inline bool is_bmc_fru() const
86 {
87 return iv_bmc_fru;
88 }
89
90 // returns fru id;
91 uint8_t get_fruid() const
92 {
93 return iv_fruid;
94 }
95
96 // Returns the length.
97 size_t get_len() const
98 {
99 return iv_len;
100 }
101
102 // Returns the type of the current fru area
103 ipmi_fru_area_type get_type() const
104 {
105 return iv_type;
106 }
107
108 // Returns the name
109 const char *get_name() const
110 {
111 return iv_name.c_str();
112 }
113
114 // Returns SD bus name
115 const char *get_bus_name() const
116 {
117 return iv_bus_name.c_str();
118 }
119
120 // Retrns SD bus object path
121 const char *get_obj_path() const
122 {
123 return iv_obj_path.c_str();
124 }
125
126 // Returns SD bus interface name
127 const char *get_intf_name() const
128 {
129 return iv_intf_name.c_str();
130 }
131
132 // Returns the data portion
133 inline uint8_t *get_data() const
134 {
135 return iv_data;
136 }
137
138 // Returns the bus type.
139 inline sd_bus *get_bus_type() const
140 {
141 return iv_bus_type;
142 }
143
144 // Sets up the sd_bus variables for the given AREA type
145 int setup_sd_bus_paths(void);
146
147 // Accepts a pointer to data and sets it in the object.
148 void set_data(const uint8_t *, const size_t);
149
150 // Sets the dbus parameters
151 void update_dbus_paths(const char *, const char *, const char *);
152};
153
154#endif