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 | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 14 | /** |
15 | * IPMIFruArea represents a piece of a FRU that is accessible over IPMI. | ||||
16 | */ | ||||
Patrick Venture | 9eb82cf | 2018-10-20 19:36:01 -0700 | [diff] [blame] | 17 | class IPMIFruArea |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 18 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 19 | public: |
Patrick Venture | ac98899 | 2018-10-21 08:37:18 -0700 | [diff] [blame] | 20 | IPMIFruArea() = delete; |
Patrick Venture | 1d00178 | 2018-10-21 13:11:08 -0700 | [diff] [blame] | 21 | ~IPMIFruArea() = default; |
Patrick Venture | ac98899 | 2018-10-21 08:37:18 -0700 | [diff] [blame] | 22 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 23 | /** |
24 | * Construct an IPMIFruArea. | ||||
25 | * | ||||
26 | * @param[in] fruID - FRU identifier value | ||||
27 | * @param[in] type - the type of FRU area. | ||||
28 | * @param[in] bmcOnlyFru - Is this FRU only accessible via the BMC | ||||
29 | */ | ||||
Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 30 | IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type, |
31 | bool bmcOnlyFru = false); | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 32 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 33 | /** |
34 | * Set whether the FRU is present. | ||||
35 | * | ||||
36 | * @param[in] present - True if present. | ||||
37 | */ | ||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 38 | inline void setPresent(const bool present) |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 39 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 40 | isPresent = present; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 41 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 42 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 43 | /** |
44 | * Retrieves the FRU's ID. | ||||
45 | * | ||||
46 | * @return the FRU ID. | ||||
47 | */ | ||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 48 | uint8_t getFruID() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 49 | { |
Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 50 | return fruID; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 51 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 52 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 53 | /** |
54 | * Returns the length of the FRU data. | ||||
55 | * | ||||
56 | * @return the number of bytes. | ||||
57 | */ | ||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 58 | size_t getLength() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 59 | { |
Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 60 | return data.size(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 61 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 62 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 63 | /** |
64 | * Returns the type of the current FRU area. | ||||
65 | * | ||||
66 | * @return the type of FRU area | ||||
67 | */ | ||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 68 | ipmi_fru_area_type getType() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 69 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 70 | return type; |
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 | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 73 | /** |
74 | * Returns the FRU area name. | ||||
75 | * | ||||
76 | * @return the FRU area name | ||||
77 | */ | ||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 78 | const char* getName() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 79 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 80 | return name.c_str(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 81 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 82 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 83 | /** |
84 | * Returns the data portion. | ||||
85 | * | ||||
86 | * @return pointer to data | ||||
87 | */ | ||||
Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 88 | inline const uint8_t* getData() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 89 | { |
Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 90 | return data.data(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 91 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 92 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 93 | /** |
94 | * Accepts a pointer to data and sets it in the object. | ||||
95 | * | ||||
96 | * @param[in] value - The data to copy into the FRU area | ||||
97 | * @param[in] length - the number of bytes value points to | ||||
98 | */ | ||||
99 | void setData(const uint8_t* value, const size_t length); | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 100 | |
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 101 | private: |
102 | // Unique way of identifying a FRU | ||||
Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 103 | uint8_t fruID = 0; |
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 104 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 105 | // Type of the FRU matching offsets in common header |
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 106 | ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE; |
107 | |||||
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 108 | // Name of the FRU area. ( BOARD/CHASSIS/PRODUCT ) |
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 109 | std::string name; |
110 | |||||
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 111 | // Special bit for BMC readable eeprom only. |
Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 112 | bool bmcOnlyFru = false; |
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 113 | |
114 | // If a FRU is physically present. | ||||
115 | bool isPresent = false; | ||||
116 | |||||
117 | // Whether a particular area is valid ? | ||||
118 | bool isValid = false; | ||||
119 | |||||
120 | // Actual area data. | ||||
Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 121 | std::vector<uint8_t> data; |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 122 | }; |
123 | |||||
124 | #endif |