summaryrefslogtreecommitdiffstats
path: root/extensions/openpower-pels/mru.hpp
blob: e2293f1198e2a0429828d9b7dad9a0ddcde94c38 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#pragma once

#include "stream.hpp"

namespace openpower
{
namespace pels
{
namespace src
{

/**
 * @class MRU
 *
 * This represents the MRU (Manufacturing Replaceable Unit)
 * substructure in the callout subsection of the SRC PEL section.
 *
 * Manufacturing replaceable units have a finer granularity than
 * a field replaceable unit, such as a chip on a card, and are
 * intended to be used during manufacturing.
 *
 * This substructure can contain up to 128 MRU callouts, each
 * containing a MRU ID and a callout priority value.
 */
class MRU
{
  public:
    /**
     * @brief A single MRU callout, which contains a priority
     *        and a MRU ID.
     *
     * The priority value is the same priority type character
     * value as in the parent callout structure. For alignment
     * purposes it is a 4 byte field, though only the LSB contains
     * the priority value.
     */
    struct MRUCallout
    {
        uint32_t priority;
        uint32_t id;
    };

    MRU() = delete;
    ~MRU() = default;
    MRU(const MRU&) = default;
    MRU& operator=(const MRU&) = default;
    MRU(MRU&&) = default;
    MRU& operator=(MRU&&) = default;

    /**
     * @brief Constructor
     *
     * Fills in this class's data fields from the stream.
     *
     * @param[in] pel - the PEL data stream
     */
    explicit MRU(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 structure when flattened into a PEL
     *
     * @return size_t - The size of the section
     */
    size_t flattenedSize() const
    {
        return _size;
    }

    /**
     * @brief Returns the contained MRU callouts.
     *
     * @return const std::vector<MRUCallout>& - The MRUs
     */
    const std::vector<MRUCallout>& mrus() const
    {
        return _mrus;
    }

    /**
     * @brief The type identifier value of this structure.
     */
    static const uint16_t substructureType = 0x4D52; // "MR"

  private:
    /**
     * @brief The callout substructure type field. Will be 'MR'.
     */
    uint16_t _type;

    /**
     * @brief The size of this callout structure.
     */
    uint8_t _size;

    /**
     * @brief The flags byte of this substructure.
     *
     * 0x0Y: Y = number of MRU callouts
     */
    uint8_t _flags;

    /**
     * @brief Reserved 4 bytes
     */
    uint32_t _reserved4B;

    /*
     * @brief The MRU callouts
     */
    std::vector<MRUCallout> _mrus;
};

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