pktfifo.cc revision 1762
17949SAli.Saidi@ARM.com/*
27949SAli.Saidi@ARM.com * Copyright (c) 2004-2005 The Regents of The University of Michigan
37949SAli.Saidi@ARM.com * All rights reserved.
47949SAli.Saidi@ARM.com *
57949SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without
67949SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are
77949SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright
87949SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer;
97949SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright
107949SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the
117949SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution;
127949SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its
137949SAli.Saidi@ARM.com * contributors may be used to endorse or promote products derived from
147949SAli.Saidi@ARM.com * this software without specific prior written permission.
157949SAli.Saidi@ARM.com *
167949SAli.Saidi@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
177949SAli.Saidi@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
187949SAli.Saidi@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
197949SAli.Saidi@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
207949SAli.Saidi@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217949SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
227949SAli.Saidi@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237949SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
247949SAli.Saidi@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
257949SAli.Saidi@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
267949SAli.Saidi@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
277949SAli.Saidi@ARM.com */
287949SAli.Saidi@ARM.com
297949SAli.Saidi@ARM.com#include "base/misc.hh"
307949SAli.Saidi@ARM.com#include "dev/pktfifo.hh"
317949SAli.Saidi@ARM.com
327949SAli.Saidi@ARM.comusing namespace std;
337949SAli.Saidi@ARM.com
347949SAli.Saidi@ARM.comvoid
357949SAli.Saidi@ARM.comPacketFifo::serialize(const string &base, ostream &os)
367949SAli.Saidi@ARM.com{
377949SAli.Saidi@ARM.com    paramOut(os, base + ".size", _size);
387949SAli.Saidi@ARM.com    paramOut(os, base + ".maxsize", _maxsize);
397949SAli.Saidi@ARM.com    paramOut(os, base + ".reserved", _reserved);
407949SAli.Saidi@ARM.com    paramOut(os, base + ".packets", fifo.size());
417949SAli.Saidi@ARM.com
427949SAli.Saidi@ARM.com    int i = 0;
437949SAli.Saidi@ARM.com    std::list<PacketPtr>::iterator p = fifo.begin();
449330Schander.sudanthi@arm.com    std::list<PacketPtr>::iterator end = fifo.end();
459330Schander.sudanthi@arm.com    while (p != end) {
468739Sgblack@eecs.umich.edu        (*p)->serialize(csprintf("%s.packet%d", base, i), os);
478739Sgblack@eecs.umich.edu        ++p;
48        ++i;
49    }
50}
51
52void
53PacketFifo::unserialize(const string &base, Checkpoint *cp,
54                        const string &section)
55{
56    paramIn(cp, section, base + ".size", _size);
57//  paramIn(cp, section, base + ".maxsize", _maxsize);
58    paramIn(cp, section, base + ".reserved", _reserved);
59    int fifosize;
60    paramIn(cp, section, base + ".packets", fifosize);
61
62    fifo.clear();
63
64    for (int i = 0; i < fifosize; ++i) {
65        PacketPtr p = new PacketData(16384);
66        p->unserialize(csprintf("%s.packet%d", base, i), cp, section);
67        fifo.push_back(p);
68    }
69}
70