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