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: |
| 40 | PelMinimal() = delete; |
| 41 | ~PelMinimal() = default; |
| 42 | PelMinimal(const PelMinimal&) = delete; |
| 43 | PelMinimal& operator=(const PelMinimal&) = delete; |
| 44 | PelMinimal(PelMinimal&&) = delete; |
| 45 | PelMinimal& operator=(PelMinimal&&) = delete; |
| 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 | /** |
| 55 | * @brief Stream raw PEL data to buffer |
| 56 | * |
| 57 | * @param[out] pelBuffer - What the data will be written to |
| 58 | */ |
| 59 | void raw(std::vector<uint8_t>& pelBuffer) const; |
| 60 | |
| 61 | /** |
| 62 | * @brief Set the User Header subsystem field |
| 63 | * |
| 64 | * @param[in] subsystem - The subsystem value |
| 65 | */ |
| 66 | void setSubsystem(uint8_t subsystem); |
| 67 | |
| 68 | /** |
| 69 | * @brief Set the User Header severity field |
| 70 | * |
| 71 | * @param[in] severity - The severity to set |
| 72 | */ |
| 73 | void setSeverity(uint8_t severity); |
| 74 | |
| 75 | /** |
| 76 | * @brief Set the User Header event type field |
| 77 | * |
| 78 | * @param[in] type - The event type |
| 79 | */ |
| 80 | void setType(uint8_t type); |
| 81 | |
| 82 | /** |
| 83 | * @brief Set the User Header action flags field |
| 84 | * |
| 85 | * @param[in] action - The action flags to set |
| 86 | */ |
| 87 | void setAction(uint16_t action); |
| 88 | |
| 89 | /** |
| 90 | * @brief Set the Primary SRC section SRC words |
| 91 | * |
| 92 | * @param[in] srcWords - The SRC words |
| 93 | */ |
| 94 | void setSrcWords(std::array<uint32_t, numSrcWords> srcWords); |
| 95 | |
| 96 | /** |
| 97 | * @brief Set the Primary SRC section ascii string field |
| 98 | * |
| 99 | * @param[in] asciiString - The ascii string |
| 100 | */ |
| 101 | void setAsciiString(std::array<char, asciiStringSize> asciiString); |
| 102 | |
| 103 | /** |
| 104 | * @brief Get section count from the private header |
| 105 | * |
| 106 | * @return Number of sections |
| 107 | */ |
| 108 | uint8_t getSectionCount(); |
| 109 | |
| 110 | /** |
| 111 | * @brief Set section count in private heasder |
| 112 | * |
| 113 | * @param[in] sectionCount - Number of sections |
| 114 | */ |
| 115 | void setSectionCount(uint8_t sectionCount); |
| 116 | |
Ben Tyner | feeea83 | 2021-04-06 10:08:11 -0500 | [diff] [blame] | 117 | /** |
| 118 | * @brief Set the symptom id field in extended user header |
| 119 | * |
| 120 | * @param[in] symptomId - The symptom ID to set |
| 121 | */ |
| 122 | void setSymptomId(const std::string& symptomId); |
| 123 | |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 124 | private: |
| 125 | /** |
| 126 | * @brief Maximum PEL size |
| 127 | */ |
| 128 | static constexpr size_t _maxPELSize = 16384; |
| 129 | |
| 130 | /** |
| 131 | * @brief Returns the size of the PEL |
| 132 | * |
| 133 | * @return size_t The PEL size in bytes |
| 134 | */ |
| 135 | size_t size() const; |
| 136 | |
| 137 | /** |
| 138 | * @brief PEL Private Header |
| 139 | */ |
| 140 | std::unique_ptr<PrivateHeader> _ph; |
| 141 | |
| 142 | /** |
| 143 | * @brief PEL User Header |
| 144 | */ |
| 145 | std::unique_ptr<UserHeader> _uh; |
| 146 | |
| 147 | /** |
| 148 | * @brief PEL Primary SRC |
| 149 | */ |
| 150 | std::unique_ptr<PrimarySrc> _ps; |
Ben Tyner | feeea83 | 2021-04-06 10:08:11 -0500 | [diff] [blame] | 151 | |
| 152 | /** |
| 153 | * @brief PEL Extended User Header |
| 154 | */ |
| 155 | std::unique_ptr<ExtendedUserHeader> _eh; |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | } // namespace pel |
| 159 | } // namespace attn |