Matt Spinler | 32f13c9 | 2019-10-09 12:48:25 -0500 | [diff] [blame] | 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 | /** |
| 14 | * @class Callouts |
| 15 | * |
| 16 | * This is an optional subsection of the SRC section in a PEL |
| 17 | * that holds callouts (represented as Callout objects). |
| 18 | * It is at the end of the SRC section, and there can only be one |
| 19 | * of these present in the SRC. |
| 20 | * |
| 21 | * If an SRC doesn't have any callouts, this object won't be created. |
| 22 | */ |
| 23 | class Callouts |
| 24 | { |
| 25 | public: |
| 26 | Callouts() = default; |
| 27 | ~Callouts() = default; |
| 28 | Callouts(const Callouts&) = delete; |
| 29 | Callouts& operator=(const Callouts&) = delete; |
| 30 | Callouts(Callouts&&) = delete; |
| 31 | Callouts& operator=(Callouts&&) = delete; |
| 32 | |
| 33 | /** |
| 34 | * @brief Constructor |
| 35 | * |
| 36 | * Fills in this class's data fields from the stream. |
| 37 | * |
| 38 | * @param[in] pel - the PEL data stream |
| 39 | */ |
| 40 | explicit Callouts(Stream& pel); |
| 41 | |
| 42 | /** |
| 43 | * @brief Flatten the object into the stream |
| 44 | * |
| 45 | * @param[in] stream - The stream to write to |
| 46 | */ |
| 47 | void flatten(Stream& pel); |
| 48 | |
| 49 | /** |
| 50 | * @brief Returns the size of this object when flattened into a PEL |
| 51 | * |
| 52 | * @return size_t - The size of the section |
| 53 | */ |
| 54 | size_t flattenedSize() |
| 55 | { |
| 56 | return _subsectionWordLength * 4; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * @brief Returns the contained callouts |
| 61 | * |
| 62 | * @return const std::vector<std::unique_ptr<Callout>>& |
| 63 | */ |
| 64 | const std::vector<std::unique_ptr<Callout>>& callouts() const |
| 65 | { |
| 66 | return _callouts; |
| 67 | } |
| 68 | |
| 69 | private: |
| 70 | /** |
| 71 | * @brief The ID of this subsection, which is 0xC0. |
| 72 | */ |
| 73 | uint8_t _subsectionID; |
| 74 | |
| 75 | /** |
| 76 | * @brief Subsection flags. Always 0. |
| 77 | */ |
| 78 | uint8_t _subsectionFlags; |
| 79 | |
| 80 | /** |
| 81 | * @brief Subsection length in 4B words. |
| 82 | * |
| 83 | * (Subsection is always a multiple of 4B) |
| 84 | */ |
| 85 | uint16_t _subsectionWordLength; |
| 86 | |
| 87 | /** |
| 88 | * @brief The contained callouts |
| 89 | */ |
| 90 | std::vector<std::unique_ptr<Callout>> _callouts; |
| 91 | }; |
| 92 | |
| 93 | } // namespace src |
| 94 | |
| 95 | } // namespace pels |
| 96 | } // namespace openpower |