1 /**
2  * Copyright © 2019 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "pce_identity.hpp"
17 
18 namespace openpower
19 {
20 namespace pels
21 {
22 namespace src
23 {
24 
PCEIdentity(Stream & pel)25 PCEIdentity::PCEIdentity(Stream& pel)
26 {
27     pel >> _type >> _size >> _flags >> _mtms;
28 
29     // Whatever is left is the enclosure name.
30     if (_size < (4 + _mtms.flattenedSize()))
31     {
32         throw std::runtime_error("PCE identity structure size field too small");
33     }
34 
35     size_t pceNameSize = _size - (4 + _mtms.flattenedSize());
36 
37     _pceName.resize(pceNameSize);
38     pel >> _pceName;
39 }
40 
flatten(Stream & pel) const41 void PCEIdentity::flatten(Stream& pel) const
42 {
43     pel << _type << _size << _flags << _mtms << _pceName;
44 }
45 
46 } // namespace src
47 } // namespace pels
48 } // namespace openpower
49