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