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