blob: 6cebb3c764ace47ab1ad3e95be1f76a9466203d1 [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
Patrick Venture9eb82cf2018-10-20 19:36:01 -070015class IPMIFruArea
vishwac93d6d42015-12-16 11:55:16 -060016{
Patrick Venturec9508db2018-10-16 17:18:43 -070017 private:
18 // Unique way of identifying a FRU
19 uint8_t iv_fruid = 0;
vishwac93d6d42015-12-16 11:55:16 -060020
Patrick Venturec9508db2018-10-16 17:18:43 -070021 // Type of the fru matching offsets in common header
22 ipmi_fru_area_type iv_type = IPMI_FRU_AREA_INTERNAL_USE;
vishwac93d6d42015-12-16 11:55:16 -060023
Patrick Venturec9508db2018-10-16 17:18:43 -070024 // Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
25 std::string iv_name;
vishwac93d6d42015-12-16 11:55:16 -060026
Patrick Venturec9508db2018-10-16 17:18:43 -070027 // Length of a specific fru area.
28 size_t iv_len = 0;
vishwac93d6d42015-12-16 11:55:16 -060029
Patrick Venturec9508db2018-10-16 17:18:43 -070030 // Special bit for BMC readable eeprom only.
31 bool iv_bmc_fru = false;
vishwac93d6d42015-12-16 11:55:16 -060032
Patrick Venturec9508db2018-10-16 17:18:43 -070033 // If a FRU is physically present.
34 bool iv_present = false;
vishwac93d6d42015-12-16 11:55:16 -060035
Patrick Venturec9508db2018-10-16 17:18:43 -070036 // Whether a particular area is valid ?
37 bool iv_valid = false;
vishwac93d6d42015-12-16 11:55:16 -060038
Patrick Venturec9508db2018-10-16 17:18:43 -070039 // Actual area data.
40 uint8_t* iv_data = nullptr;
vishwac93d6d42015-12-16 11:55:16 -060041
Patrick Venturec9508db2018-10-16 17:18:43 -070042 // fru inventory dbus name
43 std::string iv_bus_name;
vishwac93d6d42015-12-16 11:55:16 -060044
Patrick Venturec9508db2018-10-16 17:18:43 -070045 // fru inventory dbus object path
46 std::string iv_obj_path;
vishwac93d6d42015-12-16 11:55:16 -060047
Patrick Venturec9508db2018-10-16 17:18:43 -070048 // fru inventory dbus interface name
49 std::string iv_intf_name;
vishwac93d6d42015-12-16 11:55:16 -060050
Patrick Venturec9508db2018-10-16 17:18:43 -070051 // Default constructor disabled.
Patrick Venture9eb82cf2018-10-20 19:36:01 -070052 IPMIFruArea();
vishwac93d6d42015-12-16 11:55:16 -060053
Patrick Venturec9508db2018-10-16 17:18:43 -070054 public:
55 // constructor
Patrick Venture9eb82cf2018-10-20 19:36:01 -070056 IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type,
57 bool bmc_fru = false);
vishwac93d6d42015-12-16 11:55:16 -060058
Patrick Venturec9508db2018-10-16 17:18:43 -070059 // Destructor
Patrick Venture9eb82cf2018-10-20 19:36:01 -070060 virtual ~IPMIFruArea();
vishwac93d6d42015-12-16 11:55:16 -060061
Patrick Venturec9508db2018-10-16 17:18:43 -070062 // If a particular area has been marked valid / invalid
63 inline bool is_valid() const
64 {
65 return iv_valid;
66 }
vishwac93d6d42015-12-16 11:55:16 -060067
Patrick Venturec9508db2018-10-16 17:18:43 -070068 // Sets the present bit
69 inline void set_present(const bool present)
70 {
71 iv_present = present;
72 }
vishwac93d6d42015-12-16 11:55:16 -060073
Patrick Venturec9508db2018-10-16 17:18:43 -070074 // Sets the valid bit for a corresponding area.
75 inline void set_valid(const bool valid)
76 {
77 iv_valid = valid;
78 }
vishwac93d6d42015-12-16 11:55:16 -060079
Patrick Venturec9508db2018-10-16 17:18:43 -070080 // If a particular area accessible only by BMC
81 inline bool is_bmc_fru() const
82 {
83 return iv_bmc_fru;
84 }
vishwac93d6d42015-12-16 11:55:16 -060085
Patrick Venturec9508db2018-10-16 17:18:43 -070086 // returns fru id;
87 uint8_t get_fruid() const
88 {
89 return iv_fruid;
90 }
vishwac93d6d42015-12-16 11:55:16 -060091
Patrick Venturec9508db2018-10-16 17:18:43 -070092 // Returns the length.
93 size_t get_len() const
94 {
95 return iv_len;
96 }
vishwac93d6d42015-12-16 11:55:16 -060097
Patrick Venturec9508db2018-10-16 17:18:43 -070098 // Returns the type of the current fru area
99 ipmi_fru_area_type get_type() const
100 {
101 return iv_type;
102 }
vishwac93d6d42015-12-16 11:55:16 -0600103
Patrick Venturec9508db2018-10-16 17:18:43 -0700104 // Returns the name
105 const char* get_name() const
106 {
107 return iv_name.c_str();
108 }
vishwac93d6d42015-12-16 11:55:16 -0600109
Patrick Venturec9508db2018-10-16 17:18:43 -0700110 // Returns SD bus name
111 const char* get_bus_name() const
112 {
113 return iv_bus_name.c_str();
114 }
vishwac93d6d42015-12-16 11:55:16 -0600115
Patrick Venturec9508db2018-10-16 17:18:43 -0700116 // Retrns SD bus object path
117 const char* get_obj_path() const
118 {
119 return iv_obj_path.c_str();
120 }
vishwac93d6d42015-12-16 11:55:16 -0600121
Patrick Venturec9508db2018-10-16 17:18:43 -0700122 // Returns SD bus interface name
123 const char* get_intf_name() const
124 {
125 return iv_intf_name.c_str();
126 }
vishwac93d6d42015-12-16 11:55:16 -0600127
Patrick Venturec9508db2018-10-16 17:18:43 -0700128 // Returns the data portion
129 inline uint8_t* get_data() const
130 {
131 return iv_data;
132 }
vishwac93d6d42015-12-16 11:55:16 -0600133
Patrick Venturec9508db2018-10-16 17:18:43 -0700134 // Accepts a pointer to data and sets it in the object.
135 void set_data(const uint8_t*, const size_t);
vishwac93d6d42015-12-16 11:55:16 -0600136
Patrick Venturec9508db2018-10-16 17:18:43 -0700137 // Sets the dbus parameters
138 void update_dbus_paths(const char*, const char*, const char*);
vishwac93d6d42015-12-16 11:55:16 -0600139};
140
141#endif