Matt Spinler | 90b4a0a | 2019-10-09 10:08:43 -0500 | [diff] [blame] | 1 | #include "mru.hpp" |
| 2 | |
| 3 | #include <phosphor-logging/log.hpp> |
| 4 | |
| 5 | namespace openpower |
| 6 | { |
| 7 | namespace pels |
| 8 | { |
| 9 | namespace src |
| 10 | { |
| 11 | |
| 12 | using namespace phosphor::logging; |
| 13 | |
| 14 | MRU::MRU(Stream& pel) |
| 15 | { |
| 16 | pel >> _type >> _size >> _flags >> _reserved4B; |
| 17 | |
| 18 | size_t numMRUs = _flags & 0xF; |
| 19 | |
| 20 | for (size_t i = 0; i < numMRUs; i++) |
| 21 | { |
| 22 | MRUCallout mru; |
| 23 | pel >> mru.priority; |
| 24 | pel >> mru.id; |
| 25 | _mrus.push_back(std::move(mru)); |
| 26 | } |
| 27 | |
| 28 | size_t actualSize = sizeof(_type) + sizeof(_size) + sizeof(_flags) + |
| 29 | sizeof(_reserved4B) + |
| 30 | (sizeof(MRUCallout) * _mrus.size()); |
| 31 | if (_size != actualSize) |
| 32 | { |
| 33 | log<level::WARNING>("MRU callout section in PEL has listed size that " |
| 34 | "doesn't match actual size", |
| 35 | entry("SUBSTRUCTURE_SIZE=%lu", _size), |
| 36 | entry("NUM_MRUS=%lu", _mrus.size()), |
| 37 | entry("ACTUAL_SIZE=%lu", actualSize)); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | void MRU::flatten(Stream& pel) |
| 42 | { |
| 43 | pel << _type << _size << _flags << _reserved4B; |
| 44 | |
| 45 | for (auto& mru : _mrus) |
| 46 | { |
| 47 | pel << mru.priority; |
| 48 | pel << mru.id; |
| 49 | } |
| 50 | } |
| 51 | } // namespace src |
| 52 | } // namespace pels |
| 53 | } // namespace openpower |