tport.hh (3476:0e26b5458236) | tport.hh (4490:f9d3db907eec) |
---|---|
1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 44 unchanged lines hidden (view full) --- 53 * be scheduled separately via a later call to sendTiming(). This 54 * feature is handled by scheduling an internal event that calls 55 * sendTiming() after a delay, and optionally rescheduling the 56 * response if it is nacked. 57 */ 58class SimpleTimingPort : public Port 59{ 60 protected: | 1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 44 unchanged lines hidden (view full) --- 53 * be scheduled separately via a later call to sendTiming(). This 54 * feature is handled by scheduling an internal event that calls 55 * sendTiming() after a delay, and optionally rescheduling the 56 * response if it is nacked. 57 */ 58class SimpleTimingPort : public Port 59{ 60 protected: |
61 /** A deferred packet, buffered to transmit later. */ 62 class DeferredPacket { 63 public: 64 Tick tick; ///< The tick when the packet is ready to transmit 65 PacketPtr pkt; ///< Pointer to the packet to transmit 66 DeferredPacket(Tick t, PacketPtr p) 67 : tick(t), pkt(p) 68 {} 69 }; 70 71 typedef std::list<DeferredPacket> DeferredPacketList; 72 typedef std::list<DeferredPacket>::iterator DeferredPacketIterator; 73 |
|
61 /** A list of outgoing timing response packets that haven't been 62 * serviced yet. */ | 74 /** A list of outgoing timing response packets that haven't been 75 * serviced yet. */ |
63 std::list<std::pair<Tick,PacketPtr> > transmitList; | 76 DeferredPacketList transmitList; |
64 | 77 |
78 /** This function attempts to send deferred packets. Scheduled to 79 * be called in the future via SendEvent. */ 80 void processSendEvent(); 81 |
|
65 /** 66 * This class is used to implemented sendTiming() with a delay. When 67 * a delay is requested a the event is scheduled if it isn't already. 68 * When the event time expires it attempts to send the packet. 69 * If it cannot, the packet sent when recvRetry() is called. 70 **/ | 82 /** 83 * This class is used to implemented sendTiming() with a delay. When 84 * a delay is requested a the event is scheduled if it isn't already. 85 * When the event time expires it attempts to send the packet. 86 * If it cannot, the packet sent when recvRetry() is called. 87 **/ |
71 class SendEvent : public Event 72 { 73 SimpleTimingPort *port; | 88 typedef EventWrapper<SimpleTimingPort, &SimpleTimingPort::processSendEvent> 89 SendEvent; |
74 | 90 |
75 public: 76 SendEvent(SimpleTimingPort *p) 77 : Event(&mainEventQueue), port(p) 78 { } | 91 Event *sendEvent; |
79 | 92 |
80 virtual void process(); 81 82 virtual const char *description() 83 { return "Future scheduled sendTiming event"; } 84 }; 85 86 SendEvent sendEvent; 87 | |
88 /** If we need to drain, keep the drain event around until we're done 89 * here.*/ 90 Event *drainEvent; 91 | 93 /** If we need to drain, keep the drain event around until we're done 94 * here.*/ 95 Event *drainEvent; 96 |
97 /** Check the list of buffered packets against the supplied 98 * functional request. */ 99 void checkFunctional(PacketPtr funcPkt); 100 |
|
92 /** Schedule a sendTiming() event to be called in the future. 93 * @param pkt packet to send 94 * @param time increment from now (in ticks) to send packet 95 */ 96 void sendTiming(PacketPtr pkt, Tick time); 97 98 /** This function is notification that the device should attempt to send a 99 * packet again. */ --- 10 unchanged lines hidden (view full) --- 110 * changes... can always override this in cases where that's not 111 * true. */ 112 virtual void recvStatusChange(Status status) { } 113 114 115 public: 116 117 SimpleTimingPort(std::string pname, MemObject *_owner = NULL) | 101 /** Schedule a sendTiming() event to be called in the future. 102 * @param pkt packet to send 103 * @param time increment from now (in ticks) to send packet 104 */ 105 void sendTiming(PacketPtr pkt, Tick time); 106 107 /** This function is notification that the device should attempt to send a 108 * packet again. */ --- 10 unchanged lines hidden (view full) --- 119 * changes... can always override this in cases where that's not 120 * true. */ 121 virtual void recvStatusChange(Status status) { } 122 123 124 public: 125 126 SimpleTimingPort(std::string pname, MemObject *_owner = NULL) |
118 : Port(pname, _owner), sendEvent(this), drainEvent(NULL) | 127 : Port(pname, _owner), 128 sendEvent(new SendEvent(this)), 129 drainEvent(NULL) |
119 {} 120 | 130 {} 131 |
132 ~SimpleTimingPort() { delete sendEvent; } 133 |
|
121 /** Hook for draining timing accesses from the system. The 122 * associated SimObject's drain() functions should be implemented 123 * something like this when this class is used: 124 \code 125 PioDevice::drain(Event *de) 126 { 127 unsigned int count; 128 count = SimpleTimingPort->drain(de); --- 12 unchanged lines hidden --- | 134 /** Hook for draining timing accesses from the system. The 135 * associated SimObject's drain() functions should be implemented 136 * something like this when this class is used: 137 \code 138 PioDevice::drain(Event *de) 139 { 140 unsigned int count; 141 count = SimpleTimingPort->drain(de); --- 12 unchanged lines hidden --- |