blob: 4a053067dff7ff148e552623dcf7b488d3e6aadf [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)
43 {
44 }
45
46 /**
47 * @brief Constructor
48 *
Matt Spinler32f13c92019-10-09 12:48:25 -050049 * 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 */
Matt Spinler724d0d82019-11-06 10:05:36 -060060 void flatten(Stream& pel) const;
Matt Spinler32f13c92019-10-09 12:48:25 -050061
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
Matt Spinlere0366f32020-03-13 13:02:19 -050082 /**
83 * @brief Adds a callout
84 *
85 * @param[in] callout - The callout to add
86 */
87 void addCallout(std::unique_ptr<Callout> callout);
88
Matt Spinler32f13c92019-10-09 12:48:25 -050089 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