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 | public: |
Patrick Venture | ac98899 | 2018-10-21 08:37:18 -0700 | [diff] [blame] | 17 | IPMIFruArea() = delete; |
18 | |||||
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 19 | // constructor |
Patrick Venture | 9eb82cf | 2018-10-20 19:36:01 -0700 | [diff] [blame] | 20 | IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type, |
21 | bool bmc_fru = false); | ||||
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 | // Destructor |
Patrick Venture | 9eb82cf | 2018-10-20 19:36:01 -0700 | [diff] [blame] | 24 | virtual ~IPMIFruArea(); |
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 | // Sets the present bit |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 27 | inline void setPresent(const bool present) |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 28 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 29 | isPresent = present; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 30 | } |
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 | // returns fru id; |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 33 | uint8_t getFruID() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 34 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 35 | return fruid; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 36 | } |
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 | // Returns the length. |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 39 | size_t getLength() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 40 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 41 | return len; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 42 | } |
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 | // Returns the type of the current fru area |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 45 | ipmi_fru_area_type getType() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 46 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 47 | return type; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 48 | } |
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 | // Returns the name |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 51 | const char* getName() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 52 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 53 | return name.c_str(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 54 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 55 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 56 | // Returns SD bus name |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 57 | const char* getBusName() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 58 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 59 | return bus_name.c_str(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 60 | } |
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 | // Retrns SD bus object path |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 63 | const char* getObjectPath() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 64 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 65 | return obj_path.c_str(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 | // Returns SD bus interface name |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 69 | const char* getInterfaceName() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 70 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 71 | return intf_name.c_str(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 | // Returns the data portion |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 75 | inline uint8_t* getData() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 76 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 77 | return data; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 | // Accepts a pointer to data and sets it in the object. |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 81 | void setData(const uint8_t*, const size_t); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 82 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 83 | // Sets the dbus parameters |
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 84 | void updateDbusPaths(const char*, const char*, const char*); |
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 85 | |
86 | private: | ||||
87 | // Unique way of identifying a FRU | ||||
88 | uint8_t fruid = 0; | ||||
89 | |||||
90 | // Type of the fru matching offsets in common header | ||||
91 | ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE; | ||||
92 | |||||
93 | // Name of the fru area. ( BOARD/CHASSIS/PRODUCT ) | ||||
94 | std::string name; | ||||
95 | |||||
96 | // Length of a specific fru area. | ||||
97 | size_t len = 0; | ||||
98 | |||||
99 | // Special bit for BMC readable eeprom only. | ||||
100 | bool bmc_fru = false; | ||||
101 | |||||
102 | // If a FRU is physically present. | ||||
103 | bool isPresent = false; | ||||
104 | |||||
105 | // Whether a particular area is valid ? | ||||
106 | bool isValid = false; | ||||
107 | |||||
108 | // Actual area data. | ||||
109 | uint8_t* data = nullptr; | ||||
110 | |||||
111 | // fru inventory dbus name | ||||
112 | std::string bus_name; | ||||
113 | |||||
114 | // fru inventory dbus object path | ||||
115 | std::string obj_path; | ||||
116 | |||||
117 | // fru inventory dbus interface name | ||||
118 | std::string intf_name; | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 119 | }; |
120 | |||||
121 | #endif |