-
-
-void
-SimpleTimingPort::schedSendTiming(PacketPtr pkt, Tick when)
-{
- assert(when > curTick);
- assert(when < curTick + Clock::Int::ms);
-
- // Nothing is on the list: add it and schedule an event
- if (transmitList.empty() || when < transmitList.front().tick) {
- transmitList.push_front(DeferredPacket(when, pkt));
- schedSendEvent(when);
- return;
- }
-
- // list is non-empty & this belongs at the end
- if (when >= transmitList.back().tick) {
- transmitList.push_back(DeferredPacket(when, pkt));
- return;
- }
-
- // this belongs in the middle somewhere
- DeferredPacketIterator i = transmitList.begin();
- i++; // already checked for insertion at front
- DeferredPacketIterator end = transmitList.end();
-
- for (; i != end; ++i) {
- if (when < i->tick) {
- transmitList.insert(i, DeferredPacket(when, pkt));
- return;
- }
- }
- assert(false); // should never get here
-}
-
-
-void
-SimpleTimingPort::sendDeferredPacket()
-{
- assert(deferredPacketReady());
- // take packet off list here; if recvTiming() on the other side
- // calls sendTiming() back on us (like SimpleTimingCpu does), then
- // we get confused by having a non-active packet on transmitList
- DeferredPacket dp = transmitList.front();
- transmitList.pop_front();
- bool success = sendTiming(dp.pkt);
-
- if (success) {
- if (!transmitList.empty() && !sendEvent->scheduled()) {
- Tick time = transmitList.front().tick;
- sendEvent->schedule(time <= curTick ? curTick+1 : time);
- }
-
- if (transmitList.empty() && drainEvent) {
- drainEvent->process();
- drainEvent = NULL;
- }
- } else {
- // Unsuccessful, need to put back on transmitList. Callee
- // should not have messed with it (since it didn't accept that
- // packet), so we can just push it back on the front.
- assert(!sendEvent->scheduled());
- transmitList.push_front(dp);
- }
-
- waitingOnRetry = !success;
-
- if (waitingOnRetry) {
- DPRINTF(Bus, "Send failed, waiting on retry\n");
- }
-}
-
-
-void
-SimpleTimingPort::recvRetry()
-{
- DPRINTF(Bus, "Received retry\n");
- assert(waitingOnRetry);
- sendDeferredPacket();
-}
-
-
-void
-SimpleTimingPort::processSendEvent()
-{
- assert(!waitingOnRetry);
- sendDeferredPacket();
-}
-
-
-unsigned int
-SimpleTimingPort::drain(Event *de)
-{
- if (transmitList.size() == 0)
- return 0;
- drainEvent = de;
- return 1;
-}