blob: 60c878e79602a8b4fe58029e735f4039a57e2d33 [file] [log] [blame]
Matt Spinler5b3a11d2019-10-08 14:13:31 -05001#pragma once
2
3#include "mtms.hpp"
4#include "stream.hpp"
5
6namespace openpower
7{
8namespace pels
9{
10namespace src
11{
12
13/**
14 * @class PCEIdentity
15 *
16 * This represents the PCE (Power Controlling Enclosure) Identity
17 * substructure in the callout subsection of the SRC PEL section.
18 *
19 * It contains the name and machine type/model/SN of that enclosure.
20 *
21 * It is only used for errors in an I/O drawer where another enclosure
22 * may control its power. It is not used in BMC errors and so will
23 * never be created by the BMC, but only unflattened in errors it
24 * receives from the host.
25 */
26class PCEIdentity
27{
28 public:
29 PCEIdentity() = delete;
30 ~PCEIdentity() = default;
31 PCEIdentity(const PCEIdentity&) = default;
32 PCEIdentity& operator=(const PCEIdentity&) = default;
33 PCEIdentity(PCEIdentity&&) = default;
34 PCEIdentity& operator=(PCEIdentity&&) = default;
35
36 /**
37 * @brief Constructor
38 *
39 * Fills in this class's data fields from the stream.
40 *
41 * @param[in] pel - the PEL data stream
42 */
43 explicit PCEIdentity(Stream& pel);
44
45 /**
46 * @brief Flatten the object into the stream
47 *
48 * @param[in] stream - The stream to write to
49 */
Matt Spinler724d0d82019-11-06 10:05:36 -060050 void flatten(Stream& pel) const;
Matt Spinler5b3a11d2019-10-08 14:13:31 -050051
52 /**
53 * @brief Returns the size of this structure when flattened into a PEL
54 *
55 * @return size_t - The size of the structure
56 */
57 size_t flattenedSize()
58 {
59 return _size;
60 }
61
62 /**
63 * @brief The type identifier value of this structure.
64 */
65 static const uint16_t substructureType = 0x5045; // "PE"
66
67 /**
68 * @brief Returns the enclosure name
69 *
70 * @return std::string - The enclosure name
71 */
72 std::string enclosureName() const
73 {
74 // _pceName is NULL terminated
75 std::string name{static_cast<const char*>(_pceName.data())};
76 return name;
77 }
78
79 /**
80 * @brief Returns the MTMS sub structure
81 *
82 * @return const MTMS& - The machine type/model/SN structure.
83 */
84 const MTMS& mtms() const
85 {
86 return _mtms;
87 }
88
89 private:
90 /**
91 * @brief The callout substructure type field. Will be 'PE'.
92 */
93 uint16_t _type;
94
95 /**
96 * @brief The size of this callout structure.
97 *
98 * Always a multiple of 4.
99 */
100 uint8_t _size;
101
102 /**
103 * @brief The flags byte of this substructure.
104 *
105 * Always 0 for this structure.
106 */
107 uint8_t _flags;
108
109 /**
110 * @brief The structure that holds the power controlling enclosure's
111 * machine type, model, and serial number.
112 */
113 MTMS _mtms;
114
115 /**
116 * @brief The name of the power controlling enclosure.
117 *
118 * Null terminated and padded with NULLs to a 4 byte boundary.
119 */
120 std::vector<char> _pceName;
121};
122
123} // namespace src
124} // namespace pels
125} // namespace openpower