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