blob: ea28b7b295067397c9aaa6253d79b46dcfe99a38 [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 */
65 void flatten(Stream& pel);
66
67 /**
68 * @brief Returns the priority field of a callout
69 *
70 * @return uint8_t - The priority
71 */
72 uint8_t priority() const
73 {
74 return _priority;
75 }
76
77 /**
78 * @brief Returns the location code of the callout
79 *
80 * @return std::string - The location code
81 */
82 std::string locationCode() const
83 {
84 std::string lc;
85 if (!_locationCode.empty())
86 {
87 // NULL terminated
88 lc = static_cast<const char*>(_locationCode.data());
89 }
90 return lc;
91 }
92
93 /**
94 * @brief Returns the FRU identity substructure
95 *
96 * @return const std::unique_ptr<FRUIdentity>&
97 */
98 const std::unique_ptr<FRUIdentity>& fruIdentity() const
99 {
100 return _fruIdentity;
101 }
102
103 /**
104 * @brief Returns the PCE identity substructure
105 *
106 * @return const std::unique_ptr<PCEIdentity>&
107 */
108 const std::unique_ptr<PCEIdentity>& pceIdentity() const
109 {
110 return _pceIdentity;
111 }
112
113 /**
114 * @brief Returns the MRU identity substructure
115 *
116 * @return const std::unique_ptr<FRUIdentity>&
117 */
118 const std::unique_ptr<MRU>& mru() const
119 {
120 return _mru;
121 }
122
123 private:
124 /**
125 * @brief The size of this structure in the PEL
126 */
127 uint8_t _size;
128
129 /**
130 * @brief The flags byte of this structure
131 */
132 uint8_t _flags;
133
134 /**
135 * @brief The replacement priority
136 */
137 uint8_t _priority;
138
139 /**
140 * @brief The length of the location code field.
141 *
142 * Includes the NULL termination, and must be a
143 * multiple of 4 (padded with zeros)
144 */
145 uint8_t _locationCodeSize;
146
147 /**
148 * @brief NULL terminated location code
149 *
150 * Includes the NULL termination, and must be a
151 * multiple of 4 (padded with zeros)
152 */
153 std::vector<char> _locationCode;
154
155 /**
156 * @brief FRU (Field Replaceable Unit) Identity substructure
157 */
158 std::unique_ptr<FRUIdentity> _fruIdentity;
159
160 /**
161 * @brief PCE (Power Controlling Enclosure) Identity substructure
162 */
163 std::unique_ptr<PCEIdentity> _pceIdentity;
164
165 /**
166 * @brief MRU (Manufacturing Replaceable Unit) substructure
167 */
168 std::unique_ptr<MRU> _mru;
169};
170
171} // namespace src
172} // namespace pels
173} // namespace openpower