xref: /openbmc/phosphor-logging/extensions/openpower-pels/pce_identity.cpp (revision 40fb54935ce7367636a7156039396ee91cc4d5e2)
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: Copyright 2019 IBM Corporation
3 
4 #include "pce_identity.hpp"
5 
6 namespace openpower
7 {
8 namespace pels
9 {
10 namespace src
11 {
12 
PCEIdentity(Stream & pel)13 PCEIdentity::PCEIdentity(Stream& pel)
14 {
15     pel >> _type >> _size >> _flags >> _mtms;
16 
17     // Whatever is left is the enclosure name.
18     if (_size < (4 + _mtms.flattenedSize()))
19     {
20         throw std::runtime_error("PCE identity structure size field too small");
21     }
22 
23     size_t pceNameSize = _size - (4 + _mtms.flattenedSize());
24 
25     _pceName.resize(pceNameSize);
26     pel >> _pceName;
27 }
28 
flatten(Stream & pel) const29 void PCEIdentity::flatten(Stream& pel) const
30 {
31     pel << _type << _size << _flags << _mtms << _pceName;
32 }
33 
34 } // namespace src
35 } // namespace pels
36 } // namespace openpower
37