Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Matt Spinler | b832363 | 2019-09-20 15:11:04 -0500 | [diff] [blame] | 3 | #include "additional_data.hpp" |
Matt Spinler | aa65947 | 2019-10-23 09:26:48 -0500 | [diff] [blame] | 4 | #include "data_interface.hpp" |
Matt Spinler | 9d92109 | 2022-12-15 11:54:49 -0600 | [diff] [blame] | 5 | #include "journal.hpp" |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 6 | #include "private_header.hpp" |
Matt Spinler | b832363 | 2019-09-20 15:11:04 -0500 | [diff] [blame] | 7 | #include "registry.hpp" |
Matt Spinler | bd716f0 | 2019-10-15 10:54:11 -0500 | [diff] [blame] | 8 | #include "src.hpp" |
Matt Spinler | afa857c | 2019-10-24 13:03:46 -0500 | [diff] [blame] | 9 | #include "user_data.hpp" |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 10 | #include "user_data_formats.hpp" |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 11 | #include "user_header.hpp" |
| 12 | |
| 13 | #include <memory> |
| 14 | #include <vector> |
| 15 | |
| 16 | namespace openpower |
| 17 | { |
| 18 | namespace pels |
| 19 | { |
| 20 | |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 21 | /** |
| 22 | * @brief Contains information about an FFDC file. |
| 23 | */ |
| 24 | struct PelFFDCfile |
| 25 | { |
| 26 | UserDataFormat format; |
| 27 | uint8_t subType; |
| 28 | uint8_t version; |
| 29 | int fd; |
| 30 | }; |
| 31 | |
| 32 | using PelFFDC = std::vector<PelFFDCfile>; |
Arya K Padman | d8ae618 | 2024-07-19 06:25:10 -0500 | [diff] [blame] | 33 | using DebugData = std::map<std::string, std::vector<std::string>>; |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 34 | |
Jayanth Othayoth | 1ddf1e8 | 2021-06-04 09:00:54 -0500 | [diff] [blame] | 35 | constexpr uint8_t jsonCalloutSubtype = 0xCA; |
| 36 | |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 37 | /** @class PEL |
| 38 | * |
| 39 | * @brief This class represents a specific event log format referred to as a |
| 40 | * Platform Event Log. |
| 41 | * |
| 42 | * Every field in a PEL are in structures call sections, of which there are |
| 43 | * several types. Some sections are required, and some are optional. In some |
| 44 | * cases there may be more than one instance of a section type. |
| 45 | * |
| 46 | * The only two required sections for every type of PEL are the Private Header |
| 47 | * section and User Header section, which must be in the first and second |
| 48 | * positions, respectively. |
| 49 | * |
| 50 | * Every section starts with an 8 byte section header, which has the section |
| 51 | * size and type, among other things. |
| 52 | * |
| 53 | * This class represents all sections with objects. |
| 54 | * |
Matt Spinler | bd716f0 | 2019-10-15 10:54:11 -0500 | [diff] [blame] | 55 | * The class can be constructed: |
| 56 | * - From a full formed flattened PEL. |
| 57 | * - From scratch based on an OpenBMC event and its corresponding PEL message |
| 58 | * registry entry. |
Matt Spinler | b832363 | 2019-09-20 15:11:04 -0500 | [diff] [blame] | 59 | * |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 60 | * The data() method allows one to retrieve the PEL as a vector<uint8_t>. This |
| 61 | * is the format in which it is stored and transmitted. |
| 62 | */ |
| 63 | class PEL |
| 64 | { |
| 65 | public: |
| 66 | PEL() = delete; |
| 67 | ~PEL() = default; |
| 68 | PEL(const PEL&) = delete; |
| 69 | PEL& operator=(const PEL&) = delete; |
| 70 | PEL(PEL&&) = delete; |
| 71 | PEL& operator=(PEL&&) = delete; |
| 72 | |
| 73 | /** |
| 74 | * @brief Constructor |
| 75 | * |
| 76 | * Build a PEL from raw data. |
| 77 | * |
Matt Spinler | 07eefc5 | 2019-09-26 11:18:26 -0500 | [diff] [blame] | 78 | * Note: Neither this nor the following constructor can take a const vector& |
| 79 | * because the Stream class that is used to read from the vector cannot take |
| 80 | * a const. The alternative is to make a copy of the data, but as PELs can |
| 81 | * be up to 16KB that is undesireable. |
| 82 | * |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 83 | * @param[in] data - The PEL data |
| 84 | */ |
Matt Spinler | 45796e8 | 2022-07-01 11:25:27 -0500 | [diff] [blame] | 85 | explicit PEL(std::vector<uint8_t>& data); |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 86 | |
| 87 | /** |
| 88 | * @brief Constructor |
| 89 | * |
| 90 | * Build a PEL from the raw data. |
| 91 | * |
| 92 | * @param[in] data - the PEL data |
| 93 | * @param[in] obmcLogID - the corresponding OpenBMC event log ID |
| 94 | */ |
Matt Spinler | 07eefc5 | 2019-09-26 11:18:26 -0500 | [diff] [blame] | 95 | PEL(std::vector<uint8_t>& data, uint32_t obmcLogID); |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 96 | |
| 97 | /** |
Matt Spinler | b832363 | 2019-09-20 15:11:04 -0500 | [diff] [blame] | 98 | * @brief Constructor |
| 99 | * |
| 100 | * Creates a PEL from an OpenBMC event log and its message |
| 101 | * registry entry. |
| 102 | * |
| 103 | * @param[in] entry - The message registry entry for this error |
| 104 | * @param[in] obmcLogID - ID of corresponding OpenBMC event log |
| 105 | * @param[in] timestamp - Timestamp from the event log |
| 106 | * @param[in] severity - Severity from the event log |
Matt Spinler | bd716f0 | 2019-10-15 10:54:11 -0500 | [diff] [blame] | 107 | * @param[in] additionalData - The AdditionalData contents |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 108 | * @param[in] ffdcFiles - FFCD files that go into UserData sections |
Matt Spinler | aa65947 | 2019-10-23 09:26:48 -0500 | [diff] [blame] | 109 | * @param[in] dataIface - The data interface object |
Matt Spinler | 9d92109 | 2022-12-15 11:54:49 -0600 | [diff] [blame] | 110 | * @param[in] journal - The journal object |
Matt Spinler | b832363 | 2019-09-20 15:11:04 -0500 | [diff] [blame] | 111 | */ |
| 112 | PEL(const openpower::pels::message::Entry& entry, uint32_t obmcLogID, |
Matt Spinler | bd716f0 | 2019-10-15 10:54:11 -0500 | [diff] [blame] | 113 | uint64_t timestamp, phosphor::logging::Entry::Level severity, |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 114 | const AdditionalData& additionalData, const PelFFDC& ffdcFiles, |
Matt Spinler | 9d92109 | 2022-12-15 11:54:49 -0600 | [diff] [blame] | 115 | const DataInterfaceBase& dataIface, const JournalBase& journal); |
Matt Spinler | b832363 | 2019-09-20 15:11:04 -0500 | [diff] [blame] | 116 | |
| 117 | /** |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 118 | * @brief Convenience function to return the log ID field from the |
| 119 | * Private Header section. |
| 120 | * |
| 121 | * @return uint32_t - the ID |
| 122 | */ |
| 123 | uint32_t id() const |
| 124 | { |
| 125 | return _ph->id(); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * @brief Convenience function to return the PLID field from the |
| 130 | * Private Header section. |
| 131 | * |
| 132 | * @return uint32_t - the PLID |
| 133 | */ |
| 134 | uint32_t plid() const |
| 135 | { |
| 136 | return _ph->plid(); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * @brief Convenience function to return the OpenBMC event log ID field |
| 141 | * from the Private Header section. |
| 142 | * |
| 143 | * @return uint32_t - the OpenBMC event log ID |
| 144 | */ |
| 145 | uint32_t obmcLogID() const |
| 146 | { |
| 147 | return _ph->obmcLogID(); |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * @brief Convenience function to return the commit time field from |
| 152 | * the Private Header section. |
| 153 | * |
| 154 | * @return BCDTime - the timestamp |
| 155 | */ |
| 156 | BCDTime commitTime() const |
| 157 | { |
| 158 | return _ph->commitTimestamp(); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * @brief Convenience function to return the create time field from |
| 163 | * the Private Header section. |
| 164 | * |
| 165 | * @return BCDTime - the timestamp |
| 166 | */ |
| 167 | BCDTime createTime() const |
| 168 | { |
| 169 | return _ph->createTimestamp(); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * @brief Gives access to the Private Header section class |
| 174 | * |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 175 | * @return const PrivateHeader& - the private header |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 176 | */ |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 177 | const PrivateHeader& privateHeader() const |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 178 | { |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 179 | return *_ph; |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | /** |
| 183 | * @brief Gives access to the User Header section class |
| 184 | * |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 185 | * @return const UserHeader& - the user header |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 186 | */ |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 187 | const UserHeader& userHeader() const |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 188 | { |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 189 | return *_uh; |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | /** |
Matt Spinler | bd716f0 | 2019-10-15 10:54:11 -0500 | [diff] [blame] | 193 | * @brief Gives access to the primary SRC's section class |
| 194 | * |
| 195 | * This is technically an optional section, so the return |
| 196 | * value is an std::optional<SRC*>. |
| 197 | * |
| 198 | * @return std::optional<SRC*> - the SRC section object |
| 199 | */ |
| 200 | std::optional<SRC*> primarySRC() const; |
| 201 | |
| 202 | /** |
Matt Spinler | 131870c | 2019-09-25 13:29:04 -0500 | [diff] [blame] | 203 | * @brief Returns the optional sections, which is everything but |
| 204 | * the Private and User Headers. |
| 205 | * |
| 206 | * @return const std::vector<std::unique_ptr<Section>>& |
| 207 | */ |
| 208 | const std::vector<std::unique_ptr<Section>>& optionalSections() const |
| 209 | { |
| 210 | return _optionalSections; |
| 211 | } |
| 212 | |
| 213 | /** |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 214 | * @brief Returns the PEL data. |
| 215 | * |
| 216 | * @return std::vector<uint8_t> - the raw PEL data |
| 217 | */ |
Matt Spinler | 0688545 | 2019-11-06 10:35:42 -0600 | [diff] [blame] | 218 | std::vector<uint8_t> data() const; |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 219 | |
| 220 | /** |
Matt Spinler | f1b46ff | 2020-01-22 14:10:04 -0600 | [diff] [blame] | 221 | * @brief Returns the size of the PEL |
| 222 | * |
| 223 | * @return size_t The PEL size in bytes |
| 224 | */ |
| 225 | size_t size() const; |
| 226 | |
| 227 | /** |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 228 | * @brief Says if the PEL is valid (the sections are all valid) |
| 229 | * |
| 230 | * @return bool - if the PEL is valid |
| 231 | */ |
| 232 | bool valid() const; |
| 233 | |
| 234 | /** |
| 235 | * @brief Sets the commit timestamp to the current time |
| 236 | */ |
| 237 | void setCommitTime(); |
| 238 | |
| 239 | /** |
| 240 | * @brief Sets the error log ID field to a unique ID. |
| 241 | */ |
| 242 | void assignID(); |
| 243 | |
Aatir | 186ce8c | 2019-10-20 15:13:39 -0500 | [diff] [blame] | 244 | /** |
| 245 | * @brief Output a PEL in JSON. |
Harisuddin Mohamed Isa | a214ed3 | 2020-02-28 15:58:23 +0800 | [diff] [blame] | 246 | * @param[in] registry - Registry object reference |
Harisuddin Mohamed Isa | f67bafd | 2020-07-06 17:51:21 +0800 | [diff] [blame] | 247 | * @param[in] plugins - Vector of strings of plugins found in filesystem |
Aatir | 186ce8c | 2019-10-20 15:13:39 -0500 | [diff] [blame] | 248 | */ |
Harisuddin Mohamed Isa | f67bafd | 2020-07-06 17:51:21 +0800 | [diff] [blame] | 249 | void toJSON(message::Registry& registry, |
| 250 | const std::vector<std::string>& plugins) const; |
Aatir | 186ce8c | 2019-10-20 15:13:39 -0500 | [diff] [blame] | 251 | |
Matt Spinler | f38ce98 | 2019-11-07 13:25:53 -0600 | [diff] [blame] | 252 | /** |
| 253 | * @brief Sets the host transmission state in the User Header |
| 254 | * |
| 255 | * @param[in] state - The state value |
| 256 | */ |
| 257 | void setHostTransmissionState(TransmissionState state) |
| 258 | { |
| 259 | _uh->setHostTransmissionState(static_cast<uint8_t>(state)); |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * @brief Returns the host transmission state |
| 264 | * |
| 265 | * @return HostTransmissionState - The state |
| 266 | */ |
| 267 | TransmissionState hostTransmissionState() const |
| 268 | { |
| 269 | return static_cast<TransmissionState>(_uh->hostTransmissionState()); |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * @brief Sets the HMC transmission state in the User Header |
| 274 | * |
| 275 | * @param[in] state - The state value |
| 276 | */ |
| 277 | void setHMCTransmissionState(TransmissionState state) |
| 278 | { |
| 279 | _uh->setHMCTransmissionState(static_cast<uint8_t>(state)); |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * @brief Returns the HMC transmission state |
| 284 | * |
| 285 | * @return HMCTransmissionState - The state |
| 286 | */ |
| 287 | TransmissionState hmcTransmissionState() const |
| 288 | { |
| 289 | return static_cast<TransmissionState>(_uh->hmcTransmissionState()); |
| 290 | } |
| 291 | |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 292 | /** |
Andrew Geissler | f8e750d | 2022-01-14 14:56:13 -0600 | [diff] [blame] | 293 | * @brief Returns true if a hardware callout is present in the primary SRC |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 294 | * |
Andrew Geissler | f8e750d | 2022-01-14 14:56:13 -0600 | [diff] [blame] | 295 | * @return true if hardware callout present, false otherwise |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 296 | */ |
Andrew Geissler | f8e750d | 2022-01-14 14:56:13 -0600 | [diff] [blame] | 297 | bool isHwCalloutPresent() const; |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 298 | |
Sumit Kumar | 3160a54 | 2021-04-26 08:07:04 -0500 | [diff] [blame] | 299 | /** |
| 300 | * @brief Updates the system info data into HB extended user |
| 301 | * data section to this PEL object |
| 302 | * |
| 303 | * @param[in] dataIface - The data interface object |
| 304 | */ |
| 305 | void updateSysInfoInExtendedUserDataSection( |
| 306 | const DataInterfaceBase& dataIface); |
| 307 | |
Matt Spinler | 8e65f4e | 2023-05-02 13:40:08 -0500 | [diff] [blame] | 308 | /** |
| 309 | * @brief Return the deconfig flag from hex data word 5 of BMC and |
| 310 | * hostboot PELs. |
| 311 | * |
| 312 | * This only applies to BMC and hostboot PELs because only those |
| 313 | * SRC formats have this flag defined. |
| 314 | * |
| 315 | * @return bool - If the 'one or more resources are deconfigured' |
| 316 | * flag is set. |
| 317 | */ |
| 318 | bool getDeconfigFlag() const; |
| 319 | |
| 320 | /** |
| 321 | * @brief Return the guard flag from hex data word 5 of BMC and |
| 322 | * hostboot PELs. |
| 323 | * |
| 324 | * This only applies to BMC and hostboot PELs because only those |
| 325 | * SRC formats have this flag defined. |
| 326 | * |
| 327 | * @return bool - If the 'one or more resources are guarded' |
| 328 | * flag is set. |
| 329 | */ |
| 330 | bool getGuardFlag() const; |
| 331 | |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 332 | private: |
| 333 | /** |
| 334 | * @brief Builds the section objects from a PEL data buffer |
| 335 | * |
Matt Spinler | 07eefc5 | 2019-09-26 11:18:26 -0500 | [diff] [blame] | 336 | * Note: The data parameter cannot be const for the same reasons |
| 337 | * as listed in the constructor. |
| 338 | * |
| 339 | * @param[in] data - The PEL data |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 340 | * @param[in] obmcLogID - The OpenBMC event log ID to use for that |
| 341 | * field in the Private Header. |
| 342 | */ |
Matt Spinler | 07eefc5 | 2019-09-26 11:18:26 -0500 | [diff] [blame] | 343 | void populateFromRawData(std::vector<uint8_t>& data, uint32_t obmcLogID); |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 344 | |
| 345 | /** |
| 346 | * @brief Flattens the PEL objects into the buffer |
| 347 | * |
| 348 | * @param[out] pelBuffer - What the data will be written to |
| 349 | */ |
Matt Spinler | 0688545 | 2019-11-06 10:35:42 -0600 | [diff] [blame] | 350 | void flatten(std::vector<uint8_t>& pelBuffer) const; |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 351 | |
| 352 | /** |
Matt Spinler | f1e85e2 | 2019-11-01 11:31:31 -0500 | [diff] [blame] | 353 | * @brief Check that the PEL fields that need to be in agreement |
| 354 | * with each other are, and fix them up if necessary. |
| 355 | */ |
| 356 | void checkRulesAndFix(); |
| 357 | |
| 358 | /** |
Matt Spinler | acb7c10 | 2020-01-10 13:49:22 -0600 | [diff] [blame] | 359 | * @brief Returns a map of the section IDs that appear more than once |
| 360 | * in the PEL. The data value for each entry will be set to 0. |
| 361 | * |
| 362 | * @return std::map<uint16_t, size_t> |
| 363 | */ |
| 364 | std::map<uint16_t, size_t> getPluralSections() const; |
| 365 | |
| 366 | /** |
Matt Spinler | 85f61a6 | 2020-06-03 16:28:55 -0500 | [diff] [blame] | 367 | * @brief Adds the UserData section to this PEL object, |
| 368 | * shrinking it if necessary |
| 369 | * |
| 370 | * @param[in] userData - The section to add |
| 371 | * |
| 372 | * @return bool - If the section was added or not. |
| 373 | */ |
| 374 | bool addUserDataSection(std::unique_ptr<UserData> userData); |
| 375 | |
| 376 | /** |
| 377 | * @brief helper function for printing PELs. |
| 378 | * @param[in] Section& - section object reference |
| 379 | * @param[in] std::string - PEL string |
| 380 | * @param[in|out] pluralSections - Map used to track sections counts for |
| 381 | * when there is more than 1. |
| 382 | * @param[in] registry - Registry object reference |
Harisuddin Mohamed Isa | f67bafd | 2020-07-06 17:51:21 +0800 | [diff] [blame] | 383 | * @param[in] plugins - Vector of strings of plugins found in filesystem |
| 384 | * @param[in] creatorID - Creator Subsystem ID (only for UserData section) |
Matt Spinler | 85f61a6 | 2020-06-03 16:28:55 -0500 | [diff] [blame] | 385 | */ |
Patrick Williams | 075c792 | 2024-08-16 15:19:49 -0400 | [diff] [blame] | 386 | void printSectionInJSON( |
| 387 | const Section& section, std::string& buf, |
| 388 | std::map<uint16_t, size_t>& pluralSections, message::Registry& registry, |
| 389 | const std::vector<std::string>& plugins, uint8_t creatorID = 0) const; |
Matt Spinler | 85f61a6 | 2020-06-03 16:28:55 -0500 | [diff] [blame] | 390 | |
| 391 | /** |
Matt Spinler | 5a90a95 | 2020-08-27 09:39:03 -0500 | [diff] [blame] | 392 | * @brief Returns any callout JSON found in the FFDC files. |
| 393 | * |
| 394 | * Looks for an FFDC file that is JSON format and has the |
| 395 | * sub-type value set to 0xCA and returns its data as a JSON object. |
| 396 | * |
| 397 | * @param[in] ffdcFiles - FFCD files that go into UserData sections |
| 398 | * |
| 399 | * @return json - The callout JSON, or an empty object if not found |
| 400 | */ |
| 401 | nlohmann::json getCalloutJSON(const PelFFDC& ffdcFiles); |
| 402 | |
| 403 | /** |
Sumit Kumar | 3e27443 | 2021-09-14 06:37:56 -0500 | [diff] [blame] | 404 | * @brief Update terminate bit in primary SRC section to this PEL object is |
| 405 | * severity set to 0x51 = critical error, system termination |
| 406 | */ |
| 407 | void updateTerminateBitInSRCSection(); |
| 408 | |
| 409 | /** |
Matt Spinler | 9d92109 | 2022-12-15 11:54:49 -0600 | [diff] [blame] | 410 | * @brief Adds journal data to the PEL as UserData sections |
| 411 | * if specified to in the message registry. |
| 412 | * |
| 413 | * @param regEntry - The registry entry |
| 414 | * @param journal - The journal object |
| 415 | */ |
| 416 | void addJournalSections(const message::Entry& regEntry, |
| 417 | const JournalBase& journal); |
| 418 | |
| 419 | /** |
Arya K Padman | d8ae618 | 2024-07-19 06:25:10 -0500 | [diff] [blame] | 420 | * @brief API to collect the addditional details of the DIMM callouts in |
| 421 | * the PEL as a JSON object in adSysInfoData. |
| 422 | * |
| 423 | * @param[in] src - Unique pointer to the SRC object |
| 424 | * @param[in] dataIface - The data interface object |
| 425 | * @param[out] adSysInfoData - The additional data to SysInfo in json format |
| 426 | * @param[out] debugData - The map of string and vector of string to store |
| 427 | * the debug data if any. |
| 428 | */ |
| 429 | void addAdDetailsForDIMMsCallout( |
| 430 | const std::unique_ptr<SRC>& src, const DataInterfaceBase& dataIface, |
| 431 | nlohmann::json& adSysInfoData, DebugData& debugData); |
| 432 | |
| 433 | /** |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 434 | * @brief The PEL Private Header section |
| 435 | */ |
| 436 | std::unique_ptr<PrivateHeader> _ph; |
| 437 | |
| 438 | /** |
| 439 | * @brief The PEL User Header section |
| 440 | */ |
| 441 | std::unique_ptr<UserHeader> _uh; |
| 442 | |
| 443 | /** |
Matt Spinler | 131870c | 2019-09-25 13:29:04 -0500 | [diff] [blame] | 444 | * @brief Holds all sections by the PH and UH. |
| 445 | */ |
| 446 | std::vector<std::unique_ptr<Section>> _optionalSections; |
Aatir | 186ce8c | 2019-10-20 15:13:39 -0500 | [diff] [blame] | 447 | |
| 448 | /** |
Matt Spinler | 6d66382 | 2020-01-22 14:50:46 -0600 | [diff] [blame] | 449 | * @brief The maximum size a PEL can be in bytes. |
| 450 | */ |
| 451 | static constexpr size_t _maxPELSize = 16384; |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 452 | }; |
| 453 | |
Matt Spinler | afa857c | 2019-10-24 13:03:46 -0500 | [diff] [blame] | 454 | namespace util |
| 455 | { |
| 456 | |
| 457 | /** |
Matt Spinler | 85f61a6 | 2020-06-03 16:28:55 -0500 | [diff] [blame] | 458 | * @brief Creates a UserData section object that contains JSON. |
| 459 | * |
| 460 | * @param[in] json - The JSON contents |
| 461 | * |
| 462 | * @return std::unique_ptr<UserData> - The UserData object |
| 463 | */ |
| 464 | std::unique_ptr<UserData> makeJSONUserDataSection(const nlohmann::json& json); |
| 465 | |
| 466 | /** |
Matt Spinler | afa857c | 2019-10-24 13:03:46 -0500 | [diff] [blame] | 467 | * @brief Create a UserData section containing the AdditionalData |
| 468 | * contents as a JSON string. |
| 469 | * |
| 470 | * @param[in] ad - The AdditionalData contents |
| 471 | * |
| 472 | * @return std::unique_ptr<UserData> - The section |
| 473 | */ |
| 474 | std::unique_ptr<UserData> makeADUserDataSection(const AdditionalData& ad); |
| 475 | |
Matt Spinler | 4dcd3f4 | 2020-01-22 14:55:07 -0600 | [diff] [blame] | 476 | /** |
| 477 | * @brief Create a UserData section containing various useful pieces |
| 478 | * of system information as a JSON string. |
| 479 | * |
| 480 | * @param[in] ad - The AdditionalData contents |
| 481 | * @param[in] dataIface - The data interface object |
George Liu | 9ac0d9b | 2022-07-15 10:57:38 +0800 | [diff] [blame] | 482 | * @param[in] addUptime - Whether to add the uptime attribute the default is |
| 483 | * true |
Arya K Padman | d8ae618 | 2024-07-19 06:25:10 -0500 | [diff] [blame] | 484 | * @param[in] adSysInfoData - The additional data to SysInfo in json format. |
| 485 | * Default value will be empty. |
Matt Spinler | 4dcd3f4 | 2020-01-22 14:55:07 -0600 | [diff] [blame] | 486 | * |
| 487 | * @return std::unique_ptr<UserData> - The section |
| 488 | */ |
Patrick Williams | 075c792 | 2024-08-16 15:19:49 -0400 | [diff] [blame] | 489 | std::unique_ptr<UserData> makeSysInfoUserDataSection( |
| 490 | const AdditionalData& ad, const DataInterfaceBase& dataIface, |
Arya K Padman | d8ae618 | 2024-07-19 06:25:10 -0500 | [diff] [blame] | 491 | bool addUptime = true, |
| 492 | const nlohmann::json& adSysInfoData = |
| 493 | nlohmann::json(nlohmann::json::value_t::object)); |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 494 | |
| 495 | /** |
Matt Spinler | 5a90a95 | 2020-08-27 09:39:03 -0500 | [diff] [blame] | 496 | * @brief Reads data from an opened file descriptor. |
| 497 | * |
| 498 | * @param[in] fd - The FD to read from |
| 499 | * |
| 500 | * @return std::vector<uint8_t> - The data read |
| 501 | */ |
| 502 | std::vector<uint8_t> readFD(int fd); |
| 503 | |
| 504 | /** |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 505 | * @brief Create a UserData section that contains the data in the file |
| 506 | * pointed to by the file descriptor passed in. |
| 507 | * |
| 508 | * @param[in] componentID - The component ID of the PEL creator |
| 509 | * @param[in] file - The FFDC file information |
| 510 | */ |
Patrick Williams | 075c792 | 2024-08-16 15:19:49 -0400 | [diff] [blame] | 511 | std::unique_ptr<UserData> |
| 512 | makeFFDCuserDataSection(uint16_t componentID, const PelFFDCfile& file); |
Matt Spinler | 9d92109 | 2022-12-15 11:54:49 -0600 | [diff] [blame] | 513 | |
| 514 | /** |
Arya K Padman | d8ae618 | 2024-07-19 06:25:10 -0500 | [diff] [blame] | 515 | * @brief To create JSON object with the given location code and the hex |
| 516 | * converted value of the given DI property. |
| 517 | * |
| 518 | * @param[in] locationCode - The location code of the DIMM |
| 519 | * @param[in] diPropVal - The DI property value of the DIMM |
| 520 | * @param[out] adSysInfoData - Holds the created JSON object |
| 521 | */ |
| 522 | |
| 523 | void addDIMMInfo(const std::string& locationCode, |
| 524 | const std::vector<std::uint8_t>& diPropVal, |
| 525 | nlohmann::json& adSysInfoData); |
| 526 | |
| 527 | /** |
Matt Spinler | 9d92109 | 2022-12-15 11:54:49 -0600 | [diff] [blame] | 528 | * @brief Flattens a vector of strings into a vector of bytes suitable |
| 529 | * for storing in a PEL section. |
| 530 | * |
| 531 | * Adds a newline character after each string. |
| 532 | * |
| 533 | * @param lines - The vector of strings to convert |
| 534 | * |
| 535 | * @return std::vector<uint8_t> - The flattened data |
| 536 | */ |
| 537 | std::vector<uint8_t> flattenLines(const std::vector<std::string>& lines); |
| 538 | |
Matt Spinler | afa857c | 2019-10-24 13:03:46 -0500 | [diff] [blame] | 539 | } // namespace util |
| 540 | |
Matt Spinler | cb6b059 | 2019-07-16 15:58:51 -0500 | [diff] [blame] | 541 | } // namespace pels |
| 542 | } // namespace openpower |