blob: 9f929ab6213c3f6cc47718a3c6ed9219e78dfbf3 [file] [log] [blame]
Matt Spinler32f13c92019-10-09 12:48:25 -05001#pragma once
2
3#include "callout.hpp"
4#include "stream.hpp"
5
6namespace openpower
7{
8namespace pels
9{
10namespace src
11{
12
Matt Spinlere0366f32020-03-13 13:02:19 -050013constexpr uint8_t calloutsSubsectionID = 0xC0;
14constexpr size_t maxNumberOfCallouts = 10;
15
Matt Spinler32f13c92019-10-09 12:48:25 -050016/**
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 */
26class Callouts
27{
28 public:
Matt Spinler32f13c92019-10-09 12:48:25 -050029 ~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 Spinlere0366f32020-03-13 13:02:19 -050038 * Creates the object with no callouts.
39 */
40 Callouts() :
41 _subsectionID(calloutsSubsectionID), _subsectionFlags(0),
42 _subsectionWordLength(1)
Patrick Williams2544b412022-10-04 08:41:06 -050043 {}
Matt Spinlere0366f32020-03-13 13:02:19 -050044
45 /**
46 * @brief Constructor
47 *
Matt Spinler32f13c92019-10-09 12:48:25 -050048 * 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 Spinler724d0d82019-11-06 10:05:36 -060059 void flatten(Stream& pel) const;
Matt Spinler32f13c92019-10-09 12:48:25 -050060
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 Spinlere0366f32020-03-13 13:02:19 -050081 /**
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 Spinler32f13c92019-10-09 12:48:25 -050088 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