summaryrefslogtreecommitdiffstats
path: root/extensions/openpower-pels/callouts.hpp
blob: 9226a1b7b842054ac1a8856452c209ade787aa92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#pragma once

#include "callout.hpp"
#include "stream.hpp"

namespace openpower
{
namespace pels
{
namespace src
{

/**
 * @class Callouts
 *
 * This is an optional subsection of the SRC section in a PEL
 * that holds callouts (represented as Callout objects).
 * It is at the end of the SRC section, and there can only be one
 * of these present in the SRC.
 *
 * If an SRC doesn't have any callouts, this object won't be created.
 */
class Callouts
{
  public:
    Callouts() = default;
    ~Callouts() = default;
    Callouts(const Callouts&) = delete;
    Callouts& operator=(const Callouts&) = delete;
    Callouts(Callouts&&) = delete;
    Callouts& operator=(Callouts&&) = delete;

    /**
     * @brief Constructor
     *
     * Fills in this class's data fields from the stream.
     *
     * @param[in] pel - the PEL data stream
     */
    explicit Callouts(Stream& pel);

    /**
     * @brief Flatten the object into the stream
     *
     * @param[in] stream - The stream to write to
     */
    void flatten(Stream& pel) const;

    /**
     * @brief Returns the size of this object when flattened into a PEL
     *
     * @return size_t - The size of the section
     */
    size_t flattenedSize()
    {
        return _subsectionWordLength * 4;
    }

    /**
     * @brief Returns the contained callouts
     *
     * @return const std::vector<std::unique_ptr<Callout>>&
     */
    const std::vector<std::unique_ptr<Callout>>& callouts() const
    {
        return _callouts;
    }

  private:
    /**
     * @brief The ID of this subsection, which is 0xC0.
     */
    uint8_t _subsectionID;

    /**
     * @brief Subsection flags.  Always 0.
     */
    uint8_t _subsectionFlags;

    /**
     * @brief Subsection length in 4B words.
     *
     * (Subsection is always a multiple of 4B)
     */
    uint16_t _subsectionWordLength;

    /**
     * @brief The contained callouts
     */
    std::vector<std::unique_ptr<Callout>> _callouts;
};

} // namespace src

} // namespace pels
} // namespace openpower
OpenPOWER on IntegriCloud