Matt Spinler | 711d51d | 2019-11-06 09:36:51 -0600 | [diff] [blame] | 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 | */ |
Matt Spinler | 5b3a11d | 2019-10-08 14:13:31 -0500 | [diff] [blame] | 16 | #include "pce_identity.hpp" |
| 17 | |
| 18 | namespace openpower |
| 19 | { |
| 20 | namespace pels |
| 21 | { |
| 22 | namespace src |
| 23 | { |
| 24 | |
| 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 | |
Matt Spinler | 724d0d8 | 2019-11-06 10:05:36 -0600 | [diff] [blame] | 41 | void PCEIdentity::flatten(Stream& pel) const |
Matt Spinler | 5b3a11d | 2019-10-08 14:13:31 -0500 | [diff] [blame] | 42 | { |
| 43 | pel << _type << _size << _flags << _mtms << _pceName; |
| 44 | } |
| 45 | |
| 46 | } // namespace src |
| 47 | } // namespace pels |
| 48 | } // namespace openpower |