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 | */ |
Matt Spinler | 0688545 | 2019-11-06 10:35:42 -0600 | [diff] [blame] | 62 | void flatten(Stream& stream) const override; |
Matt Spinler | cf5a8d0 | 2019-09-05 12:58:53 -0500 | [diff] [blame] | 63 | |
| 64 | /** |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 65 | * @brief Returns the subsystem field. |
| 66 | * |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 67 | * @return uint8_t - the subsystem |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 68 | */ |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 69 | uint8_t subsystem() const |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 70 | { |
| 71 | return _eventSubsystem; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * @brief Returns the event scope field. |
| 76 | * |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 77 | * @return uint8_t - the event scope |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 78 | */ |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 79 | uint8_t scope() const |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 80 | { |
| 81 | return _eventScope; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @brief Returns the severity field. |
| 86 | * |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 87 | * @return uint8_t - the severity |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 88 | */ |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 89 | uint8_t severity() const |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 90 | { |
| 91 | return _eventSeverity; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @brief Returns the event type field. |
| 96 | * |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 97 | * @return uint8_t - the event type |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 98 | */ |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 99 | uint8_t eventType() const |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 100 | { |
| 101 | return _eventType; |
| 102 | } |
| 103 | |
| 104 | /** |
Matt Spinler | f1e85e2 | 2019-11-01 11:31:31 -0500 | [diff] [blame] | 105 | * @brief Set the event type field |
| 106 | * |
| 107 | * @param[in] type - the new event type |
| 108 | */ |
| 109 | void setEventType(uint8_t type) |
| 110 | { |
| 111 | _eventType = type; |
| 112 | } |
| 113 | |
| 114 | /** |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 115 | * @brief Returns the problem domain field. |
| 116 | * |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 117 | * @return uint8_t - the problem domain |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 118 | */ |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 119 | uint8_t problemDomain() const |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 120 | { |
| 121 | return _problemDomain; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * @brief Returns the problem vector field. |
| 126 | * |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 127 | * @return uint8_t - the problem vector |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 128 | */ |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 129 | uint8_t problemVector() const |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 130 | { |
| 131 | return _problemVector; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * @brief Returns the action flags field. |
| 136 | * |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 137 | * @return uint16_t - the action flags |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 138 | */ |
Matt Spinler | 97d19b4 | 2019-10-29 11:34:03 -0500 | [diff] [blame] | 139 | uint16_t actionFlags() const |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 140 | { |
| 141 | return _actionFlags; |
| 142 | } |
| 143 | |
| 144 | /** |
Matt Spinler | f1e85e2 | 2019-11-01 11:31:31 -0500 | [diff] [blame] | 145 | * @brief Sets the action flags field |
| 146 | * |
| 147 | * @param[in] flags - the new action flags |
| 148 | */ |
| 149 | void setActionFlags(uint16_t flags) |
| 150 | { |
| 151 | _actionFlags = flags; |
| 152 | } |
| 153 | |
| 154 | /** |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 155 | * @brief Returns the size of this section when flattened into a PEL |
| 156 | * |
| 157 | * @return size_t - the size of the section |
| 158 | */ |
| 159 | static constexpr size_t flattenedSize() |
| 160 | { |
| 161 | return Section::flattenedSize() + sizeof(_eventSubsystem) + |
| 162 | sizeof(_eventScope) + sizeof(_eventSeverity) + |
| 163 | sizeof(_eventType) + sizeof(_reserved4Byte1) + |
| 164 | sizeof(_problemDomain) + sizeof(_problemVector) + |
| 165 | sizeof(_actionFlags) + sizeof(_reserved4Byte2); |
| 166 | } |
| 167 | |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 168 | private: |
| 169 | /** |
Matt Spinler | cf5a8d0 | 2019-09-05 12:58:53 -0500 | [diff] [blame] | 170 | * @brief Fills in the object from the stream data |
| 171 | * |
| 172 | * @param[in] stream - The stream to read from |
| 173 | */ |
| 174 | void unflatten(Stream& stream); |
| 175 | |
| 176 | /** |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 177 | * @brief Validates the section contents |
| 178 | * |
| 179 | * Updates _valid (in Section) with the results. |
| 180 | */ |
| 181 | void validate() override; |
| 182 | |
| 183 | /** |
| 184 | * @brief The subsystem associated with the event. |
| 185 | */ |
| 186 | uint8_t _eventSubsystem; |
| 187 | |
| 188 | /** |
| 189 | * @brief The event scope field. |
| 190 | */ |
| 191 | uint8_t _eventScope; |
| 192 | |
| 193 | /** |
| 194 | * @brief The event severity. |
| 195 | */ |
| 196 | uint8_t _eventSeverity; |
| 197 | |
| 198 | /** |
| 199 | * @brief The event type. |
| 200 | */ |
| 201 | uint8_t _eventType; |
| 202 | |
| 203 | /** |
| 204 | * @brief A reserved word placeholder |
| 205 | */ |
| 206 | uint32_t _reserved4Byte1; |
| 207 | |
| 208 | /** |
| 209 | * @brief The problem domain field. |
| 210 | */ |
| 211 | uint8_t _problemDomain; |
| 212 | |
| 213 | /** |
| 214 | * @brief The problem vector field. |
| 215 | */ |
| 216 | uint8_t _problemVector; |
| 217 | |
| 218 | /** |
| 219 | * @brief The action flags field. |
| 220 | */ |
| 221 | uint16_t _actionFlags; |
| 222 | |
| 223 | /** |
| 224 | * @brief The second reserved word placeholder. |
| 225 | */ |
| 226 | uint32_t _reserved4Byte2; |
| 227 | }; |
| 228 | |
Matt Spinler | 03c1d91 | 2019-07-10 14:12:15 -0500 | [diff] [blame] | 229 | } // namespace pels |
| 230 | } // namespace openpower |