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