blob: caf3aec6b77042679569cbbaad8381d9d91fbc2b [file] [log] [blame]
Matt Spinler6c9662c2019-10-09 11:27:20 -05001#pragma once
2
3#include "fru_identity.hpp"
4#include "mru.hpp"
5#include "pce_identity.hpp"
6#include "stream.hpp"
7
8namespace openpower
9{
10namespace pels
11{
12namespace src
13{
14
15/**
16 * @class Callout
17 *
18 * Represents a single FRU callout in the SRC's FRU callout
19 * subsection.
20 *
21 * The 'Callouts' class holds a list of these objects.
22 *
23 * The callout priority and location code are in this structure.
24 *
25 * There can also be up to one each of three types of substructures
26 * in a single callout:
27 * * FRU Identity (must be first if present)
28 * * Power Controlling Enclosure (PCE)
29 * * Manufacturing Replaceable Unit (MRU)
30 *
31 * These substructures have their own objects managed by unique_ptrs
32 * which will only be allocated if those substructures exist.
33 */
34class Callout
35{
36 public:
37 Callout() = delete;
38 ~Callout() = default;
39 Callout(const Callout&) = delete;
40 Callout& operator=(const Callout&) = delete;
41 Callout(Callout&&) = delete;
42 Callout& operator=(Callout&&) = delete;
43
44 /**
45 * @brief Constructor
46 *
47 * Fills in this class's data fields from the stream.
48 *
49 * @param[in] pel - the PEL data stream
50 */
51 explicit Callout(Stream& pel);
52
53 /**
54 * @brief Returns the size of this object when flattened into a PEL
55 *
56 * @return size_t - The size of the section
57 */
58 size_t flattenedSize();
59
60 /**
61 * @brief Flatten the object into the stream
62 *
63 * @param[in] stream - The stream to write to
64 */
Matt Spinler724d0d82019-11-06 10:05:36 -060065 void flatten(Stream& pel) const;
Matt Spinler6c9662c2019-10-09 11:27:20 -050066
67 /**
Harisuddin Mohamed Isa0f717e12020-01-15 20:05:33 +080068 * @brief Returns the flags field of a callout
69 *
70 * @return uint8_t - The flags
71 */
72 uint8_t flags() const
73 {
74 return _flags;
75 }
76
77 /**
Matt Spinler6c9662c2019-10-09 11:27:20 -050078 * @brief Returns the priority field of a callout
79 *
80 * @return uint8_t - The priority
81 */
82 uint8_t priority() const
83 {
84 return _priority;
85 }
86
87 /**
88 * @brief Returns the location code of the callout
89 *
90 * @return std::string - The location code
91 */
92 std::string locationCode() const
93 {
94 std::string lc;
95 if (!_locationCode.empty())
96 {
97 // NULL terminated
98 lc = static_cast<const char*>(_locationCode.data());
99 }
100 return lc;
101 }
102
103 /**
104 * @brief Returns the FRU identity substructure
105 *
106 * @return const std::unique_ptr<FRUIdentity>&
107 */
108 const std::unique_ptr<FRUIdentity>& fruIdentity() const
109 {
110 return _fruIdentity;
111 }
112
113 /**
114 * @brief Returns the PCE identity substructure
115 *
116 * @return const std::unique_ptr<PCEIdentity>&
117 */
118 const std::unique_ptr<PCEIdentity>& pceIdentity() const
119 {
120 return _pceIdentity;
121 }
122
123 /**
124 * @brief Returns the MRU identity substructure
125 *
126 * @return const std::unique_ptr<FRUIdentity>&
127 */
128 const std::unique_ptr<MRU>& mru() const
129 {
130 return _mru;
131 }
132
133 private:
134 /**
135 * @brief The size of this structure in the PEL
136 */
137 uint8_t _size;
138
139 /**
140 * @brief The flags byte of this structure
141 */
142 uint8_t _flags;
143
144 /**
145 * @brief The replacement priority
146 */
147 uint8_t _priority;
148
149 /**
150 * @brief The length of the location code field.
151 *
152 * Includes the NULL termination, and must be a
153 * multiple of 4 (padded with zeros)
154 */
155 uint8_t _locationCodeSize;
156
157 /**
158 * @brief NULL terminated location code
159 *
160 * Includes the NULL termination, and must be a
161 * multiple of 4 (padded with zeros)
162 */
163 std::vector<char> _locationCode;
164
165 /**
166 * @brief FRU (Field Replaceable Unit) Identity substructure
167 */
168 std::unique_ptr<FRUIdentity> _fruIdentity;
169
170 /**
171 * @brief PCE (Power Controlling Enclosure) Identity substructure
172 */
173 std::unique_ptr<PCEIdentity> _pceIdentity;
174
175 /**
176 * @brief MRU (Manufacturing Replaceable Unit) substructure
177 */
178 std::unique_ptr<MRU> _mru;
179};
180
181} // namespace src
182} // namespace pels
183} // namespace openpower