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