port.cc (9178:6a0ff1770e6e) port.cc (9294:8fb03b13de02)
1/*
2 * Copyright (c) 2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

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

54 : portName(_name), id(_id), owner(_owner)
55{
56}
57
58Port::~Port()
59{
60}
61
1/*
2 * Copyright (c) 2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

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

54 : portName(_name), id(_id), owner(_owner)
55{
56}
57
58Port::~Port()
59{
60}
61
62BaseMasterPort::BaseMasterPort(const std::string& name, MemObject* owner,
63 PortID _id)
64 : Port(name, *owner, _id), _baseSlavePort(NULL)
65{
66}
67
68BaseMasterPort::~BaseMasterPort()
69{
70}
71
72BaseSlavePort&
73BaseMasterPort::getSlavePort() const
74{
75 if(_baseSlavePort == NULL)
76 panic("Cannot getSlavePort on master port %s that is not connected\n",
77 name());
78
79 return *_baseSlavePort;
80}
81
82bool
83BaseMasterPort::isConnected() const
84{
85 return _baseSlavePort != NULL;
86}
87
88BaseSlavePort::BaseSlavePort(const std::string& name, MemObject* owner,
89 PortID _id)
90 : Port(name, *owner, _id), _baseMasterPort(NULL)
91{
92}
93
94BaseSlavePort::~BaseSlavePort()
95{
96}
97
98BaseMasterPort&
99BaseSlavePort::getMasterPort() const
100{
101 if(_baseMasterPort == NULL)
102 panic("Cannot getMasterPort on slave port %s that is not connected\n",
103 name());
104
105 return *_baseMasterPort;
106}
107
108bool
109BaseSlavePort::isConnected() const
110{
111 return _baseMasterPort != NULL;
112}
113
62/**
63 * Master port
64 */
65MasterPort::MasterPort(const std::string& name, MemObject* owner, PortID _id)
114/**
115 * Master port
116 */
117MasterPort::MasterPort(const std::string& name, MemObject* owner, PortID _id)
66 : Port(name, *owner, _id), _slavePort(NULL)
118 : BaseMasterPort(name, owner, _id), _slavePort(NULL)
67{
68}
69
70MasterPort::~MasterPort()
71{
72}
73
119{
120}
121
122MasterPort::~MasterPort()
123{
124}
125
74SlavePort&
75MasterPort::getSlavePort() const
126void
127MasterPort::bind(BaseSlavePort& slave_port)
76{
128{
77 if(_slavePort == NULL)
78 panic("Cannot getSlavePort on master port %s that is not connected\n",
79 name());
129 // bind on the level of the base ports
130 _baseSlavePort = &slave_port;
80
131
81 return *_slavePort;
132 // also attempt to base the slave to the appropriate type
133 SlavePort* cast_slave_port = dynamic_cast<SlavePort*>(&slave_port);
134
135 // if this port is compatible, then proceed with the binding
136 if (cast_slave_port != NULL) {
137 // master port keeps track of the slave port
138 _slavePort = cast_slave_port;
139 // slave port also keeps track of master port
140 _slavePort->bind(*this);
141 } else {
142 fatal("Master port %s cannot bind to %s\n", name(),
143 slave_port.name());
144 }
82}
83
84void
85MasterPort::unbind()
86{
87 if (_slavePort == NULL)
88 panic("Attempting to unbind master port %s that is not connected\n",
89 name());
90 _slavePort->unbind();
91 _slavePort = NULL;
145}
146
147void
148MasterPort::unbind()
149{
150 if (_slavePort == NULL)
151 panic("Attempting to unbind master port %s that is not connected\n",
152 name());
153 _slavePort->unbind();
154 _slavePort = NULL;
155 _baseSlavePort = NULL;
92}
93
156}
157
94void
95MasterPort::bind(SlavePort& slave_port)
96{
97 if (_slavePort != NULL)
98 panic("Attempting to bind master port %s that is already connected\n",
99 name());
100
101 // master port keeps track of the slave port
102 _slavePort = &slave_port;
103
104 // slave port also keeps track of master port
105 _slavePort->bind(*this);
106}
107
108bool
109MasterPort::isConnected() const
110{
111 return _slavePort != NULL;
112}
113
114unsigned
115MasterPort::peerBlockSize() const
116{
117 return _slavePort->deviceBlockSize();
118}
119
120AddrRangeList
121MasterPort::getAddrRanges() const

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

167
168 sendFunctional(&pkt);
169}
170
171/**
172 * Slave port
173 */
174SlavePort::SlavePort(const std::string& name, MemObject* owner, PortID id)
158unsigned
159MasterPort::peerBlockSize() const
160{
161 return _slavePort->deviceBlockSize();
162}
163
164AddrRangeList
165MasterPort::getAddrRanges() const

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

211
212 sendFunctional(&pkt);
213}
214
215/**
216 * Slave port
217 */
218SlavePort::SlavePort(const std::string& name, MemObject* owner, PortID id)
175 : Port(name, *owner, id), _masterPort(NULL)
219 : BaseSlavePort(name, owner, id), _masterPort(NULL)
176{
177}
178
179SlavePort::~SlavePort()
180{
181}
182
183void
184SlavePort::unbind()
185{
220{
221}
222
223SlavePort::~SlavePort()
224{
225}
226
227void
228SlavePort::unbind()
229{
230 _baseMasterPort = NULL;
186 _masterPort = NULL;
187}
188
189void
190SlavePort::bind(MasterPort& master_port)
191{
231 _masterPort = NULL;
232}
233
234void
235SlavePort::bind(MasterPort& master_port)
236{
237 _baseMasterPort = &master_port;
192 _masterPort = &master_port;
193}
194
238 _masterPort = &master_port;
239}
240
195MasterPort&
196SlavePort::getMasterPort() const
197{
198 if (_masterPort == NULL)
199 panic("Cannot getMasterPort on slave port %s that is not connected\n",
200 name());
201
202 return *_masterPort;
203}
204
205unsigned
206SlavePort::peerBlockSize() const
207{
208 return _masterPort->deviceBlockSize();
209}
210
241unsigned
242SlavePort::peerBlockSize() const
243{
244 return _masterPort->deviceBlockSize();
245}
246
211bool
212SlavePort::isConnected() const
213{
214 return _masterPort != NULL;
215}
216
217Tick
218SlavePort::sendAtomicSnoop(PacketPtr pkt)
219{
220 assert(pkt->isRequest());
221 return _masterPort->recvAtomicSnoop(pkt);
222}
223
224void

--- 25 unchanged lines hidden ---
247Tick
248SlavePort::sendAtomicSnoop(PacketPtr pkt)
249{
250 assert(pkt->isRequest());
251 return _masterPort->recvAtomicSnoop(pkt);
252}
253
254void

--- 25 unchanged lines hidden ---