| 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; |
| Patrick Venture | 1d00178 | 2018-10-21 13:11:08 -0700 | [diff] [blame] | 18 | ~IPMIFruArea() = default; |
| Patrick Venture | ac98899 | 2018-10-21 08:37:18 -0700 | [diff] [blame] | 19 | |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 20 | // constructor |
| Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 21 | IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type, |
| 22 | bool bmcOnlyFru = false); | ||||
| 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 | // Sets the present bit |
| Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 25 | inline void setPresent(const bool present) |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 26 | { |
| Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 27 | isPresent = present; |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 28 | } |
| 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 | // returns fru id; |
| Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 31 | uint8_t getFruID() const |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 32 | { |
| Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 33 | return fruID; |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 34 | } |
| 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 | // Returns the length. |
| Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 37 | size_t getLength() const |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 38 | { |
| Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 39 | return data.size(); |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 40 | } |
| 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 | // Returns the type of the current fru area |
| Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 43 | ipmi_fru_area_type getType() const |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 44 | { |
| Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 45 | return type; |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 46 | } |
| 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 | // Returns the name |
| Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 49 | const char* getName() const |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 50 | { |
| Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 51 | return name.c_str(); |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 52 | } |
| 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 | // Returns the data portion |
| Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 55 | inline const uint8_t* getData() const |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 56 | { |
| Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 57 | return data.data(); |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 58 | } |
| vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 59 | |
| Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 60 | // Accepts a pointer to data and sets it in the object. |
| Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 61 | void setData(const uint8_t*, const size_t); |
| vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 62 | |
| Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 63 | private: |
| 64 | // Unique way of identifying a FRU | ||||
| Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 65 | uint8_t fruID = 0; |
| Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 66 | |
| 67 | // Type of the fru matching offsets in common header | ||||
| 68 | ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE; | ||||
| 69 | |||||
| 70 | // Name of the fru area. ( BOARD/CHASSIS/PRODUCT ) | ||||
| 71 | std::string name; | ||||
| 72 | |||||
| Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 73 | // Special bit for BMC readable eeprom only. |
| Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 74 | bool bmcOnlyFru = false; |
| Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 75 | |
| 76 | // If a FRU is physically present. | ||||
| 77 | bool isPresent = false; | ||||
| 78 | |||||
| 79 | // Whether a particular area is valid ? | ||||
| 80 | bool isValid = false; | ||||
| 81 | |||||
| 82 | // Actual area data. | ||||
| Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 83 | std::vector<uint8_t> data; |
| vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 84 | }; |
| 85 | |||||
| 86 | #endif | ||||