blob: 8ad3e3c3ea51a70a1aa6a4c80146e221cdcac371 [file] [log] [blame]
Matt Spinler90b4a0a2019-10-09 10:08:43 -05001#pragma once
2
3#include "stream.hpp"
4
5namespace openpower
6{
7namespace pels
8{
9namespace src
10{
11
12/**
13 * @class MRU
14 *
15 * This represents the MRU (Manufacturing Replaceable Unit)
16 * substructure in the callout subsection of the SRC PEL section.
17 *
18 * Manufacturing replaceable units have a finer granularity than
19 * a field replaceable unit, such as a chip on a card, and are
20 * intended to be used during manufacturing.
21 *
22 * This substructure can contain up to 128 MRU callouts, each
23 * containing a MRU ID and a callout priority value.
24 */
25class MRU
26{
27 public:
28 /**
29 * @brief A single MRU callout, which contains a priority
30 * and a MRU ID.
31 *
32 * The priority value is the same priority type character
33 * value as in the parent callout structure. For alignment
34 * purposes it is a 4 byte field, though only the LSB contains
35 * the priority value.
36 */
37 struct MRUCallout
38 {
39 uint32_t priority;
40 uint32_t id;
41 };
42
43 MRU() = delete;
44 ~MRU() = default;
45 MRU(const MRU&) = default;
46 MRU& operator=(const MRU&) = default;
47 MRU(MRU&&) = default;
48 MRU& operator=(MRU&&) = default;
49
50 /**
51 * @brief Constructor
52 *
53 * Fills in this class's data fields from the stream.
54 *
55 * @param[in] pel - the PEL data stream
56 */
57 explicit MRU(Stream& pel);
58
59 /**
60 * @brief Flatten the object into the stream
61 *
62 * @param[in] stream - The stream to write to
63 */
64 void flatten(Stream& pel);
65
66 /**
67 * @brief Returns the size of this structure when flattened into a PEL
68 *
69 * @return size_t - The size of the section
70 */
71 size_t flattenedSize() const
72 {
73 return _size;
74 }
75
76 /**
77 * @brief Returns the contained MRU callouts.
78 *
79 * @return const std::vector<MRUCallout>& - The MRUs
80 */
81 const std::vector<MRUCallout>& mrus() const
82 {
83 return _mrus;
84 }
85
86 /**
87 * @brief The type identifier value of this structure.
88 */
89 static const uint16_t substructureType = 0x4D52; // "MR"
90
91 private:
92 /**
93 * @brief The callout substructure type field. Will be 'MR'.
94 */
95 uint16_t _type;
96
97 /**
98 * @brief The size of this callout structure.
99 */
100 uint8_t _size;
101
102 /**
103 * @brief The flags byte of this substructure.
104 *
105 * 0x0Y: Y = number of MRU callouts
106 */
107 uint8_t _flags;
108
109 /**
110 * @brief Reserved 4 bytes
111 */
112 uint32_t _reserved4B;
113
114 /*
115 * @brief The MRU callouts
116 */
117 std::vector<MRUCallout> _mrus;
118};
119
120} // namespace src
121} // namespace pels
122} // namespace openpower