dev: Make serialization in Sinic constant
This changeset transitions the Sinic device to the new serialization framework that requires the serialization method to be constant.
This commit is contained in:
parent
53e777d683
commit
af6b51925c
|
@ -80,6 +80,7 @@ class PacketFifo
|
||||||
|
|
||||||
typedef std::list<PacketFifoEntry> fifo_list;
|
typedef std::list<PacketFifoEntry> fifo_list;
|
||||||
typedef fifo_list::iterator iterator;
|
typedef fifo_list::iterator iterator;
|
||||||
|
typedef fifo_list::const_iterator const_iterator;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::list<PacketFifoEntry> fifo;
|
std::list<PacketFifoEntry> fifo;
|
||||||
|
@ -112,6 +113,9 @@ class PacketFifo
|
||||||
iterator begin() { return fifo.begin(); }
|
iterator begin() { return fifo.begin(); }
|
||||||
iterator end() { return fifo.end(); }
|
iterator end() { return fifo.end(); }
|
||||||
|
|
||||||
|
const_iterator begin() const { return fifo.begin(); }
|
||||||
|
const_iterator end() const { return fifo.end(); }
|
||||||
|
|
||||||
EthPacketPtr front() { return fifo.begin()->packet; }
|
EthPacketPtr front() { return fifo.begin()->packet; }
|
||||||
|
|
||||||
bool push(EthPacketPtr ptr)
|
bool push(EthPacketPtr ptr)
|
||||||
|
@ -171,25 +175,25 @@ class PacketFifo
|
||||||
|
|
||||||
bool copyout(void *dest, unsigned offset, unsigned len);
|
bool copyout(void *dest, unsigned offset, unsigned len);
|
||||||
|
|
||||||
int countPacketsBefore(iterator i)
|
int countPacketsBefore(const_iterator i) const
|
||||||
{
|
{
|
||||||
if (i == fifo.end())
|
if (i == fifo.end())
|
||||||
return 0;
|
return 0;
|
||||||
return i->number - fifo.begin()->number;
|
return i->number - fifo.begin()->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int countPacketsAfter(iterator i)
|
int countPacketsAfter(const_iterator i) const
|
||||||
{
|
{
|
||||||
iterator end = fifo.end();
|
auto end = fifo.end();
|
||||||
if (i == end)
|
if (i == end)
|
||||||
return 0;
|
return 0;
|
||||||
return (--end)->number - i->number;
|
return (--end)->number - i->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
void check()
|
void check() const
|
||||||
{
|
{
|
||||||
unsigned total = 0;
|
unsigned total = 0;
|
||||||
for (iterator i = begin(); i != end(); ++i)
|
for (auto i = begin(); i != end(); ++i)
|
||||||
total += i->packet->length + i->slack;
|
total += i->packet->length + i->slack;
|
||||||
|
|
||||||
if (total != _size)
|
if (total != _size)
|
||||||
|
|
|
@ -1303,7 +1303,7 @@ Base::unserialize(CheckpointIn &cp)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Device::serializeOld(CheckpointOut &cp)
|
Device::serialize(CheckpointOut &cp) const
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
|
@ -1345,7 +1345,7 @@ Device::serializeOld(CheckpointOut &cp)
|
||||||
paramOut(cp, reg + ".rxPacketExists", rxPacketExists);
|
paramOut(cp, reg + ".rxPacketExists", rxPacketExists);
|
||||||
if (rxPacketExists) {
|
if (rxPacketExists) {
|
||||||
int rxPacket = 0;
|
int rxPacket = 0;
|
||||||
PacketFifo::iterator i = rxFifo.begin();
|
auto i = rxFifo.begin();
|
||||||
while (i != vnic->rxIndex) {
|
while (i != vnic->rxIndex) {
|
||||||
assert(i != rxFifo.end());
|
assert(i != rxFifo.end());
|
||||||
++i;
|
++i;
|
||||||
|
@ -1369,7 +1369,7 @@ Device::serializeOld(CheckpointOut &cp)
|
||||||
SERIALIZE_SCALAR(rxDirtyCount);
|
SERIALIZE_SCALAR(rxDirtyCount);
|
||||||
SERIALIZE_SCALAR(rxMappedCount);
|
SERIALIZE_SCALAR(rxMappedCount);
|
||||||
|
|
||||||
VirtualList::iterator i, end;
|
VirtualList::const_iterator i, end;
|
||||||
for (count = 0, i = rxList.begin(), end = rxList.end(); i != end; ++i)
|
for (count = 0, i = rxList.begin(), end = rxList.end(); i != end; ++i)
|
||||||
paramOut(cp, csprintf("rxList%d", count++), *i);
|
paramOut(cp, csprintf("rxList%d", count++), *i);
|
||||||
int rxListSize = count;
|
int rxListSize = count;
|
||||||
|
|
|
@ -297,7 +297,7 @@ class Device : public Base
|
||||||
* Serialization stuff
|
* Serialization stuff
|
||||||
*/
|
*/
|
||||||
public:
|
public:
|
||||||
void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
|
void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
|
||||||
void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
|
void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue