114d671faSMatt Spinler #pragma once 214d671faSMatt Spinler 314d671faSMatt Spinler #include "section.hpp" 414d671faSMatt Spinler #include "stream.hpp" 514d671faSMatt Spinler 614d671faSMatt Spinler namespace openpower 714d671faSMatt Spinler { 814d671faSMatt Spinler namespace pels 914d671faSMatt Spinler { 1014d671faSMatt Spinler 1114d671faSMatt Spinler /** 1214d671faSMatt Spinler * @class Generic 1314d671faSMatt Spinler * 1414d671faSMatt Spinler * This class is used for a PEL section when there is no other class to use. 1514d671faSMatt Spinler * It just contains a vector of the raw data. Its purpose is so that a PEL 1614d671faSMatt Spinler * can be completely unflattened even if the code doesn't have a class for 1714d671faSMatt Spinler * every section type. 1814d671faSMatt Spinler */ 1914d671faSMatt Spinler class Generic : public Section 2014d671faSMatt Spinler { 2114d671faSMatt Spinler public: 2214d671faSMatt Spinler Generic() = delete; 2314d671faSMatt Spinler ~Generic() = default; 2414d671faSMatt Spinler Generic(const Generic&) = default; 2514d671faSMatt Spinler Generic& operator=(const Generic&) = default; 2614d671faSMatt Spinler Generic(Generic&&) = default; 2714d671faSMatt Spinler Generic& operator=(Generic&&) = default; 2814d671faSMatt Spinler 2914d671faSMatt Spinler /** 3014d671faSMatt Spinler * @brief Constructor 3114d671faSMatt Spinler * 3214d671faSMatt Spinler * Fills in this class's data fields from the stream. 3314d671faSMatt Spinler * 3414d671faSMatt Spinler * @param[in] pel - the PEL data stream 3514d671faSMatt Spinler */ 3614d671faSMatt Spinler explicit Generic(Stream& pel); 3714d671faSMatt Spinler 3814d671faSMatt Spinler /** 3914d671faSMatt Spinler * @brief Flatten the section into the stream 4014d671faSMatt Spinler * 4114d671faSMatt Spinler * @param[in] stream - The stream to write to 4214d671faSMatt Spinler */ 43*0688545bSMatt Spinler void flatten(Stream& stream) const override; 4414d671faSMatt Spinler 4514d671faSMatt Spinler /** 4614d671faSMatt Spinler * @brief Returns the size of this section when flattened into a PEL 4714d671faSMatt Spinler * 4814d671faSMatt Spinler * @return size_t - the size of the section 4914d671faSMatt Spinler */ flattenedSize()5014d671faSMatt Spinler size_t flattenedSize() 5114d671faSMatt Spinler { 5214d671faSMatt Spinler return Section::flattenedSize() + _data.size(); 5314d671faSMatt Spinler } 5414d671faSMatt Spinler 5514d671faSMatt Spinler /** 5614d671faSMatt Spinler * @brief Returns the raw section data 5714d671faSMatt Spinler * 5814d671faSMatt Spinler * @return std::vector<uint8_t>& 5914d671faSMatt Spinler */ data() const6014d671faSMatt Spinler const std::vector<uint8_t>& data() const 6114d671faSMatt Spinler { 6214d671faSMatt Spinler return _data; 6314d671faSMatt Spinler } 6414d671faSMatt Spinler 6514d671faSMatt Spinler private: 6614d671faSMatt Spinler /** 6714d671faSMatt Spinler * @brief Fills in the object from the stream data 6814d671faSMatt Spinler * 6914d671faSMatt Spinler * @param[in] stream - The stream to read from 7014d671faSMatt Spinler */ 7114d671faSMatt Spinler void unflatten(Stream& stream); 7214d671faSMatt Spinler 7314d671faSMatt Spinler /** 7414d671faSMatt Spinler * @brief Validates the section contents 7514d671faSMatt Spinler * 7614d671faSMatt Spinler * Updates _valid (in Section) with the results. 7714d671faSMatt Spinler */ 7814d671faSMatt Spinler void validate() override; 7914d671faSMatt Spinler 8014d671faSMatt Spinler /** 8114d671faSMatt Spinler * @brief The section data 8214d671faSMatt Spinler */ 8314d671faSMatt Spinler std::vector<uint8_t> _data; 8414d671faSMatt Spinler }; 8514d671faSMatt Spinler 8614d671faSMatt Spinler } // namespace pels 8714d671faSMatt Spinler } // namespace openpower 88