tport.cc revision 2914
12810SN/A/*
22810SN/A * Copyright (c) 2006 The Regents of The University of Michigan
32810SN/A * All rights reserved.
42810SN/A *
52810SN/A * Redistribution and use in source and binary forms, with or without
62810SN/A * modification, are permitted provided that the following conditions are
72810SN/A * met: redistributions of source code must retain the above copyright
82810SN/A * notice, this list of conditions and the following disclaimer;
92810SN/A * redistributions in binary form must reproduce the above copyright
102810SN/A * notice, this list of conditions and the following disclaimer in the
112810SN/A * documentation and/or other materials provided with the distribution;
122810SN/A * neither the name of the copyright holders nor the names of its
132810SN/A * contributors may be used to endorse or promote products derived from
142810SN/A * this software without specific prior written permission.
152810SN/A *
162810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272810SN/A *
282810SN/A * Authors: Ali Saidi
292810SN/A */
302810SN/A
312810SN/A#include "mem/tport.hh"
322810SN/A
332810SN/Avoid
342810SN/ASimpleTimingPort::recvRetry()
352810SN/A{
362810SN/A    bool result = true;
372810SN/A    while (result && transmitList.size()) {
382810SN/A        result = Port::sendTiming(transmitList.front());
392810SN/A        if (result)
404666SN/A            transmitList.pop_front();
412810SN/A    }
425338Sstever@gmail.com   if (transmitList.size() == 0 && drainEvent) {
434167SN/A       drainEvent->process();
442810SN/A       drainEvent = NULL;
452810SN/A   }
462810SN/A}
472810SN/A
482810SN/Avoid
492810SN/ASimpleTimingPort::SendEvent::process()
502810SN/A{
512810SN/A    port->outTiming--;
522810SN/A    assert(port->outTiming >= 0);
532810SN/A    if (port->Port::sendTiming(packet))
542813SN/A       if (port->transmitList.size() == 0 && port->drainEvent) {
554903SN/A           port->drainEvent->process();
564903SN/A           port->drainEvent = NULL;
572810SN/A       }
582810SN/A       return;
594903SN/A
604903SN/A    port->transmitList.push_back(packet);
614903SN/A}
624903SN/A
634903SN/Avoid
644903SN/ASimpleTimingPort::resendNacked(Packet *pkt) {
654903SN/A    pkt->reinitNacked();
664908SN/A    if (transmitList.size()) {
675875Ssteve.reinhardt@amd.com         transmitList.push_front(pkt);
684903SN/A    } else {
695875Ssteve.reinhardt@amd.com        if (!Port::sendTiming(pkt))
704903SN/A            transmitList.push_front(pkt);
714903SN/A    }
724903SN/A};
734903SN/A
744903SN/A
754903SN/Aunsigned int
764903SN/ASimpleTimingPort::drain(Event *de)
775318SN/A{
784908SN/A    if (outTiming == 0 && transmitList.size() == 0)
795318SN/A        return 0;
804908SN/A    drainEvent = de;
814908SN/A    return 1;
824908SN/A}
834908SN/A