gem5  v20.1.0.0
port.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012,2015,2017 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
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2002-2005 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
46 #ifndef __MEM_PORT_HH__
47 #define __MEM_PORT_HH__
48 
49 #include "base/addr_range.hh"
50 #include "mem/packet.hh"
51 #include "mem/protocol/atomic.hh"
53 #include "mem/protocol/timing.hh"
54 #include "sim/port.hh"
55 
56 class SimObject;
57 
59 class MasterPort;
60 class SlavePort;
61 
62 class ResponsePort;
63 
74 class RequestPort: public Port, public AtomicRequestProtocol,
76 {
77  friend class ResponsePort;
78 
79  private:
81 
82  protected:
84 
85  public:
86  RequestPort(const std::string& name, SimObject* _owner,
88  virtual ~RequestPort();
89 
94  void bind(Port &peer) override;
95 
99  void unbind() override;
100 
110  virtual bool isSnooping() const { return false; }
111 
116 
121  void printAddr(Addr a);
122 
123  public:
124  /* The atomic protocol. */
125 
136 
148 
149  public:
150  /* The functional protocol. */
151 
159  void sendFunctional(PacketPtr pkt) const;
160 
161  public:
162  /* The timing protocol. */
163 
175  bool sendTimingReq(PacketPtr pkt);
176 
188  bool tryTiming(PacketPtr pkt) const;
189 
199  bool sendTimingSnoopResp(PacketPtr pkt);
200 
207  virtual void sendRetryResp();
208 
209  protected:
217  virtual void recvRangeChange() { }
218 
222  Tick
224  {
225  panic("%s was not expecting an atomic snoop request\n", name());
226  return 0;
227  }
228 
229  void
231  {
232  panic("%s was not expecting a functional snoop request\n", name());
233  }
234 
235  void
237  {
238  panic("%s was not expecting a timing snoop request.\n", name());
239  }
240 
241  void
243  {
244  panic("%s was not expecting a snoop retry.\n", name());
245  }
246 };
247 
248 class M5_DEPRECATED MasterPort : public RequestPort
249 {
250  public:
251  MasterPort(const std::string& name, SimObject* _owner,
252  PortID id=InvalidPortID) : RequestPort(name, _owner, id)
253  {}
254 };
255 
265 class ResponsePort : public Port, public AtomicResponseProtocol,
267 {
268  friend class RequestPort;
269 
270  private:
272 
274 
275  protected:
277 
278  public:
279  ResponsePort(const std::string& name, SimObject* _owner,
280  PortID id=InvalidPortID);
281  virtual ~ResponsePort();
282 
288  bool isSnooping() const { return _requestPort->isSnooping(); }
289 
294 
302  virtual AddrRangeList getAddrRanges() const = 0;
303 
307  void unbind() override {}
308  void bind(Port &peer) override {}
309 
310  public:
311  /* The atomic protocol. */
312 
322  Tick
324  {
325  try {
327  } catch (UnboundPortException) {
328  reportUnbound();
329  }
330  }
331 
332  public:
333  /* The functional protocol. */
334 
342  void
344  {
345  try {
347  } catch (UnboundPortException) {
348  reportUnbound();
349  }
350  }
351 
352  public:
353  /* The timing protocol. */
354 
366  bool
368  {
369  try {
371  } catch (UnboundPortException) {
372  reportUnbound();
373  }
374  }
375 
383  void
385  {
386  try {
388  } catch (UnboundPortException) {
389  reportUnbound();
390  }
391  }
392 
397  void
399  {
400  try {
402  } catch (UnboundPortException) {
403  reportUnbound();
404  }
405  }
406 
411  void
413  {
414  try {
416  } catch (UnboundPortException) {
417  reportUnbound();
418  }
419  }
420 
421  protected:
426  void responderUnbind();
427 
432  void responderBind(RequestPort& request_port);
433 
437  Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override;
438 
439  bool
440  tryTiming(PacketPtr pkt) override
441  {
442  panic("%s was not expecting a %s\n", name(), __func__);
443  }
444 
445  bool
447  {
448  panic("%s was not expecting a timing snoop response\n", name());
449  }
450 };
451 
452 class M5_DEPRECATED SlavePort : public ResponsePort
453 {
454  public:
455  SlavePort(const std::string& name, SimObject* _owner,
456  PortID id=InvalidPortID) : ResponsePort(name, _owner, id)
457  {}
458 };
459 
460 inline Tick
462 {
463  try {
465  } catch (UnboundPortException) {
466  reportUnbound();
467  }
468 }
469 
470 inline Tick
472 {
473  try {
475  pkt, backdoor);
476  } catch (UnboundPortException) {
477  reportUnbound();
478  }
479 }
480 
481 inline void
483 {
484  try {
486  } catch (UnboundPortException) {
487  reportUnbound();
488  }
489 }
490 
491 inline bool
493 {
494  try {
496  } catch (UnboundPortException) {
497  reportUnbound();
498  }
499 }
500 
501 inline bool
503 {
504  try {
506  } catch (UnboundPortException) {
507  reportUnbound();
508  }
509 }
510 
511 inline bool
513 {
514  try {
516  } catch (UnboundPortException) {
517  reportUnbound();
518  }
519 }
520 
521 inline void
523 {
524  try {
526  } catch (UnboundPortException) {
527  reportUnbound();
528  }
529 }
530 
531 #endif //__MEM_PORT_HH__
RequestPort::sendAtomicBackdoor
Tick sendAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor)
Send an atomic request packet like above, but also request a backdoor to the data being accessed.
Definition: port.hh:471
ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:265
MemBackdoor
Definition: backdoor.hh:38
RequestPort::~RequestPort
virtual ~RequestPort()
Definition: port.cc:120
TimingResponseProtocol
Definition: timing.hh:122
RequestPort::recvAtomicSnoop
Tick recvAtomicSnoop(PacketPtr pkt) override
Default implementations.
Definition: port.hh:223
ResponsePort::sendTimingResp
bool sendTimingResp(PacketPtr pkt)
Attempt to send a timing response to the request port by calling its corresponding receive function.
Definition: port.hh:367
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
Port::UnboundPortException
Definition: port.hh:66
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
ResponsePort::sendAtomicSnoop
Tick sendAtomicSnoop(PacketPtr pkt)
Send an atomic snoop request packet, where the data is moved and the state is updated in zero time,...
Definition: port.hh:323
RequestPort::getAddrRanges
AddrRangeList getAddrRanges() const
Get the address ranges of the connected responder port.
Definition: port.cc:148
ResponsePort::responderUnbind
void responderUnbind()
Called by the request port to unbind.
Definition: port.cc:180
ResponsePort::ResponsePort
ResponsePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Response port.
Definition: port.cc:169
TimingResponseProtocol::sendResp
bool sendResp(TimingRequestProtocol *peer, PacketPtr pkt)
Attempt to send a timing response to the peer by calling its corresponding receive function.
Definition: timing.cc:77
RequestPort::sendFunctional
void sendFunctional(PacketPtr pkt) const
Send a functional request packet, where the data is instantly updated everywhere in the memory system...
Definition: port.hh:482
RequestPort::bind
void bind(Port &peer) override
Bind this request port to a response port.
Definition: port.cc:125
atomic.hh
Port::reportUnbound
void reportUnbound() const
Definition: port.cc:57
RequestPort::_responsePort
ResponsePort * _responsePort
Definition: port.hh:80
TimingRequestProtocol::sendRetryResp
void sendRetryResp(TimingResponseProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingResp to this protocol and failed.
Definition: timing.cc:69
RequestPort::sendTimingSnoopResp
bool sendTimingSnoopResp(PacketPtr pkt)
Attempt to send a timing snoop response packet to the response port by calling its corresponding rece...
Definition: port.hh:512
packet.hh
FunctionalResponseProtocol::sendSnoop
void sendSnoop(FunctionalRequestProtocol *peer, PacketPtr pkt) const
Send a functional snoop request packet, where the data is instantly updated everywhere in the memory ...
Definition: functional.cc:56
ResponsePort::tryTiming
bool tryTiming(PacketPtr pkt) override
Availability request from the peer.
Definition: port.hh:440
ResponsePort::responderBind
void responderBind(RequestPort &request_port)
Called by the request port to bind.
Definition: port.cc:187
ResponsePort::sendTimingSnoopReq
void sendTimingSnoopReq(PacketPtr pkt)
Attempt to send a timing snoop request packet to the request port by calling its corresponding receiv...
Definition: port.hh:384
RequestPort::recvRetrySnoopResp
void recvRetrySnoopResp() override
Called by the peer if sendTimingSnoopResp was called on this protocol (causing recvTimingSnoopResp to...
Definition: port.hh:242
TimingResponseProtocol::sendRetryReq
void sendRetryReq(TimingRequestProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingReq to this protocol and failed.
Definition: timing.cc:92
ResponsePort::defaultBackdoorWarned
bool defaultBackdoorWarned
Definition: port.hh:273
ArmISA::a
Bitfield< 8 > a
Definition: miscregs_types.hh:62
RequestPort::sendTimingReq
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the responder port by calling its corresponding receive function.
Definition: port.hh:492
functional.hh
ResponsePort::bind
void bind(Port &peer) override
Attach to a peer port.
Definition: port.hh:308
AtomicResponseProtocol
Definition: atomic.hh:86
SlavePort
Definition: port.hh:452
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
RequestPort::RequestPort
RequestPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Request port.
Definition: port.cc:114
SlavePort::SlavePort
SlavePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Definition: port.hh:455
timing.hh
FunctionalResponseProtocol
Definition: functional.hh:68
RequestPort::sendRetryResp
virtual void sendRetryResp()
Send a retry to the response port that previously attempted a sendTimingResp to this request port and...
Definition: port.hh:522
ResponsePort::isSnooping
bool isSnooping() const
Find out if the peer request port is snooping or not.
Definition: port.hh:288
AtomicRequestProtocol
Definition: atomic.hh:49
RequestPort::isSnooping
virtual bool isSnooping() const
Determine if this request port is snooping or not.
Definition: port.hh:110
RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:74
ResponsePort::recvTimingSnoopResp
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition: port.hh:446
RequestPort::recvRangeChange
virtual void recvRangeChange()
Called to receive an address range change from the peer response port.
Definition: port.hh:217
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
TimingRequestProtocol::trySend
bool trySend(TimingResponseProtocol *peer, PacketPtr pkt) const
Check if the peer can handle a timing request.
Definition: timing.cc:53
port.hh
MasterPort::MasterPort
MasterPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Definition: port.hh:251
name
const std::string & name()
Definition: trace.cc:50
ResponsePort::~ResponsePort
virtual ~ResponsePort()
Definition: port.cc:175
addr_range.hh
ResponsePort::owner
SimObject & owner
Definition: port.hh:276
RequestPort::owner
SimObject & owner
Definition: port.hh:83
ResponsePort::getAddrRanges
virtual AddrRangeList getAddrRanges() const =0
Get a list of the non-overlapping address ranges the owner is responsible for.
RequestPort::unbind
void unbind() override
Unbind this request port and the associated response port.
Definition: port.cc:138
TimingRequestProtocol
Definition: timing.hh:48
FunctionalRequestProtocol::send
void send(FunctionalResponseProtocol *peer, PacketPtr pkt) const
Send a functional request packet, where the data is instantly updated everywhere in the memory system...
Definition: functional.cc:46
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
AtomicRequestProtocol::send
Tick send(AtomicResponseProtocol *peer, PacketPtr pkt)
Send an atomic request packet, where the data is moved and the state is updated in zero time,...
Definition: atomic.cc:48
RequestPort::printAddr
void printAddr(Addr a)
Inject a PrintReq for the given address to print the state of that address throughout the memory syst...
Definition: port.cc:154
TimingResponseProtocol::sendRetrySnoopResp
void sendRetrySnoopResp(TimingRequestProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingSnoopResp to this peer and failed.
Definition: timing.cc:98
ResponsePort::sendFunctionalSnoop
void sendFunctionalSnoop(PacketPtr pkt) const
Send a functional snoop request packet, where the data is instantly updated everywhere in the memory ...
Definition: port.hh:343
AtomicResponseProtocol::sendSnoop
Tick sendSnoop(AtomicRequestProtocol *peer, PacketPtr pkt)
Send an atomic snoop request packet, where the data is moved and the state is updated in zero time,...
Definition: atomic.cc:65
ResponsePort::sendRetrySnoopResp
void sendRetrySnoopResp()
Send a retry to the request port that previously attempted a sendTimingSnoopResp to this response por...
Definition: port.hh:412
ResponsePort::recvAtomicBackdoor
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
Default implementations.
Definition: port.cc:194
ResponsePort::sendRetryReq
void sendRetryReq()
Send a retry to the request port that previously attempted a sendTimingReq to this response port and ...
Definition: port.hh:398
RequestPort::sendAtomic
Tick sendAtomic(PacketPtr pkt)
Send an atomic request packet, where the data is moved and the state is updated in zero time,...
Definition: port.hh:461
std::list< AddrRange >
RequestPort::recvTimingSnoopReq
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
Definition: port.hh:236
ResponsePort::sendRangeChange
void sendRangeChange() const
Called by the owner to send a range change.
Definition: port.hh:293
TimingRequestProtocol::sendReq
bool sendReq(TimingResponseProtocol *peer, PacketPtr pkt)
Attempt to send a timing request to the peer by calling its corresponding receive function.
Definition: timing.cc:46
AtomicRequestProtocol::sendBackdoor
Tick sendBackdoor(AtomicResponseProtocol *peer, PacketPtr pkt, MemBackdoorPtr &backdoor)
Send an atomic request packet like above, but also request a backdoor to the data being accessed.
Definition: atomic.cc:55
TimingResponseProtocol::sendSnoopReq
void sendSnoopReq(TimingRequestProtocol *peer, PacketPtr pkt)
Attempt to send a timing snoop request packet to the peer by calling its corresponding receive functi...
Definition: timing.cc:84
RequestPort::recvFunctionalSnoop
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
Definition: port.hh:230
ResponsePort::_requestPort
RequestPort * _requestPort
Definition: port.hh:271
ResponsePort::unbind
void unbind() override
We let the request port do the work, so these don't do anything.
Definition: port.hh:307
MasterPort
Definition: port.hh:248
ArmISA::id
Bitfield< 33 > id
Definition: miscregs_types.hh:247
FunctionalRequestProtocol
Definition: functional.hh:48
RequestPort::tryTiming
bool tryTiming(PacketPtr pkt) const
Check if the responder can handle a timing request.
Definition: port.hh:502
TimingRequestProtocol::sendSnoopResp
bool sendSnoopResp(TimingResponseProtocol *peer, PacketPtr pkt)
Attempt to send a timing snoop response packet to it's peer by calling its corresponding receive func...
Definition: timing.cc:61
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17