Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "fru_identity.hpp" |
| 4 | #include "mru.hpp" |
| 5 | #include "pce_identity.hpp" |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 6 | #include "pel_types.hpp" |
Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 7 | #include "stream.hpp" |
| 8 | |
| 9 | namespace openpower |
| 10 | { |
| 11 | namespace pels |
| 12 | { |
| 13 | namespace src |
| 14 | { |
| 15 | |
| 16 | /** |
| 17 | * @class Callout |
| 18 | * |
| 19 | * Represents a single FRU callout in the SRC's FRU callout |
| 20 | * subsection. |
| 21 | * |
| 22 | * The 'Callouts' class holds a list of these objects. |
| 23 | * |
| 24 | * The callout priority and location code are in this structure. |
| 25 | * |
| 26 | * There can also be up to one each of three types of substructures |
| 27 | * in a single callout: |
| 28 | * * FRU Identity (must be first if present) |
| 29 | * * Power Controlling Enclosure (PCE) |
| 30 | * * Manufacturing Replaceable Unit (MRU) |
| 31 | * |
| 32 | * These substructures have their own objects managed by unique_ptrs |
| 33 | * which will only be allocated if those substructures exist. |
| 34 | */ |
| 35 | class Callout |
| 36 | { |
| 37 | public: |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 38 | /** |
| 39 | * @brief Which callout substructures are included. |
| 40 | */ |
| 41 | enum calloutFlags |
| 42 | { |
| 43 | calloutType = 0b0010'0000, |
| 44 | fruIdentIncluded = 0b0000'1000, |
| 45 | mruIncluded = 0b0000'0100 |
| 46 | |
| 47 | // Leaving out the various PCE identity ones since |
| 48 | // we don't use them. |
| 49 | }; |
| 50 | |
Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 51 | Callout() = delete; |
| 52 | ~Callout() = default; |
| 53 | Callout(const Callout&) = delete; |
| 54 | Callout& operator=(const Callout&) = delete; |
| 55 | Callout(Callout&&) = delete; |
| 56 | Callout& operator=(Callout&&) = delete; |
| 57 | |
| 58 | /** |
| 59 | * @brief Constructor |
| 60 | * |
| 61 | * Fills in this class's data fields from the stream. |
| 62 | * |
| 63 | * @param[in] pel - the PEL data stream |
| 64 | */ |
| 65 | explicit Callout(Stream& pel); |
| 66 | |
| 67 | /** |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 68 | * @brief Constructor |
| 69 | * |
| 70 | * Creates the objects with a FRUIdentity substructure that calls |
| 71 | * out a normal hardware FRU. |
| 72 | * |
| 73 | * @param[in] priority - The priority of the callout |
| 74 | * @param[in] locationCode - The location code of the callout |
| 75 | * @param[in] partNumber - The part number of the callout |
| 76 | * @param[in] ccin - The CCIN of the callout |
| 77 | * @param[in] serialNumber - The serial number of the callout |
| 78 | */ |
| 79 | Callout(CalloutPriority priority, const std::string& locationCode, |
| 80 | const std::string& partNumber, const std::string& ccin, |
| 81 | const std::string& serialNumber); |
| 82 | |
| 83 | /** |
| 84 | * @brief Constructor |
| 85 | * |
| 86 | * Creates the objects with a FRUIdentity substructure that calls |
Matt Spinler | a86ec99 | 2020-04-09 12:42:07 -0500 | [diff] [blame] | 87 | * out a maintenance procedure. |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 88 | * |
| 89 | * @param[in] priority - The priority of the callout |
Matt Spinler | a27e2e5 | 2020-04-09 11:06:11 -0500 | [diff] [blame] | 90 | * @param[in] procedureFromRegistry - The maintenance procedure name |
| 91 | * as defined in the message registry. |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 92 | */ |
Matt Spinler | a27e2e5 | 2020-04-09 11:06:11 -0500 | [diff] [blame] | 93 | Callout(CalloutPriority priority, const std::string& procedureFromRegistry); |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 94 | |
| 95 | /** |
Matt Spinler | a86ec99 | 2020-04-09 12:42:07 -0500 | [diff] [blame] | 96 | * @brief Constructor |
| 97 | * |
| 98 | * Creates the objects with a FRUIdentity substructure that calls |
| 99 | * out a symbolic FRU. |
| 100 | * |
| 101 | * @param[in] priority - The priority of the callout |
| 102 | * @param[in] symbolicFRUFromRegistry - The symbolic FRU name as |
| 103 | * defined in the message registry. |
| 104 | * @param[in] locationCode - The location code of the callout |
| 105 | * @param[in] trustedLocationCode - If the location is trusted |
| 106 | */ |
| 107 | Callout(CalloutPriority priority, |
| 108 | const std::string& symbolicFRUFromRegistry, |
| 109 | const std::string& locationCode, bool trustedLocationCode); |
| 110 | |
| 111 | /** |
Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 112 | * @brief Returns the size of this object when flattened into a PEL |
| 113 | * |
| 114 | * @return size_t - The size of the section |
| 115 | */ |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 116 | size_t flattenedSize() const; |
Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * @brief Flatten the object into the stream |
| 120 | * |
| 121 | * @param[in] stream - The stream to write to |
| 122 | */ |
Matt Spinler | 724d0d8 | 2019-11-06 10:05:36 -0600 | [diff] [blame] | 123 | void flatten(Stream& pel) const; |
Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 124 | |
| 125 | /** |
Harisuddin Mohamed Isa | 0f717e1 | 2020-01-15 20:05:33 +0800 | [diff] [blame] | 126 | * @brief Returns the flags field of a callout |
| 127 | * |
| 128 | * @return uint8_t - The flags |
| 129 | */ |
| 130 | uint8_t flags() const |
| 131 | { |
| 132 | return _flags; |
| 133 | } |
| 134 | |
| 135 | /** |
Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 136 | * @brief Returns the priority field of a callout |
| 137 | * |
| 138 | * @return uint8_t - The priority |
| 139 | */ |
| 140 | uint8_t priority() const |
| 141 | { |
| 142 | return _priority; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * @brief Returns the location code of the callout |
| 147 | * |
| 148 | * @return std::string - The location code |
| 149 | */ |
| 150 | std::string locationCode() const |
| 151 | { |
| 152 | std::string lc; |
| 153 | if (!_locationCode.empty()) |
| 154 | { |
| 155 | // NULL terminated |
| 156 | lc = static_cast<const char*>(_locationCode.data()); |
| 157 | } |
| 158 | return lc; |
| 159 | } |
| 160 | |
| 161 | /** |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 162 | * @brief Returns the location code size |
| 163 | * |
| 164 | * @return size_t - The size, including the terminating null. |
| 165 | */ |
| 166 | size_t locationCodeSize() const |
| 167 | { |
| 168 | return _locationCodeSize; |
| 169 | } |
| 170 | |
| 171 | /** |
Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 172 | * @brief Returns the FRU identity substructure |
| 173 | * |
| 174 | * @return const std::unique_ptr<FRUIdentity>& |
| 175 | */ |
| 176 | const std::unique_ptr<FRUIdentity>& fruIdentity() const |
| 177 | { |
| 178 | return _fruIdentity; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * @brief Returns the PCE identity substructure |
| 183 | * |
| 184 | * @return const std::unique_ptr<PCEIdentity>& |
| 185 | */ |
| 186 | const std::unique_ptr<PCEIdentity>& pceIdentity() const |
| 187 | { |
| 188 | return _pceIdentity; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * @brief Returns the MRU identity substructure |
| 193 | * |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 194 | * @return const std::unique_ptr<MRU>& |
Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 195 | */ |
| 196 | const std::unique_ptr<MRU>& mru() const |
| 197 | { |
| 198 | return _mru; |
| 199 | } |
| 200 | |
| 201 | private: |
| 202 | /** |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 203 | * @brief Sets the location code field |
| 204 | * |
| 205 | * @param[in] locationCode - The location code string |
| 206 | */ |
| 207 | void setLocationCode(const std::string& locationCode); |
| 208 | |
| 209 | /** |
Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 210 | * @brief The size of this structure in the PEL |
| 211 | */ |
| 212 | uint8_t _size; |
| 213 | |
| 214 | /** |
| 215 | * @brief The flags byte of this structure |
| 216 | */ |
| 217 | uint8_t _flags; |
| 218 | |
| 219 | /** |
| 220 | * @brief The replacement priority |
| 221 | */ |
| 222 | uint8_t _priority; |
| 223 | |
| 224 | /** |
| 225 | * @brief The length of the location code field. |
| 226 | * |
| 227 | * Includes the NULL termination, and must be a |
| 228 | * multiple of 4 (padded with zeros) |
| 229 | */ |
Matt Spinler | 0a5d10c | 2020-03-13 12:54:02 -0500 | [diff] [blame] | 230 | uint8_t _locationCodeSize = 0; |
Matt Spinler | 6c9662c | 2019-10-09 11:27:20 -0500 | [diff] [blame] | 231 | |
| 232 | /** |
| 233 | * @brief NULL terminated location code |
| 234 | * |
| 235 | * Includes the NULL termination, and must be a |
| 236 | * multiple of 4 (padded with zeros) |
| 237 | */ |
| 238 | std::vector<char> _locationCode; |
| 239 | |
| 240 | /** |
| 241 | * @brief FRU (Field Replaceable Unit) Identity substructure |
| 242 | */ |
| 243 | std::unique_ptr<FRUIdentity> _fruIdentity; |
| 244 | |
| 245 | /** |
| 246 | * @brief PCE (Power Controlling Enclosure) Identity substructure |
| 247 | */ |
| 248 | std::unique_ptr<PCEIdentity> _pceIdentity; |
| 249 | |
| 250 | /** |
| 251 | * @brief MRU (Manufacturing Replaceable Unit) substructure |
| 252 | */ |
| 253 | std::unique_ptr<MRU> _mru; |
| 254 | }; |
| 255 | |
| 256 | } // namespace src |
| 257 | } // namespace pels |
| 258 | } // namespace openpower |