blob: 6a6f257be0f08bc4ab29803631a035dec75f85d9 [file] [log] [blame]
Matt Spinler711d51d2019-11-06 09:36:51 -06001/**
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 */
Matt Spinler5b3a11d2019-10-08 14:13:31 -050016#include "pce_identity.hpp"
17
18namespace openpower
19{
20namespace pels
21{
22namespace src
23{
24
25PCEIdentity::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
Matt Spinler724d0d82019-11-06 10:05:36 -060041void PCEIdentity::flatten(Stream& pel) const
Matt Spinler5b3a11d2019-10-08 14:13:31 -050042{
43 pel << _type << _size << _flags << _mtms << _pceName;
44}
45
46} // namespace src
47} // namespace pels
48} // namespace openpower