summaryrefslogtreecommitdiff
path: root/dev/pktfifo.cc
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2006-02-28 06:13:35 -0500
committerGabe Black <gblack@eecs.umich.edu>2006-02-28 06:13:35 -0500
commitf7360d5bca61baf4539698faf08fc36113c4fb33 (patch)
tree1551252d2ea703d26c39eddcd21e752eb94a148c /dev/pktfifo.cc
parent299efffaf5eb5fb55b2109a643e1e0e985f89ce6 (diff)
parentd207168eda13483a2990cdf060c1a7ead42cc9da (diff)
downloadgem5-f7360d5bca61baf4539698faf08fc36113c4fb33.tar.xz
Merge gblack@m5.eecs.umich.edu:/bk/multiarch
into ewok.(none):/home/gblack/m5/multiarch --HG-- extra : convert_revision : 0b3ffc0605c9043d7f5bf6c15f4a3c68846a732a
Diffstat (limited to 'dev/pktfifo.cc')
-rw-r--r--dev/pktfifo.cc34
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;