diff options
author | Gabe Black <gblack@eecs.umich.edu> | 2006-02-28 06:03:57 -0500 |
---|---|---|
committer | Gabe Black <gblack@eecs.umich.edu> | 2006-02-28 06:03:57 -0500 |
commit | d207168eda13483a2990cdf060c1a7ead42cc9da (patch) | |
tree | 18383564b534a5fe6a7ba73bdc179fa249788013 /dev/pktfifo.cc | |
parent | e5f75c2549d4881284202208c09e881886f4fdd4 (diff) | |
parent | 29f50d934549f10b073a5492bd0d441d71534ace (diff) | |
download | gem5-d207168eda13483a2990cdf060c1a7ead42cc9da.tar.xz |
Merge zizzer.eecs.umich.edu:/z/m5/Bitkeeper/m5
into zizzer.eecs.umich.edu:/z/m5/Bitkeeper/multiarch
--HG--
extra : convert_revision : 3a3ff8fcf472db385219a00ae434d1f3fea43b18
Diffstat (limited to 'dev/pktfifo.cc')
-rw-r--r-- | dev/pktfifo.cc | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/dev/pktfifo.cc b/dev/pktfifo.cc index b4fab2d6f..639009be9 100644 --- a/dev/pktfifo.cc +++ b/dev/pktfifo.cc @@ -31,6 +31,36 @@ using namespace std; +bool +PacketFifo::copyout(void *dest, int offset, int len) +{ + char *data = (char *)dest; + if (offset + len >= size()) + return false; + + list<PacketPtr>::iterator p = fifo.begin(); + list<PacketPtr>::iterator end = fifo.end(); + while (len > 0) { + while (offset >= (*p)->length) { + offset -= (*p)->length; + ++p; + } + + if (p == end) + panic("invalid fifo"); + + int size = min((*p)->length - offset, len); + memcpy(data, (*p)->data, size); + offset = 0; + len -= size; + data += size; + ++p; + } + + return true; +} + + void PacketFifo::serialize(const string &base, ostream &os) { @@ -40,8 +70,8 @@ PacketFifo::serialize(const string &base, ostream &os) paramOut(os, base + ".packets", fifo.size()); int i = 0; - std::list<PacketPtr>::iterator p = fifo.begin(); - std::list<PacketPtr>::iterator end = fifo.end(); + list<PacketPtr>::iterator p = fifo.begin(); + list<PacketPtr>::iterator end = fifo.end(); while (p != end) { (*p)->serialize(csprintf("%s.packet%d", base, i), os); ++p; |