1 #pragma once 2 3 #include "callout.hpp" 4 #include "stream.hpp" 5 6 namespace openpower 7 { 8 namespace pels 9 { 10 namespace src 11 { 12 13 constexpr uint8_t calloutsSubsectionID = 0xC0; 14 constexpr size_t maxNumberOfCallouts = 10; 15 16 /** 17 * @class Callouts 18 * 19 * This is an optional subsection of the SRC section in a PEL 20 * that holds callouts (represented as Callout objects). 21 * It is at the end of the SRC section, and there can only be one 22 * of these present in the SRC. 23 * 24 * If an SRC doesn't have any callouts, this object won't be created. 25 */ 26 class Callouts 27 { 28 public: 29 ~Callouts() = default; 30 Callouts(const Callouts&) = delete; 31 Callouts& operator=(const Callouts&) = delete; 32 Callouts(Callouts&&) = delete; 33 Callouts& operator=(Callouts&&) = delete; 34 35 /** 36 * @brief Constructor 37 * 38 * Creates the object with no callouts. 39 */ 40 Callouts() : 41 _subsectionID(calloutsSubsectionID), _subsectionFlags(0), 42 _subsectionWordLength(1) 43 { 44 } 45 46 /** 47 * @brief Constructor 48 * 49 * Fills in this class's data fields from the stream. 50 * 51 * @param[in] pel - the PEL data stream 52 */ 53 explicit Callouts(Stream& pel); 54 55 /** 56 * @brief Flatten the object into the stream 57 * 58 * @param[in] stream - The stream to write to 59 */ 60 void flatten(Stream& pel) const; 61 62 /** 63 * @brief Returns the size of this object when flattened into a PEL 64 * 65 * @return size_t - The size of the section 66 */ 67 size_t flattenedSize() 68 { 69 return _subsectionWordLength * 4; 70 } 71 72 /** 73 * @brief Returns the contained callouts 74 * 75 * @return const std::vector<std::unique_ptr<Callout>>& 76 */ 77 const std::vector<std::unique_ptr<Callout>>& callouts() const 78 { 79 return _callouts; 80 } 81 82 /** 83 * @brief Adds a callout 84 * 85 * @param[in] callout - The callout to add 86 */ 87 void addCallout(std::unique_ptr<Callout> callout); 88 89 private: 90 /** 91 * @brief The ID of this subsection, which is 0xC0. 92 */ 93 uint8_t _subsectionID; 94 95 /** 96 * @brief Subsection flags. Always 0. 97 */ 98 uint8_t _subsectionFlags; 99 100 /** 101 * @brief Subsection length in 4B words. 102 * 103 * (Subsection is always a multiple of 4B) 104 */ 105 uint16_t _subsectionWordLength; 106 107 /** 108 * @brief The contained callouts 109 */ 110 std::vector<std::unique_ptr<Callout>> _callouts; 111 }; 112 113 } // namespace src 114 115 } // namespace pels 116 } // namespace openpower 117