| Matt Spinler | c63e2e8 | 2019-12-02 15:50:12 -0600 | [diff] [blame^] | 1 | #pragma once | 
|  | 2 |  | 
|  | 3 | #include "bcd_time.hpp" | 
|  | 4 | #include "data_interface.hpp" | 
|  | 5 | #include "elog_entry.hpp" | 
|  | 6 | #include "mtms.hpp" | 
|  | 7 | #include "registry.hpp" | 
|  | 8 | #include "section.hpp" | 
|  | 9 | #include "src.hpp" | 
|  | 10 | #include "stream.hpp" | 
|  | 11 |  | 
|  | 12 | namespace openpower | 
|  | 13 | { | 
|  | 14 | namespace pels | 
|  | 15 | { | 
|  | 16 |  | 
|  | 17 | constexpr uint8_t extendedUserHeaderVersion = 0x01; | 
|  | 18 | constexpr size_t firmwareVersionSize = 16; | 
|  | 19 |  | 
|  | 20 | /** | 
|  | 21 | * @class ExtendedUserHeader | 
|  | 22 | * | 
|  | 23 | * This represents the Extended User Header section in a PEL.  It is  a required | 
|  | 24 | * section.  It contains code versions, an MTMS subsection, and a string called | 
|  | 25 | * a symptom ID. | 
|  | 26 | * | 
|  | 27 | * The Section base class handles the section header structure that every | 
|  | 28 | * PEL section has at offset zero. | 
|  | 29 | */ | 
|  | 30 | class ExtendedUserHeader : public Section | 
|  | 31 | { | 
|  | 32 | public: | 
|  | 33 | ExtendedUserHeader() = delete; | 
|  | 34 | ~ExtendedUserHeader() = default; | 
|  | 35 | ExtendedUserHeader(const ExtendedUserHeader&) = default; | 
|  | 36 | ExtendedUserHeader& operator=(const ExtendedUserHeader&) = default; | 
|  | 37 | ExtendedUserHeader(ExtendedUserHeader&&) = default; | 
|  | 38 | ExtendedUserHeader& operator=(ExtendedUserHeader&&) = default; | 
|  | 39 |  | 
|  | 40 | /** | 
|  | 41 | * @brief Constructor | 
|  | 42 | * | 
|  | 43 | * Fills in this class's data fields from the stream. | 
|  | 44 | * | 
|  | 45 | * @param[in] pel - the PEL data stream | 
|  | 46 | */ | 
|  | 47 | explicit ExtendedUserHeader(Stream& pel); | 
|  | 48 |  | 
|  | 49 | /** | 
|  | 50 | * @brief Constructor | 
|  | 51 | * | 
|  | 52 | * @param[in] dataIface - The DataInterface object | 
|  | 53 | * @param[in] regEntry - The message registry entry for this event | 
|  | 54 | * @param[in] src - The SRC section object for this event | 
|  | 55 | */ | 
|  | 56 | ExtendedUserHeader(const DataInterfaceBase& dataIface, | 
|  | 57 | const message::Entry& regEntry, const SRC& src); | 
|  | 58 |  | 
|  | 59 | /** | 
|  | 60 | * @brief Flatten the section into the stream | 
|  | 61 | * | 
|  | 62 | * @param[in] stream - The stream to write to | 
|  | 63 | */ | 
|  | 64 | void flatten(Stream& stream) const override; | 
|  | 65 |  | 
|  | 66 | /** | 
|  | 67 | * @brief Returns the size of this section when flattened into a PEL | 
|  | 68 | * | 
|  | 69 | * @return size_t - the size of the section | 
|  | 70 | */ | 
|  | 71 | size_t flattenedSize() | 
|  | 72 | { | 
|  | 73 | return Section::flattenedSize() + _mtms.flattenedSize() + | 
|  | 74 | _serverFWVersion.size() + _subsystemFWVersion.size() + | 
|  | 75 | sizeof(_reserved4B) + sizeof(_refTime) + sizeof(_reserved1B1) + | 
|  | 76 | sizeof(_reserved1B2) + sizeof(_reserved1B3) + | 
|  | 77 | sizeof(_symptomIDSize) + _symptomIDSize; | 
|  | 78 | } | 
|  | 79 |  | 
|  | 80 | /** | 
|  | 81 | * @brief Returns the server firmware version | 
|  | 82 | * | 
|  | 83 | * @return std::string - The version | 
|  | 84 | */ | 
|  | 85 | std::string serverFWVersion() const | 
|  | 86 | { | 
|  | 87 | std::string version; | 
|  | 88 | for (size_t i = 0; | 
|  | 89 | i < _serverFWVersion.size() && _serverFWVersion[i] != '\0'; i++) | 
|  | 90 | { | 
|  | 91 | version.push_back(_serverFWVersion[i]); | 
|  | 92 | } | 
|  | 93 | return version; | 
|  | 94 | } | 
|  | 95 |  | 
|  | 96 | /** | 
|  | 97 | * @brief Returns the subsystem firmware version | 
|  | 98 | * | 
|  | 99 | * @return std::string - The version | 
|  | 100 | */ | 
|  | 101 | std::string subsystemFWVersion() const | 
|  | 102 | { | 
|  | 103 | std::string version; | 
|  | 104 | for (size_t i = 0; | 
|  | 105 | i < _subsystemFWVersion.size() && _subsystemFWVersion[i] != '\0'; | 
|  | 106 | i++) | 
|  | 107 | { | 
|  | 108 | version.push_back(_subsystemFWVersion[i]); | 
|  | 109 | } | 
|  | 110 | return version; | 
|  | 111 | } | 
|  | 112 |  | 
|  | 113 | /** | 
|  | 114 | * @brief Returns the machine type+model | 
|  | 115 | * | 
|  | 116 | * @return std::string - The MTM | 
|  | 117 | */ | 
|  | 118 | std::string machineTypeModel() const | 
|  | 119 | { | 
|  | 120 | return _mtms.machineTypeAndModel(); | 
|  | 121 | } | 
|  | 122 |  | 
|  | 123 | /** | 
|  | 124 | * @brief Returns the machine serial number | 
|  | 125 | * | 
|  | 126 | * @return std::string - The serial number | 
|  | 127 | */ | 
|  | 128 | std::string machineSerialNumber() const | 
|  | 129 | { | 
|  | 130 | return _mtms.machineSerialNumber(); | 
|  | 131 | } | 
|  | 132 |  | 
|  | 133 | /** | 
|  | 134 | * @brief Returns the Event Common Reference Time field | 
|  | 135 | * | 
|  | 136 | * @return BCDTime - The time value | 
|  | 137 | */ | 
|  | 138 | const BCDTime& refTime() const | 
|  | 139 | { | 
|  | 140 | return _refTime; | 
|  | 141 | } | 
|  | 142 |  | 
|  | 143 | /** | 
|  | 144 | * @brief Returns the symptom ID | 
|  | 145 | * | 
|  | 146 | * @return std::string - The symptom ID | 
|  | 147 | */ | 
|  | 148 | std::string symptomID() const | 
|  | 149 | { | 
|  | 150 | std::string symptom; | 
|  | 151 | for (size_t i = 0; i < _symptomID.size() && _symptomID[i] != '\0'; i++) | 
|  | 152 | { | 
|  | 153 | symptom.push_back(_symptomID[i]); | 
|  | 154 | } | 
|  | 155 | return symptom; | 
|  | 156 | } | 
|  | 157 |  | 
|  | 158 | private: | 
|  | 159 | /** | 
|  | 160 | * @brief Fills in the object from the stream data | 
|  | 161 | * | 
|  | 162 | * @param[in] stream - The stream to read from | 
|  | 163 | */ | 
|  | 164 | void unflatten(Stream& stream); | 
|  | 165 |  | 
|  | 166 | /** | 
|  | 167 | * @brief Validates the section contents | 
|  | 168 | * | 
|  | 169 | * Updates _valid (in Section) with the results. | 
|  | 170 | */ | 
|  | 171 | void validate() override; | 
|  | 172 |  | 
|  | 173 | /** | 
|  | 174 | * @brief Builds the symptom ID | 
|  | 175 | * | 
|  | 176 | * Uses the message registry to say which SRC fields to add | 
|  | 177 | * to the SRC's ASCII string to make the ID, and uses a smart | 
|  | 178 | * default if not specified in the registry. | 
|  | 179 | * | 
|  | 180 | * @param[in] regEntry - The message registry entry for this event | 
|  | 181 | * @param[in] src - The SRC section object for this event | 
|  | 182 | */ | 
|  | 183 | void createSymptomID(const message::Entry& regEntry, const SRC& src); | 
|  | 184 |  | 
|  | 185 | /** | 
|  | 186 | * @brief The structure that holds the machine TM and SN fields. | 
|  | 187 | */ | 
|  | 188 | MTMS _mtms; | 
|  | 189 |  | 
|  | 190 | /** | 
|  | 191 | * @brief The server firmware version | 
|  | 192 | * | 
|  | 193 | * NULL terminated. | 
|  | 194 | * | 
|  | 195 | * The release version of the full firmware image. | 
|  | 196 | */ | 
|  | 197 | std::array<uint8_t, firmwareVersionSize> _serverFWVersion; | 
|  | 198 |  | 
|  | 199 | /** | 
|  | 200 | * @brief The subsystem firmware version | 
|  | 201 | * | 
|  | 202 | * NULL terminated. | 
|  | 203 | * | 
|  | 204 | * On PELs created on the BMC, this will be the BMC code version. | 
|  | 205 | */ | 
|  | 206 | std::array<uint8_t, firmwareVersionSize> _subsystemFWVersion; | 
|  | 207 |  | 
|  | 208 | /** | 
|  | 209 | * @brief Reserved | 
|  | 210 | */ | 
|  | 211 | uint32_t _reserved4B = 0; | 
|  | 212 |  | 
|  | 213 | /** | 
|  | 214 | * @brief Event Common Reference Time | 
|  | 215 | * | 
|  | 216 | * This is not used by PELs created on the BMC. | 
|  | 217 | */ | 
|  | 218 | BCDTime _refTime; | 
|  | 219 |  | 
|  | 220 | /** | 
|  | 221 | * @brief Reserved | 
|  | 222 | */ | 
|  | 223 | uint8_t _reserved1B1 = 0; | 
|  | 224 |  | 
|  | 225 | /** | 
|  | 226 | * @brief Reserved | 
|  | 227 | */ | 
|  | 228 | uint8_t _reserved1B2 = 0; | 
|  | 229 |  | 
|  | 230 | /** | 
|  | 231 | * @brief Reserved | 
|  | 232 | */ | 
|  | 233 | uint8_t _reserved1B3 = 0; | 
|  | 234 |  | 
|  | 235 | /** | 
|  | 236 | * @brief The size of the symptom ID field | 
|  | 237 | */ | 
|  | 238 | uint8_t _symptomIDSize; | 
|  | 239 |  | 
|  | 240 | /** | 
|  | 241 | * @brief The symptom ID field | 
|  | 242 | * | 
|  | 243 | * Describes a unique event signature for the log. | 
|  | 244 | * Required for serviceable events, otherwise optional. | 
|  | 245 | * When present, must start with the first 8 characters | 
|  | 246 | * of the ASCII string field from the SRC. | 
|  | 247 | * | 
|  | 248 | * NULL terminated. | 
|  | 249 | */ | 
|  | 250 | std::vector<uint8_t> _symptomID; | 
|  | 251 | }; | 
|  | 252 |  | 
|  | 253 | } // namespace pels | 
|  | 254 | } // namespace openpower |