vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 1 | #ifndef __IPMI_FRU_AREA_H__ |
2 | #define __IPMI_FRU_AREA_H__ | ||||
3 | |||||
Ratan Gupta | 19c617b | 2017-02-10 15:39:40 +0530 | [diff] [blame] | 4 | #include "frup.hpp" |
Matthew Barth | 155c34f | 2016-10-18 14:33:17 -0500 | [diff] [blame] | 5 | #include "writefrudata.hpp" |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 6 | |
Patrick Venture | b4c333f | 2018-10-20 20:16:39 -0700 | [diff] [blame^] | 7 | #include <cstdint> |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 8 | #include <memory> |
9 | #include <string> | ||||
10 | #include <vector> | ||||
11 | |||||
Patrick Venture | b4c333f | 2018-10-20 20:16:39 -0700 | [diff] [blame^] | 12 | using std::uint8_t; |
13 | |||||
Patrick Venture | 9eb82cf | 2018-10-20 19:36:01 -0700 | [diff] [blame] | 14 | class IPMIFruArea |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 15 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 16 | private: |
17 | // Unique way of identifying a FRU | ||||
18 | uint8_t iv_fruid = 0; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 19 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 20 | // Type of the fru matching offsets in common header |
21 | ipmi_fru_area_type iv_type = IPMI_FRU_AREA_INTERNAL_USE; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 22 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 23 | // Name of the fru area. ( BOARD/CHASSIS/PRODUCT ) |
24 | std::string iv_name; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 25 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 26 | // Length of a specific fru area. |
27 | size_t iv_len = 0; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 28 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 29 | // Special bit for BMC readable eeprom only. |
30 | bool iv_bmc_fru = false; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 31 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 32 | // If a FRU is physically present. |
33 | bool iv_present = false; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 34 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 35 | // Whether a particular area is valid ? |
36 | bool iv_valid = false; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 37 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 38 | // Actual area data. |
39 | uint8_t* iv_data = nullptr; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 40 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 41 | // fru inventory dbus name |
42 | std::string iv_bus_name; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 43 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 44 | // fru inventory dbus object path |
45 | std::string iv_obj_path; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 46 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 47 | // fru inventory dbus interface name |
48 | std::string iv_intf_name; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 49 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 50 | // Default constructor disabled. |
Patrick Venture | 9eb82cf | 2018-10-20 19:36:01 -0700 | [diff] [blame] | 51 | IPMIFruArea(); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 52 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 53 | public: |
54 | // constructor | ||||
Patrick Venture | 9eb82cf | 2018-10-20 19:36:01 -0700 | [diff] [blame] | 55 | IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type, |
56 | bool bmc_fru = false); | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 57 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 58 | // Destructor |
Patrick Venture | 9eb82cf | 2018-10-20 19:36:01 -0700 | [diff] [blame] | 59 | virtual ~IPMIFruArea(); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 60 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 61 | // If a particular area has been marked valid / invalid |
62 | inline bool is_valid() const | ||||
63 | { | ||||
64 | return iv_valid; | ||||
65 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 66 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 67 | // Sets the present bit |
68 | inline void set_present(const bool present) | ||||
69 | { | ||||
70 | iv_present = present; | ||||
71 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 72 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 73 | // Sets the valid bit for a corresponding area. |
74 | inline void set_valid(const bool valid) | ||||
75 | { | ||||
76 | iv_valid = valid; | ||||
77 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 78 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 79 | // If a particular area accessible only by BMC |
80 | inline bool is_bmc_fru() const | ||||
81 | { | ||||
82 | return iv_bmc_fru; | ||||
83 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 84 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 85 | // returns fru id; |
86 | uint8_t get_fruid() const | ||||
87 | { | ||||
88 | return iv_fruid; | ||||
89 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 90 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 91 | // Returns the length. |
92 | size_t get_len() const | ||||
93 | { | ||||
94 | return iv_len; | ||||
95 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 96 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 97 | // Returns the type of the current fru area |
98 | ipmi_fru_area_type get_type() const | ||||
99 | { | ||||
100 | return iv_type; | ||||
101 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 102 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 103 | // Returns the name |
104 | const char* get_name() const | ||||
105 | { | ||||
106 | return iv_name.c_str(); | ||||
107 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 108 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 109 | // Returns SD bus name |
110 | const char* get_bus_name() const | ||||
111 | { | ||||
112 | return iv_bus_name.c_str(); | ||||
113 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 114 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 115 | // Retrns SD bus object path |
116 | const char* get_obj_path() const | ||||
117 | { | ||||
118 | return iv_obj_path.c_str(); | ||||
119 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 120 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 121 | // Returns SD bus interface name |
122 | const char* get_intf_name() const | ||||
123 | { | ||||
124 | return iv_intf_name.c_str(); | ||||
125 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 126 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 127 | // Returns the data portion |
128 | inline uint8_t* get_data() const | ||||
129 | { | ||||
130 | return iv_data; | ||||
131 | } | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 132 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 133 | // Accepts a pointer to data and sets it in the object. |
134 | void set_data(const uint8_t*, const size_t); | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 135 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 136 | // Sets the dbus parameters |
137 | void update_dbus_paths(const char*, const char*, const char*); | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 138 | }; |
139 | |||||
140 | #endif |