Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Matt Spinler | fdb6a20 | 2019-09-20 14:09:20 -0500 | [diff] [blame] | 3 | #include "elog_entry.hpp" |
| 4 | #include "registry.hpp" |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 5 | #include "section.hpp" |
| 6 | #include "stream.hpp" |
| 7 | |
| 8 | namespace openpower |
| 9 | { |
| 10 | namespace pels |
| 11 | { |
| 12 | |
Matt Spinler | 1a94cc3 | 2019-09-11 13:32:12 -0500 | [diff] [blame] | 13 | static constexpr uint8_t userHeaderVersion = 0x01; |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 14 | |
| 15 | /** |
| 16 | * @class UserHeader |
| 17 | * |
| 18 | * This represents the User Header section in a PEL. It is required, |
| 19 | * and it is always the second section. |
| 20 | * |
| 21 | * The Section base class handles the section header structure that every |
| 22 | * PEL section has at offset zero. |
| 23 | * |
| 24 | * The fields in this class directly correspond to the order and sizes of |
| 25 | * the fields in the section. |
| 26 | */ |
| 27 | class UserHeader : public Section |
| 28 | { |
| 29 | public: |
| 30 | UserHeader() = delete; |
| 31 | ~UserHeader() = default; |
| 32 | UserHeader(const UserHeader&) = default; |
| 33 | UserHeader& operator=(const UserHeader&) = default; |
| 34 | UserHeader(UserHeader&&) = default; |
| 35 | UserHeader& operator=(UserHeader&&) = default; |
| 36 | |
| 37 | /** |
| 38 | * @brief Constructor |
| 39 | * |
Matt Spinler | fdb6a20 | 2019-09-20 14:09:20 -0500 | [diff] [blame] | 40 | * Creates a valid UserHeader with the passed in data. |
| 41 | * |
| 42 | * @param[in] entry - The message registry entry for this error |
| 43 | * @param[in] severity - The OpenBMC event log severity for this error |
| 44 | */ |
| 45 | UserHeader(const message::Entry& entry, |
| 46 | phosphor::logging::Entry::Level severity); |
| 47 | |
| 48 | /** |
| 49 | * @brief Constructor |
| 50 | * |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 51 | * Fills in this class's data fields from the stream. |
| 52 | * |
| 53 | * @param[in] pel - the PEL data stream |
| 54 | */ |
| 55 | explicit UserHeader(Stream& pel); |
| 56 | |
| 57 | /** |
Matt Spinler | cf5a8d0 | 2019-09-05 12:58:53 -0500 | [diff] [blame] | 58 | * @brief Flatten the section into the stream |
| 59 | * |
| 60 | * @param[in] stream - The stream to write to |
| 61 | */ |
| 62 | void flatten(Stream& stream) override; |
| 63 | |
| 64 | /** |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 65 | * @brief Returns the subsystem field. |
| 66 | * |
| 67 | * @return uint8_t& - the subsystem |
| 68 | */ |
| 69 | uint8_t& subsystem() |
| 70 | { |
| 71 | return _eventSubsystem; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * @brief Returns the event scope field. |
| 76 | * |
| 77 | * @return uint8_t& - the event scope |
| 78 | */ |
| 79 | uint8_t& scope() |
| 80 | { |
| 81 | return _eventScope; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @brief Returns the severity field. |
| 86 | * |
| 87 | * @return uint8_t& - the severity |
| 88 | */ |
| 89 | uint8_t& severity() |
| 90 | { |
| 91 | return _eventSeverity; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @brief Returns the event type field. |
| 96 | * |
| 97 | * @return uint8_t& - the event type |
| 98 | */ |
| 99 | uint8_t& eventType() |
| 100 | { |
| 101 | return _eventType; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * @brief Returns the problem domain field. |
| 106 | * |
| 107 | * @return uint8_t& - the problem domain |
| 108 | */ |
| 109 | uint8_t& problemDomain() |
| 110 | { |
| 111 | return _problemDomain; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * @brief Returns the problem vector field. |
| 116 | * |
| 117 | * @return uint8_t& - the problem vector |
| 118 | */ |
| 119 | uint8_t& problemVector() |
| 120 | { |
| 121 | return _problemVector; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * @brief Returns the action flags field. |
| 126 | * |
| 127 | * @return uint16_t& - the action flags |
| 128 | */ |
| 129 | uint16_t& actionFlags() |
| 130 | { |
| 131 | return _actionFlags; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * @brief Returns the size of this section when flattened into a PEL |
| 136 | * |
| 137 | * @return size_t - the size of the section |
| 138 | */ |
| 139 | static constexpr size_t flattenedSize() |
| 140 | { |
| 141 | return Section::flattenedSize() + sizeof(_eventSubsystem) + |
| 142 | sizeof(_eventScope) + sizeof(_eventSeverity) + |
| 143 | sizeof(_eventType) + sizeof(_reserved4Byte1) + |
| 144 | sizeof(_problemDomain) + sizeof(_problemVector) + |
| 145 | sizeof(_actionFlags) + sizeof(_reserved4Byte2); |
| 146 | } |
| 147 | |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 148 | private: |
| 149 | /** |
Matt Spinler | cf5a8d0 | 2019-09-05 12:58:53 -0500 | [diff] [blame] | 150 | * @brief Fills in the object from the stream data |
| 151 | * |
| 152 | * @param[in] stream - The stream to read from |
| 153 | */ |
| 154 | void unflatten(Stream& stream); |
| 155 | |
| 156 | /** |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 157 | * @brief Validates the section contents |
| 158 | * |
| 159 | * Updates _valid (in Section) with the results. |
| 160 | */ |
| 161 | void validate() override; |
| 162 | |
| 163 | /** |
| 164 | * @brief The subsystem associated with the event. |
| 165 | */ |
| 166 | uint8_t _eventSubsystem; |
| 167 | |
| 168 | /** |
| 169 | * @brief The event scope field. |
| 170 | */ |
| 171 | uint8_t _eventScope; |
| 172 | |
| 173 | /** |
| 174 | * @brief The event severity. |
| 175 | */ |
| 176 | uint8_t _eventSeverity; |
| 177 | |
| 178 | /** |
| 179 | * @brief The event type. |
| 180 | */ |
| 181 | uint8_t _eventType; |
| 182 | |
| 183 | /** |
| 184 | * @brief A reserved word placeholder |
| 185 | */ |
| 186 | uint32_t _reserved4Byte1; |
| 187 | |
| 188 | /** |
| 189 | * @brief The problem domain field. |
| 190 | */ |
| 191 | uint8_t _problemDomain; |
| 192 | |
| 193 | /** |
| 194 | * @brief The problem vector field. |
| 195 | */ |
| 196 | uint8_t _problemVector; |
| 197 | |
| 198 | /** |
| 199 | * @brief The action flags field. |
| 200 | */ |
| 201 | uint16_t _actionFlags; |
| 202 | |
| 203 | /** |
| 204 | * @brief The second reserved word placeholder. |
| 205 | */ |
| 206 | uint32_t _reserved4Byte2; |
| 207 | }; |
| 208 | |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 209 | } // namespace pels |
| 210 | } // namespace openpower |