Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 3 | #include "pel_common.hpp" |
| 4 | #include "pel_section.hpp" |
| 5 | #include "stream.hpp" |
| 6 | |
| 7 | namespace attn |
| 8 | { |
| 9 | namespace pel |
| 10 | { |
| 11 | |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 12 | /** |
| 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 | */ |
| 45 | class PrivateHeader : public Section |
| 46 | { |
| 47 | public: |
Zane Shelley | b82cbf7 | 2022-06-27 10:28:06 -0500 | [diff] [blame] | 48 | PrivateHeader() = delete; |
| 49 | ~PrivateHeader() = default; |
| 50 | PrivateHeader(const PrivateHeader&) = default; |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 51 | PrivateHeader& operator=(const PrivateHeader&) = default; |
| 52 | PrivateHeader(PrivateHeader&&) = default; |
Zane Shelley | b82cbf7 | 2022-06-27 10:28:06 -0500 | [diff] [blame] | 53 | PrivateHeader& operator=(PrivateHeader&&) = default; |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 54 | |
| 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 Tyner | 135793a | 2021-10-27 09:18:41 -0500 | [diff] [blame] | 107 | /** |
| 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 Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 114 | private: |
| 115 | /** |
| 116 | * @brief The creation time timestamp |
| 117 | */ |
| 118 | uint64_t _createTimestamp; |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 119 | |
| 120 | /** |
| 121 | * @brief The commit time timestamp |
| 122 | */ |
| 123 | uint64_t _commitTimestamp; |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 124 | |
| 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 Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 167 | } // namespace pel |
| 168 | } // namespace attn |