blob: 89e0cfe328f7401f31c14e513f703e7f15d6a64f [file] [log] [blame]
Matt Spinler90b4a0a2019-10-09 10:08:43 -05001#include "mru.hpp"
2
3#include <phosphor-logging/log.hpp>
4
5namespace openpower
6{
7namespace pels
8{
9namespace src
10{
11
12using namespace phosphor::logging;
13
14MRU::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
41void 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