blob: 011ade5a9848526616427e658ef03fbd896b9afd [file] [log] [blame]
Ben Tynerf5210bb2021-01-05 12:58:10 -06001#pragma once
2
Ben Tynerf5210bb2021-01-05 12:58:10 -06003#include "pel_common.hpp"
4#include "pel_section.hpp"
5#include "stream.hpp"
6
7namespace attn
8{
9namespace pel
10{
11
Ben Tynerf5210bb2021-01-05 12:58:10 -060012/**
13 * @class PrivateHeader
14 *
15 * This represents the Private Header section in a PEL. It is required,
16 * and it is always the first section.
17 *
18 * The Section base class handles the SectionHeader structure that every
19 * PEL section has at offset zero.
20 *
21 * |--------+----------------------+----------+----------+---------------|
22 * | length | byte0 | byte1 | byte2 | byte3 |
23 * |--------+----------------------+----------+----------+---------------|
24 * | 8 | Section Header |
25 * | | |
26 * |--------+------------------------------------------------------------|
27 * | 8 | Timestamp - Creation |
28 * | | |
29 * |--------+------------------------------------------------------------|
30 * | 8 | Timestamp - Commit |
31 * | | |
32 * |--------+----------------------+----------+----------+---------------|
33 * | 4 | Creator ID | reserved | reserved | section count |
34 * |--------+----------------------+----------+----------+---------------|
35 * | 4 | OpenBMC Event Log ID |
36 * |--------+------------------------------------------------------------|
37 * | 8 | Creator Implementation |
38 * | | |
39 * |--------+------------------------------------------------------------|
40 * | 4 | Platform Log ID |
41 * |--------+------------------------------------------------------------|
42 * | 4 | Log Entry ID |
43 * |--------+------------------------------------------------------------|
44 */
45class PrivateHeader : public Section
46{
47 public:
Zane Shelleyb82cbf72022-06-27 10:28:06 -050048 PrivateHeader() = delete;
49 ~PrivateHeader() = default;
50 PrivateHeader(const PrivateHeader&) = default;
Ben Tynerf5210bb2021-01-05 12:58:10 -060051 PrivateHeader& operator=(const PrivateHeader&) = default;
52 PrivateHeader(PrivateHeader&&) = default;
Zane Shelleyb82cbf72022-06-27 10:28:06 -050053 PrivateHeader& operator=(PrivateHeader&&) = default;
Ben Tynerf5210bb2021-01-05 12:58:10 -060054
55 /**
56 * @brief Constructor
57 *
58 * Fills in this class's data fields from raw data.
59 *
60 * @param[in] pel - the PEL data stream
61 *
62 */
63 explicit PrivateHeader(Stream& pel);
64
65 /**
66 * @brief Flatten the section into the stream
67 *
68 * @param[in] stream - The stream to write to
69 */
70 void flatten(Stream& stream) const override;
71
72 /**
73 * @brief Fills in the object from the stream data
74 *
75 * @param[in] stream - The stream to read from
76 */
77 void unflatten(Stream& stream);
78
79 /**
80 * @brief Returns the size of this section when flattened into a PEL
81 *
82 * @return size_t - the size of the section
83 */
84 static constexpr size_t flattenedSize()
85 {
86 return Section::flattenedSize() + sizeof(_createTimestamp) +
87 sizeof(_commitTimestamp) + sizeof(_creatorID) +
88 sizeof(_reservedByte1) + sizeof(_reservedByte2) +
89 sizeof(_sectionCount) + sizeof(_obmcLogID) +
90 sizeof(_creatorVersion) + sizeof(_plid) + sizeof(_id);
91 }
92
93 /**
94 * @brief Get the total number of sections in this PEL
95 *
96 * @return Number of sections
97 */
98 uint8_t getSectionCount();
99
100 /**
101 * @brief Set the total number of sections in this PEL
102 *
103 * @param[in] sectionCount - Number of sections
104 */
105 void setSectionCount(uint8_t sectionCount);
106
Ben Tyner135793a2021-10-27 09:18:41 -0500107 /**
108 * @brief Set the plid in this PEL
109 *
110 * @param[in] plid - platform log ID
111 */
112 void setPlid(uint32_t plid);
113
Ben Tynerf5210bb2021-01-05 12:58:10 -0600114 private:
115 /**
116 * @brief The creation time timestamp
117 */
118 uint64_t _createTimestamp;
Ben Tynerf5210bb2021-01-05 12:58:10 -0600119
120 /**
121 * @brief The commit time timestamp
122 */
123 uint64_t _commitTimestamp;
Ben Tynerf5210bb2021-01-05 12:58:10 -0600124
125 /**
126 * @brief The creator ID field
127 */
128 uint8_t _creatorID;
129
130 /**
131 * @brief A reserved byte.
132 */
133 uint8_t _reservedByte1 = 0;
134
135 /**
136 * @brief A reserved byte.
137 */
138 uint8_t _reservedByte2 = 0;
139
140 /**
141 * @brief Total number of sections in the PEL
142 */
143 uint8_t _sectionCount = 3; // private header, user header, primary src = 3
144
145 /**
146 * @brief The OpenBMC event log ID that corresponds to this PEL.
147 */
148 uint32_t _obmcLogID = 0;
149
150 /**
151 * @brief The creator subsystem version field
152 */
153 uint64_t _creatorVersion;
154 // CreatorVersion _creatorVersion;
155
156 /**
157 * @brief The platform log ID field
158 */
159 uint32_t _plid;
160
161 /**
162 * @brief The log entry ID field
163 */
164 uint32_t _id = 0;
165};
166
Ben Tynerf5210bb2021-01-05 12:58:10 -0600167} // namespace pel
168} // namespace attn