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 | |
Matt Spinler | e0366f3 | 2020-03-13 13:02:19 -0500 | [diff] [blame] | 13 | constexpr uint8_t calloutsSubsectionID = 0xC0; |
| 14 | constexpr size_t maxNumberOfCallouts = 10; |
| 15 | |
Matt Spinler | 32f13c9 | 2019-10-09 12:48:25 -0500 | [diff] [blame] | 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: |
Matt Spinler | 32f13c9 | 2019-10-09 12:48:25 -0500 | [diff] [blame] | 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 | * |
Matt Spinler | e0366f3 | 2020-03-13 13:02:19 -0500 | [diff] [blame] | 38 | * Creates the object with no callouts. |
| 39 | */ |
| 40 | Callouts() : |
| 41 | _subsectionID(calloutsSubsectionID), _subsectionFlags(0), |
| 42 | _subsectionWordLength(1) |
Patrick Williams | 2544b41 | 2022-10-04 08:41:06 -0500 | [diff] [blame] | 43 | {} |
Matt Spinler | e0366f3 | 2020-03-13 13:02:19 -0500 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * @brief Constructor |
| 47 | * |
Matt Spinler | 32f13c9 | 2019-10-09 12:48:25 -0500 | [diff] [blame] | 48 | * Fills in this class's data fields from the stream. |
| 49 | * |
| 50 | * @param[in] pel - the PEL data stream |
| 51 | */ |
| 52 | explicit Callouts(Stream& pel); |
| 53 | |
| 54 | /** |
| 55 | * @brief Flatten the object into the stream |
| 56 | * |
| 57 | * @param[in] stream - The stream to write to |
| 58 | */ |
Matt Spinler | 724d0d8 | 2019-11-06 10:05:36 -0600 | [diff] [blame] | 59 | void flatten(Stream& pel) const; |
Matt Spinler | 32f13c9 | 2019-10-09 12:48:25 -0500 | [diff] [blame] | 60 | |
| 61 | /** |
| 62 | * @brief Returns the size of this object when flattened into a PEL |
| 63 | * |
| 64 | * @return size_t - The size of the section |
| 65 | */ |
| 66 | size_t flattenedSize() |
| 67 | { |
| 68 | return _subsectionWordLength * 4; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * @brief Returns the contained callouts |
| 73 | * |
| 74 | * @return const std::vector<std::unique_ptr<Callout>>& |
| 75 | */ |
| 76 | const std::vector<std::unique_ptr<Callout>>& callouts() const |
| 77 | { |
| 78 | return _callouts; |
| 79 | } |
| 80 | |
Matt Spinler | e0366f3 | 2020-03-13 13:02:19 -0500 | [diff] [blame] | 81 | /** |
| 82 | * @brief Adds a callout |
| 83 | * |
| 84 | * @param[in] callout - The callout to add |
| 85 | */ |
| 86 | void addCallout(std::unique_ptr<Callout> callout); |
| 87 | |
Matt Spinler | 32f13c9 | 2019-10-09 12:48:25 -0500 | [diff] [blame] | 88 | private: |
| 89 | /** |
| 90 | * @brief The ID of this subsection, which is 0xC0. |
| 91 | */ |
| 92 | uint8_t _subsectionID; |
| 93 | |
| 94 | /** |
| 95 | * @brief Subsection flags. Always 0. |
| 96 | */ |
| 97 | uint8_t _subsectionFlags; |
| 98 | |
| 99 | /** |
| 100 | * @brief Subsection length in 4B words. |
| 101 | * |
| 102 | * (Subsection is always a multiple of 4B) |
| 103 | */ |
| 104 | uint16_t _subsectionWordLength; |
| 105 | |
| 106 | /** |
| 107 | * @brief The contained callouts |
| 108 | */ |
| 109 | std::vector<std::unique_ptr<Callout>> _callouts; |
| 110 | }; |
| 111 | |
| 112 | } // namespace src |
| 113 | |
| 114 | } // namespace pels |
| 115 | } // namespace openpower |