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: |
| 48 | PrivateHeader() = delete; |
| 49 | ~PrivateHeader() = default; |
| 50 | PrivateHeader(const PrivateHeader&) = default; |
| 51 | PrivateHeader& operator=(const PrivateHeader&) = default; |
| 52 | PrivateHeader(PrivateHeader&&) = default; |
| 53 | PrivateHeader& operator=(PrivateHeader&&) = default; |
| 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 | |
| 107 | private: |
| 108 | /** |
| 109 | * @brief The creation time timestamp |
| 110 | */ |
| 111 | uint64_t _createTimestamp; |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * @brief The commit time timestamp |
| 115 | */ |
| 116 | uint64_t _commitTimestamp; |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * @brief The creator ID field |
| 120 | */ |
| 121 | uint8_t _creatorID; |
| 122 | |
| 123 | /** |
| 124 | * @brief A reserved byte. |
| 125 | */ |
| 126 | uint8_t _reservedByte1 = 0; |
| 127 | |
| 128 | /** |
| 129 | * @brief A reserved byte. |
| 130 | */ |
| 131 | uint8_t _reservedByte2 = 0; |
| 132 | |
| 133 | /** |
| 134 | * @brief Total number of sections in the PEL |
| 135 | */ |
| 136 | uint8_t _sectionCount = 3; // private header, user header, primary src = 3 |
| 137 | |
| 138 | /** |
| 139 | * @brief The OpenBMC event log ID that corresponds to this PEL. |
| 140 | */ |
| 141 | uint32_t _obmcLogID = 0; |
| 142 | |
| 143 | /** |
| 144 | * @brief The creator subsystem version field |
| 145 | */ |
| 146 | uint64_t _creatorVersion; |
| 147 | // CreatorVersion _creatorVersion; |
| 148 | |
| 149 | /** |
| 150 | * @brief The platform log ID field |
| 151 | */ |
| 152 | uint32_t _plid; |
| 153 | |
| 154 | /** |
| 155 | * @brief The log entry ID field |
| 156 | */ |
| 157 | uint32_t _id = 0; |
| 158 | }; |
| 159 | |
Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 160 | } // namespace pel |
| 161 | } // namespace attn |