Deleted Added
sdiff udiff text old ( 8711:c7e14f52c682 ) new ( 8713:2f1a3e335255 )
full compact
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;
9 * redistributions in binary form must reproduce the above copyright

--- 12 unchanged lines hidden (view full) ---

22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Ali Saidi
29 * Steve Reinhardt
30 */
31
32/**
33 * @file
34 * Declaration of a simple bus bridge object with no buffering
35 */
36
37#ifndef __MEM_BRIDGE_HH__
38#define __MEM_BRIDGE_HH__
39
40#include <list>
41#include <queue>
42#include <string>
43
44#include "base/fast_alloc.hh"
45#include "base/types.hh"
46#include "mem/mem_object.hh"
47#include "mem/packet.hh"
48#include "mem/port.hh"
49#include "params/Bridge.hh"
50#include "sim/eventq.hh"
51
52class Bridge : public MemObject
53{
54 protected:
55 /** Declaration of the buses port type, one will be instantiated for each
56 of the interfaces connecting to the bus. */
57 class BridgePort : public Port
58 {
59 /** A pointer to the bridge to which this port belongs. */
60 Bridge *bridge;
61
62 /**
63 * Pointer to the port on the other side of the bridge
64 * (connected to the other bus).
65 */
66 BridgePort *otherPort;
67
68 /** Minimum delay though this bridge. */
69 Tick delay;
70
71 /** Min delay to respond to a nack. */
72 Tick nackDelay;
73
74 /** Pass ranges from one side of the bridge to the other? */
75 std::vector<Range<Addr> > filterRanges;
76
77 class PacketBuffer : public Packet::SenderState, public FastAlloc {
78
79 public:
80 Tick ready;
81 PacketPtr pkt;
82 bool nackedHere;
83 Packet::SenderState *origSenderState;
84 short origSrc;
85 bool expectResponse;
86
87 PacketBuffer(PacketPtr _pkt, Tick t, bool nack = false)
88 : ready(t), pkt(_pkt), nackedHere(nack),
89 origSenderState(_pkt->senderState),
90 origSrc(nack ? _pkt->getDest() : _pkt->getSrc() ),
91 expectResponse(_pkt->needsResponse() && !nack)
92
93 {
94 if (!pkt->isResponse() && !nack)
95 pkt->senderState = this;
96 }
97
98 void fixResponse(PacketPtr pkt)
99 {
100 assert(pkt->senderState == this);
101 pkt->setDest(origSrc);
102 pkt->senderState = origSenderState;
103 }
104 };
105
106 /**
107 * Outbound packet queue. Packets are held in this queue for a
108 * specified delay to model the processing delay of the
109 * bridge.
110 */
111 std::list<PacketBuffer*> sendQueue;
112
113 int outstandingResponses;
114 int queuedRequests;
115
116 /** If we're waiting for a retry to happen.*/
117 bool inRetry;
118
119 /** Max queue size for outbound packets */
120 int reqQueueLimit;
121
122 /** Max queue size for reserved responses. */
123 int respQueueLimit;
124
125 /**
126 * Is this side blocked from accepting outbound packets?
127 */
128 bool respQueueFull();
129 bool reqQueueFull();
130
131 void queueForSendTiming(PacketPtr pkt);
132
133 void finishSend(PacketBuffer *buf);
134
135 void nackRequest(PacketPtr pkt);
136
137 /**
138 * Handle send event, scheduled when the packet at the head of
139 * the outbound queue is ready to transmit (for timing
140 * accesses only).
141 */
142 void trySend();
143
144 class SendEvent : public Event
145 {
146 BridgePort *port;
147
148 public:
149 SendEvent(BridgePort *p) : port(p) {}
150 virtual void process() { port->trySend(); }
151 virtual const char *description() const { return "bridge send"; }
152 };
153
154 SendEvent sendEvent;
155
156 public:
157 /** Constructor for the BusPort.*/
158 BridgePort(const std::string &_name, Bridge *_bridge,
159 BridgePort *_otherPort, int _delay, int _nack_delay,
160 int _req_limit, int _resp_limit,
161 std::vector<Range<Addr> > filter_ranges);
162
163 protected:
164
165 /** When receiving a timing request from the peer port,
166 pass it to the bridge. */
167 virtual bool recvTiming(PacketPtr pkt);
168
169 /** When receiving a retry request from the peer port,
170 pass it to the bridge. */

--- 6 unchanged lines hidden (view full) ---

177 /** When receiving a Functional request from the peer port,
178 pass it to the bridge. */
179 virtual void recvFunctional(PacketPtr pkt);
180
181 /**
182 * When receiving a range change, pass it through the bridge.
183 */
184 virtual void recvRangeChange();
185
186 /** When receiving a address range request the peer port,
187 pass it to the bridge. */
188 virtual AddrRangeList getAddrRanges();
189 };
190
191 BridgePort portA, portB;
192
193 /** If this bridge should acknowledge writes. */
194 bool ackWrites;
195
196 public:
197 typedef BridgeParams Params;
198
199 protected:
200 Params *_params;

--- 13 unchanged lines hidden ---