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 | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 18 | uint8_t 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 |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 21 | ipmi_fru_area_type 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 ) |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 24 | std::string 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. |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 27 | size_t 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. |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 30 | bool 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. |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 33 | bool isPresent = 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 ? |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 36 | bool isValid = 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. |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 39 | uint8_t* 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 |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 42 | std::string 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 |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 45 | std::string 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 |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 48 | std::string 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 | // Sets the present bit |
62 | inline void set_present(const bool present) | ||||
63 | { | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 64 | isPresent = present; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 | // returns fru id; |
68 | uint8_t get_fruid() const | ||||
69 | { | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 70 | return fruid; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 | // Returns the length. |
74 | size_t get_len() const | ||||
75 | { | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 76 | return len; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 | // Returns the type of the current fru area |
80 | ipmi_fru_area_type get_type() const | ||||
81 | { | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 82 | return type; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 the name |
86 | const char* get_name() const | ||||
87 | { | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 88 | return name.c_str(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 SD bus name |
92 | const char* get_bus_name() const | ||||
93 | { | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 94 | return bus_name.c_str(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 | // Retrns SD bus object path |
98 | const char* get_obj_path() const | ||||
99 | { | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 100 | return obj_path.c_str(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 SD bus interface name |
104 | const char* get_intf_name() const | ||||
105 | { | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 106 | return intf_name.c_str(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 the data portion |
110 | inline uint8_t* get_data() const | ||||
111 | { | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame^] | 112 | return data; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 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 | // Accepts a pointer to data and sets it in the object. |
116 | void set_data(const uint8_t*, const size_t); | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 117 | |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 118 | // Sets the dbus parameters |
119 | void update_dbus_paths(const char*, const char*, const char*); | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 120 | }; |
121 | |||||
122 | #endif |