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. | ||||
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 28 | */ |
Jayanth Othayoth | 70cb067 | 2025-06-07 02:13:23 -0500 | [diff] [blame] | 29 | IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 30 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 31 | /** |
32 | * Set whether the FRU is present. | ||||
33 | * | ||||
34 | * @param[in] present - True if present. | ||||
35 | */ | ||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 36 | inline void setPresent(const bool present) |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 37 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 38 | isPresent = present; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 39 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 40 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 41 | /** |
42 | * Retrieves the FRU's ID. | ||||
43 | * | ||||
44 | * @return the FRU ID. | ||||
45 | */ | ||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 46 | uint8_t getFruID() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 47 | { |
Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 48 | return fruID; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 49 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 50 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 51 | /** |
52 | * Returns the length of the FRU data. | ||||
53 | * | ||||
54 | * @return the number of bytes. | ||||
55 | */ | ||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 56 | size_t getLength() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 57 | { |
Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 58 | return data.size(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 59 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 60 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 61 | /** |
62 | * Returns the type of the current FRU area. | ||||
63 | * | ||||
64 | * @return the type of FRU area | ||||
65 | */ | ||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 66 | ipmi_fru_area_type getType() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 67 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 68 | return type; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 69 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 70 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 71 | /** |
72 | * Returns the FRU area name. | ||||
73 | * | ||||
74 | * @return the FRU area name | ||||
75 | */ | ||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 76 | const char* getName() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 77 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 78 | return name.c_str(); |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 79 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 80 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 81 | /** |
82 | * Returns the data portion. | ||||
83 | * | ||||
84 | * @return pointer to data | ||||
85 | */ | ||||
Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 86 | inline const uint8_t* getData() const |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 87 | { |
Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 88 | return data.data(); |
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 | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 91 | /** |
92 | * Accepts a pointer to data and sets it in the object. | ||||
93 | * | ||||
94 | * @param[in] value - The data to copy into the FRU area | ||||
95 | * @param[in] length - the number of bytes value points to | ||||
96 | */ | ||||
97 | void setData(const uint8_t* value, const size_t length); | ||||
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 98 | |
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 99 | private: |
100 | // Unique way of identifying a FRU | ||||
Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 101 | uint8_t fruID = 0; |
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 102 | |
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 103 | // Type of the FRU matching offsets in common header |
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 104 | ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE; |
105 | |||||
Patrick Venture | 1816ff3 | 2018-10-21 13:32:06 -0700 | [diff] [blame] | 106 | // Name of the FRU area. ( BOARD/CHASSIS/PRODUCT ) |
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 107 | std::string name; |
108 | |||||
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 109 | // If a FRU is physically present. |
110 | bool isPresent = false; | ||||
111 | |||||
Patrick Venture | 524ba9c | 2018-10-20 20:52:27 -0700 | [diff] [blame] | 112 | // Actual area data. |
Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 113 | std::vector<uint8_t> data; |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 114 | }; |
115 | |||||
116 | #endif |