Matt Spinler | 90b4a0a | 2019-10-09 10:08:43 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "stream.hpp" |
| 4 | |
| 5 | namespace openpower |
| 6 | { |
| 7 | namespace pels |
| 8 | { |
| 9 | namespace 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 | */ |
| 25 | class 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 | /** |
Matt Spinler | 5ab3997 | 2020-08-13 13:02:28 -0500 | [diff] [blame] | 60 | * @brief Constructor |
| 61 | * |
| 62 | * Creates the object using the passed in MRUs |
| 63 | * |
| 64 | * @param[in] mrus - The MRUs |
| 65 | */ |
| 66 | explicit MRU(const std::vector<MRUCallout>& mrus); |
| 67 | |
| 68 | /** |
Matt Spinler | 90b4a0a | 2019-10-09 10:08:43 -0500 | [diff] [blame] | 69 | * @brief Flatten the object into the stream |
| 70 | * |
| 71 | * @param[in] stream - The stream to write to |
| 72 | */ |
Matt Spinler | 724d0d8 | 2019-11-06 10:05:36 -0600 | [diff] [blame] | 73 | void flatten(Stream& pel) const; |
Matt Spinler | 90b4a0a | 2019-10-09 10:08:43 -0500 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * @brief Returns the size of this structure when flattened into a PEL |
| 77 | * |
| 78 | * @return size_t - The size of the section |
| 79 | */ |
| 80 | size_t flattenedSize() const |
| 81 | { |
| 82 | return _size; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * @brief Returns the contained MRU callouts. |
| 87 | * |
| 88 | * @return const std::vector<MRUCallout>& - The MRUs |
| 89 | */ |
| 90 | const std::vector<MRUCallout>& mrus() const |
| 91 | { |
| 92 | return _mrus; |
| 93 | } |
| 94 | |
| 95 | /** |
Matt Spinler | 5ab3997 | 2020-08-13 13:02:28 -0500 | [diff] [blame] | 96 | * @brief Returns the size field |
| 97 | * |
| 98 | * @return size_t - The size of the MRU substructure |
| 99 | */ |
| 100 | size_t size() const |
| 101 | { |
| 102 | return _size; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @brief Returns the flags field |
| 107 | * |
| 108 | * @return uint8_t - The flags |
| 109 | */ |
| 110 | uint8_t flags() const |
| 111 | { |
| 112 | return _flags; |
| 113 | } |
| 114 | |
| 115 | /** |
Matt Spinler | 90b4a0a | 2019-10-09 10:08:43 -0500 | [diff] [blame] | 116 | * @brief The type identifier value of this structure. |
| 117 | */ |
| 118 | static const uint16_t substructureType = 0x4D52; // "MR" |
| 119 | |
| 120 | private: |
| 121 | /** |
| 122 | * @brief The callout substructure type field. Will be 'MR'. |
| 123 | */ |
| 124 | uint16_t _type; |
| 125 | |
| 126 | /** |
| 127 | * @brief The size of this callout structure. |
| 128 | */ |
| 129 | uint8_t _size; |
| 130 | |
| 131 | /** |
| 132 | * @brief The flags byte of this substructure. |
| 133 | * |
| 134 | * 0x0Y: Y = number of MRU callouts |
| 135 | */ |
| 136 | uint8_t _flags; |
| 137 | |
| 138 | /** |
| 139 | * @brief Reserved 4 bytes |
| 140 | */ |
| 141 | uint32_t _reserved4B; |
| 142 | |
| 143 | /* |
| 144 | * @brief The MRU callouts |
| 145 | */ |
| 146 | std::vector<MRUCallout> _mrus; |
| 147 | }; |
| 148 | |
| 149 | } // namespace src |
| 150 | } // namespace pels |
| 151 | } // namespace openpower |