Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Ben Tyner | feeea83 | 2021-04-06 10:08:11 -0500 | [diff] [blame] | 3 | #include "extended_user_header.hpp" |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 4 | #include "pel_common.hpp" |
| 5 | #include "primary_src.hpp" |
| 6 | #include "private_header.hpp" |
| 7 | #include "user_header.hpp" |
| 8 | |
| 9 | #include <vector> |
| 10 | |
| 11 | namespace attn |
| 12 | { |
| 13 | namespace pel |
| 14 | { |
| 15 | |
| 16 | /** @class PelMinimal |
| 17 | * |
| 18 | * @brief Class for a minimal platform event log (PEL) |
| 19 | * |
| 20 | * This class can be used to create form a PEL and create a raw PEL file. The |
| 21 | * implementation based on "Platform Event Log and SRC PLDD v1.1" |
| 22 | * |
| 23 | * This PEL consists of the following position dependent sections: |
| 24 | * |
| 25 | * |----------+------------------------------| |
| 26 | * | length | section | |
| 27 | * |----------+------------------------------| |
| 28 | * | 48 | Private Header Section | |
| 29 | * |----------+------------------------------| |
| 30 | * | 24 | User Header Section | |
| 31 | * |----------+------------------------------| |
| 32 | * | 72 | Primary SRC Section | |
| 33 | * |----------+------------------------------| |
Ben Tyner | feeea83 | 2021-04-06 10:08:11 -0500 | [diff] [blame] | 34 | * | 20 | Extended User Header | |
| 35 | * |----------+------------------------------| |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 36 | */ |
| 37 | class PelMinimal |
| 38 | { |
| 39 | public: |
Patrick Williams | 27dd636 | 2023-05-10 07:51:20 -0500 | [diff] [blame^] | 40 | PelMinimal() = delete; |
| 41 | ~PelMinimal() = default; |
| 42 | PelMinimal(const PelMinimal&) = delete; |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 43 | PelMinimal& operator=(const PelMinimal&) = delete; |
Patrick Williams | 27dd636 | 2023-05-10 07:51:20 -0500 | [diff] [blame^] | 44 | PelMinimal(PelMinimal&&) = delete; |
| 45 | PelMinimal& operator=(PelMinimal&&) = delete; |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 46 | |
| 47 | /** |
| 48 | * @brief Create a minimal PEL object from raw data |
| 49 | * |
| 50 | * @param[in] pelBuffer - buffer containing a raw PEL |
| 51 | */ |
Ben Tyner | dc5b0ff | 2021-01-14 14:01:39 -0600 | [diff] [blame] | 52 | explicit PelMinimal(std::vector<uint8_t>& data); |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 53 | |
| 54 | /** |
austinfcui | 9e4d190 | 2022-02-22 11:03:49 -0600 | [diff] [blame] | 55 | * @brief Initialize the object's data members |
| 56 | * |
| 57 | * @param[in] data - reference to the vector |
| 58 | */ |
| 59 | void initialize(std::vector<uint8_t>& data); |
| 60 | |
| 61 | /** |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 62 | * @brief Stream raw PEL data to buffer |
| 63 | * |
| 64 | * @param[out] pelBuffer - What the data will be written to |
| 65 | */ |
| 66 | void raw(std::vector<uint8_t>& pelBuffer) const; |
| 67 | |
| 68 | /** |
| 69 | * @brief Set the User Header subsystem field |
| 70 | * |
| 71 | * @param[in] subsystem - The subsystem value |
| 72 | */ |
| 73 | void setSubsystem(uint8_t subsystem); |
| 74 | |
| 75 | /** |
| 76 | * @brief Set the User Header severity field |
| 77 | * |
| 78 | * @param[in] severity - The severity to set |
| 79 | */ |
| 80 | void setSeverity(uint8_t severity); |
| 81 | |
| 82 | /** |
| 83 | * @brief Set the User Header event type field |
| 84 | * |
| 85 | * @param[in] type - The event type |
| 86 | */ |
| 87 | void setType(uint8_t type); |
| 88 | |
| 89 | /** |
| 90 | * @brief Set the User Header action flags field |
| 91 | * |
| 92 | * @param[in] action - The action flags to set |
| 93 | */ |
| 94 | void setAction(uint16_t action); |
| 95 | |
| 96 | /** |
| 97 | * @brief Set the Primary SRC section SRC words |
| 98 | * |
| 99 | * @param[in] srcWords - The SRC words |
| 100 | */ |
| 101 | void setSrcWords(std::array<uint32_t, numSrcWords> srcWords); |
| 102 | |
| 103 | /** |
| 104 | * @brief Set the Primary SRC section ascii string field |
| 105 | * |
| 106 | * @param[in] asciiString - The ascii string |
| 107 | */ |
| 108 | void setAsciiString(std::array<char, asciiStringSize> asciiString); |
| 109 | |
| 110 | /** |
| 111 | * @brief Get section count from the private header |
| 112 | * |
| 113 | * @return Number of sections |
| 114 | */ |
| 115 | uint8_t getSectionCount(); |
| 116 | |
| 117 | /** |
| 118 | * @brief Set section count in private heasder |
| 119 | * |
| 120 | * @param[in] sectionCount - Number of sections |
| 121 | */ |
| 122 | void setSectionCount(uint8_t sectionCount); |
| 123 | |
Ben Tyner | feeea83 | 2021-04-06 10:08:11 -0500 | [diff] [blame] | 124 | /** |
| 125 | * @brief Set the symptom id field in extended user header |
| 126 | * |
| 127 | * @param[in] symptomId - The symptom ID to set |
| 128 | */ |
| 129 | void setSymptomId(const std::string& symptomId); |
| 130 | |
Ben Tyner | 135793a | 2021-10-27 09:18:41 -0500 | [diff] [blame] | 131 | /** |
| 132 | * @brief Update the PLID |
| 133 | */ |
| 134 | void setPlid(uint32_t plid); |
| 135 | |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 136 | private: |
| 137 | /** |
| 138 | * @brief Maximum PEL size |
| 139 | */ |
| 140 | static constexpr size_t _maxPELSize = 16384; |
| 141 | |
| 142 | /** |
| 143 | * @brief Returns the size of the PEL |
| 144 | * |
| 145 | * @return size_t The PEL size in bytes |
| 146 | */ |
| 147 | size_t size() const; |
| 148 | |
| 149 | /** |
| 150 | * @brief PEL Private Header |
| 151 | */ |
| 152 | std::unique_ptr<PrivateHeader> _ph; |
| 153 | |
| 154 | /** |
| 155 | * @brief PEL User Header |
| 156 | */ |
| 157 | std::unique_ptr<UserHeader> _uh; |
| 158 | |
| 159 | /** |
| 160 | * @brief PEL Primary SRC |
| 161 | */ |
| 162 | std::unique_ptr<PrimarySrc> _ps; |
Ben Tyner | feeea83 | 2021-04-06 10:08:11 -0500 | [diff] [blame] | 163 | |
| 164 | /** |
| 165 | * @brief PEL Extended User Header |
| 166 | */ |
| 167 | std::unique_ptr<ExtendedUserHeader> _eh; |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | } // namespace pel |
| 171 | } // namespace attn |