blob: d6486f1920bb906df8a498720334dd8683164f27 [file] [log] [blame]
Ben Tynerfeeea832021-04-06 10:08:11 -05001#pragma once
2
3#include "pel_common.hpp"
4#include "pel_section.hpp"
5#include "stream.hpp"
6
7namespace attn
8{
9namespace pel
10{
11
12constexpr uint8_t extendedUserHeaderVersion = 0x01;
13constexpr size_t firmwareVersionSize = 16;
14
15/**
16 * @class ExtendedUserHeader
17 *
18 * This represents the Extended User Header section in a PEL
19 *
20 * |----------+---------------------------+-------+-------+-------------------|
21 * | length | byte0 | byte1 | byte2 | byte3 |
22 * |----------+---------------------------+-------+-------+-------------------|
23 * | 8 | Section Header |
24 * |----------+---------------------------------------------------------------|
25 * | 20 | Machine Type/Model/Serial |
26 * |----------+---------------------------------------------------------------|
27 * | 16 | FW Released Version |
28 * |----------+---------------------------------------------------------------|
29 * | 16 | FW Sub-system driver ver. |
30 * |----------+---------------------------+-------+-------+-------------------|
31 * | 4 | Reserved | rsvd | rsvd | Symptom ID length |
32 * |----------+---------------------------+-------+-------+-------------------|
33 * | 8 | Event Common Reference Time |
34 * |----------+---------------------------------------------------------------|
35 * | 4 | Reserved |
36 * |----------+---------------------------------------------------------------|
37 * | variable | Symptom ID |
38 * |----------+---------------------------------------------------------------|
39 *
40 */
41class ExtendedUserHeader : public Section
42{
43 public:
44 ExtendedUserHeader() = delete;
45 ~ExtendedUserHeader() = default;
46 ExtendedUserHeader(const ExtendedUserHeader&) = default;
47 ExtendedUserHeader& operator=(const ExtendedUserHeader&) = default;
48 ExtendedUserHeader(ExtendedUserHeader&&) = default;
49 ExtendedUserHeader& operator=(ExtendedUserHeader&&) = default;
50
51 /**
52 * @brief Constructor
53 *
54 * Fills in this class's data fields from raw data.
55 *
56 * @param[in] pel - the PEL data stream
57 */
58 explicit ExtendedUserHeader(Stream& pel);
59
60 /**
61 * @brief Flatten the section into the stream
62 *
63 * @param[in] stream - The stream to write to
64 */
65 void flatten(Stream& stream) const override;
66
67 /**
68 * @brief Fills in the object from the stream data
69 *
70 * @param[in] stream - The stream to read from
71 */
72 void unflatten(Stream& stream);
73
74 /**
75 * @brief Returns the size of this section when flattened into a PEL
76 *
77 * @return size_t - the size of the section
78 */
79 size_t flattenedSize()
80 {
81 return Section::flattenedSize() + mtmsSize + _serverFWVersion.size() +
82 _subsystemFWVersion.size() + sizeof(_reserved4B) +
83 sizeof(_refTime) + sizeof(_reserved1B1) + sizeof(_reserved1B2) +
84 sizeof(_reserved1B3) + sizeof(_symptomIdSize) + _symptomIdSize;
85 }
86
87 /**
88 * @brief Set the symptom id field in extended user header
89 *
90 * @param[in] symptomId - The symptom ID to set
91 */
92 void setSymptomId(const std::string& symptomId);
93
94 private:
95 /**
96 * @brief The structure that holds the machine TM and SN fields.
97 */
98 uint8_t _mtms[mtmsSize];
99
100 /**
101 * @brief The server firmware version
102 *
103 * NULL terminated.
104 *
105 * The release version of the full firmware image.
106 */
107 std::array<uint8_t, firmwareVersionSize> _serverFWVersion;
108
109 /**
110 * @brief The subsystem firmware version
111 *
112 * NULL terminated.
113 *
114 * On PELs created on the BMC, this will be the BMC code version.
115 */
116 std::array<uint8_t, firmwareVersionSize> _subsystemFWVersion;
117
118 /**
119 * @brief Reserved
120 */
121 uint32_t _reserved4B = 0;
122
123 /**
124 * @brief Event Common Reference Time
125 *
126 * This is not used by PELs created on the BMC.
127 */
128 uint64_t _refTime;
129
130 /**
131 * @brief Reserved
132 */
133 uint8_t _reserved1B1 = 0;
134
135 /**
136 * @brief Reserved
137 */
138 uint8_t _reserved1B2 = 0;
139
140 /**
141 * @brief Reserved
142 */
143 uint8_t _reserved1B3 = 0;
144
145 /**
146 * @brief The size of the symptom ID field
147 */
148 uint8_t _symptomIdSize;
149
150 /**
151 * @brief The symptom ID field
152 *
153 * Describes a unique event signature for the log.
154 * Required for serviceable events, otherwise optional.
155 * When present, must start with the first 8 characters
156 * of the ASCII string field from the SRC.
157 *
158 * NULL terminated.
159 */
160 std::vector<uint8_t> _symptomId;
161};
162
163} // namespace pel
164} // namespace attn