blob: 6b7dbc79dcf1648f65069ad8880efd45600635b3 [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"
Matt Spinler0a5d10c2020-03-13 12:54:02 -05006#include "pel_types.hpp"
Matt Spinler6c9662c2019-10-09 11:27:20 -05007#include "stream.hpp"
8
9namespace openpower
10{
11namespace pels
12{
13namespace src
14{
15
16/**
17 * @class Callout
18 *
19 * Represents a single FRU callout in the SRC's FRU callout
20 * subsection.
21 *
22 * The 'Callouts' class holds a list of these objects.
23 *
24 * The callout priority and location code are in this structure.
25 *
26 * There can also be up to one each of three types of substructures
27 * in a single callout:
28 * * FRU Identity (must be first if present)
29 * * Power Controlling Enclosure (PCE)
30 * * Manufacturing Replaceable Unit (MRU)
31 *
32 * These substructures have their own objects managed by unique_ptrs
33 * which will only be allocated if those substructures exist.
34 */
35class Callout
36{
37 public:
Matt Spinler0a5d10c2020-03-13 12:54:02 -050038 /**
39 * @brief Which callout substructures are included.
40 */
41 enum calloutFlags
42 {
43 calloutType = 0b0010'0000,
44 fruIdentIncluded = 0b0000'1000,
45 mruIncluded = 0b0000'0100
46
47 // Leaving out the various PCE identity ones since
48 // we don't use them.
49 };
50
Matt Spinler6c9662c2019-10-09 11:27:20 -050051 Callout() = delete;
52 ~Callout() = default;
53 Callout(const Callout&) = delete;
54 Callout& operator=(const Callout&) = delete;
55 Callout(Callout&&) = delete;
56 Callout& operator=(Callout&&) = delete;
57
58 /**
59 * @brief Constructor
60 *
61 * Fills in this class's data fields from the stream.
62 *
63 * @param[in] pel - the PEL data stream
64 */
65 explicit Callout(Stream& pel);
66
67 /**
Matt Spinler0a5d10c2020-03-13 12:54:02 -050068 * @brief Constructor
69 *
70 * Creates the objects with a FRUIdentity substructure that calls
71 * out a normal hardware FRU.
72 *
73 * @param[in] priority - The priority of the callout
74 * @param[in] locationCode - The location code of the callout
75 * @param[in] partNumber - The part number of the callout
76 * @param[in] ccin - The CCIN of the callout
77 * @param[in] serialNumber - The serial number of the callout
78 */
79 Callout(CalloutPriority priority, const std::string& locationCode,
80 const std::string& partNumber, const std::string& ccin,
81 const std::string& serialNumber);
82
83 /**
84 * @brief Constructor
85 *
86 * Creates the objects with a FRUIdentity substructure that calls
87 * out maintenance procedure.
88 *
89 * @param[in] priority - The priority of the callout
Matt Spinlera27e2e52020-04-09 11:06:11 -050090 * @param[in] procedureFromRegistry - The maintenance procedure name
91 * as defined in the message registry.
Matt Spinler0a5d10c2020-03-13 12:54:02 -050092 */
Matt Spinlera27e2e52020-04-09 11:06:11 -050093 Callout(CalloutPriority priority, const std::string& procedureFromRegistry);
Matt Spinler0a5d10c2020-03-13 12:54:02 -050094
95 /**
Matt Spinler6c9662c2019-10-09 11:27:20 -050096 * @brief Returns the size of this object when flattened into a PEL
97 *
98 * @return size_t - The size of the section
99 */
Matt Spinler0a5d10c2020-03-13 12:54:02 -0500100 size_t flattenedSize() const;
Matt Spinler6c9662c2019-10-09 11:27:20 -0500101
102 /**
103 * @brief Flatten the object into the stream
104 *
105 * @param[in] stream - The stream to write to
106 */
Matt Spinler724d0d82019-11-06 10:05:36 -0600107 void flatten(Stream& pel) const;
Matt Spinler6c9662c2019-10-09 11:27:20 -0500108
109 /**
Harisuddin Mohamed Isa0f717e12020-01-15 20:05:33 +0800110 * @brief Returns the flags field of a callout
111 *
112 * @return uint8_t - The flags
113 */
114 uint8_t flags() const
115 {
116 return _flags;
117 }
118
119 /**
Matt Spinler6c9662c2019-10-09 11:27:20 -0500120 * @brief Returns the priority field of a callout
121 *
122 * @return uint8_t - The priority
123 */
124 uint8_t priority() const
125 {
126 return _priority;
127 }
128
129 /**
130 * @brief Returns the location code of the callout
131 *
132 * @return std::string - The location code
133 */
134 std::string locationCode() const
135 {
136 std::string lc;
137 if (!_locationCode.empty())
138 {
139 // NULL terminated
140 lc = static_cast<const char*>(_locationCode.data());
141 }
142 return lc;
143 }
144
145 /**
Matt Spinler0a5d10c2020-03-13 12:54:02 -0500146 * @brief Returns the location code size
147 *
148 * @return size_t - The size, including the terminating null.
149 */
150 size_t locationCodeSize() const
151 {
152 return _locationCodeSize;
153 }
154
155 /**
Matt Spinler6c9662c2019-10-09 11:27:20 -0500156 * @brief Returns the FRU identity substructure
157 *
158 * @return const std::unique_ptr<FRUIdentity>&
159 */
160 const std::unique_ptr<FRUIdentity>& fruIdentity() const
161 {
162 return _fruIdentity;
163 }
164
165 /**
166 * @brief Returns the PCE identity substructure
167 *
168 * @return const std::unique_ptr<PCEIdentity>&
169 */
170 const std::unique_ptr<PCEIdentity>& pceIdentity() const
171 {
172 return _pceIdentity;
173 }
174
175 /**
176 * @brief Returns the MRU identity substructure
177 *
Matt Spinler0a5d10c2020-03-13 12:54:02 -0500178 * @return const std::unique_ptr<MRU>&
Matt Spinler6c9662c2019-10-09 11:27:20 -0500179 */
180 const std::unique_ptr<MRU>& mru() const
181 {
182 return _mru;
183 }
184
185 private:
186 /**
Matt Spinler0a5d10c2020-03-13 12:54:02 -0500187 * @brief Sets the location code field
188 *
189 * @param[in] locationCode - The location code string
190 */
191 void setLocationCode(const std::string& locationCode);
192
193 /**
Matt Spinler6c9662c2019-10-09 11:27:20 -0500194 * @brief The size of this structure in the PEL
195 */
196 uint8_t _size;
197
198 /**
199 * @brief The flags byte of this structure
200 */
201 uint8_t _flags;
202
203 /**
204 * @brief The replacement priority
205 */
206 uint8_t _priority;
207
208 /**
209 * @brief The length of the location code field.
210 *
211 * Includes the NULL termination, and must be a
212 * multiple of 4 (padded with zeros)
213 */
Matt Spinler0a5d10c2020-03-13 12:54:02 -0500214 uint8_t _locationCodeSize = 0;
Matt Spinler6c9662c2019-10-09 11:27:20 -0500215
216 /**
217 * @brief NULL terminated location code
218 *
219 * Includes the NULL termination, and must be a
220 * multiple of 4 (padded with zeros)
221 */
222 std::vector<char> _locationCode;
223
224 /**
225 * @brief FRU (Field Replaceable Unit) Identity substructure
226 */
227 std::unique_ptr<FRUIdentity> _fruIdentity;
228
229 /**
230 * @brief PCE (Power Controlling Enclosure) Identity substructure
231 */
232 std::unique_ptr<PCEIdentity> _pceIdentity;
233
234 /**
235 * @brief MRU (Manufacturing Replaceable Unit) substructure
236 */
237 std::unique_ptr<MRU> _mru;
238};
239
240} // namespace src
241} // namespace pels
242} // namespace openpower