gem5  v21.1.0.2
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 namespace gem5
57 {
58 
59 class SimObject;
60 
62 class MasterPort;
63 class SlavePort;
64 
65 class ResponsePort;
66 
77 class RequestPort: public Port, public AtomicRequestProtocol,
79 {
80  friend class ResponsePort;
81 
82  private:
84 
85  protected:
87 
88  public:
89  RequestPort(const std::string& name, SimObject* _owner,
91  virtual ~RequestPort();
92 
97  void bind(Port &peer) override;
98 
102  void unbind() override;
103 
113  virtual bool isSnooping() const { return false; }
114 
119 
124  void printAddr(Addr a);
125 
126  public:
127  /* The atomic protocol. */
128 
139 
151 
152  public:
153  /* The functional protocol. */
154 
162  void sendFunctional(PacketPtr pkt) const;
163 
164  public:
165  /* The timing protocol. */
166 
178  bool sendTimingReq(PacketPtr pkt);
179 
191  bool tryTiming(PacketPtr pkt) const;
192 
202  bool sendTimingSnoopResp(PacketPtr pkt);
203 
210  virtual void sendRetryResp();
211 
212  protected:
220  virtual void recvRangeChange() { }
221 
225  Tick
227  {
228  panic("%s was not expecting an atomic snoop request\n", name());
229  return 0;
230  }
231 
232  void
234  {
235  panic("%s was not expecting a functional snoop request\n", name());
236  }
237 
238  void
240  {
241  panic("%s was not expecting a timing snoop request.\n", name());
242  }
243 
244  void
246  {
247  panic("%s was not expecting a snoop retry.\n", name());
248  }
249 };
250 
251 class [[deprecated]] MasterPort : public RequestPort
252 {
253  public:
254  MasterPort(const std::string& name, SimObject* _owner,
255  PortID id=InvalidPortID) : RequestPort(name, _owner, id)
256  {}
257 };
258 
268 class ResponsePort : public Port, public AtomicResponseProtocol,
270 {
271  friend class RequestPort;
272 
273  private:
275 
277 
278  protected:
280 
281  public:
282  ResponsePort(const std::string& name, SimObject* _owner,
283  PortID id=InvalidPortID);
284  virtual ~ResponsePort();
285 
291  bool isSnooping() const { return _requestPort->isSnooping(); }
292 
297 
305  virtual AddrRangeList getAddrRanges() const = 0;
306 
310  void unbind() override {}
311  void bind(Port &peer) override {}
312 
313  public:
314  /* The atomic protocol. */
315 
325  Tick
327  {
328  try {
330  } catch (UnboundPortException) {
331  reportUnbound();
332  }
333  }
334 
335  public:
336  /* The functional protocol. */
337 
345  void
347  {
348  try {
350  } catch (UnboundPortException) {
351  reportUnbound();
352  }
353  }
354 
355  public:
356  /* The timing protocol. */
357 
369  bool
371  {
372  try {
374  } catch (UnboundPortException) {
375  reportUnbound();
376  }
377  }
378 
386  void
388  {
389  try {
391  } catch (UnboundPortException) {
392  reportUnbound();
393  }
394  }
395 
400  void
402  {
403  try {
405  } catch (UnboundPortException) {
406  reportUnbound();
407  }
408  }
409 
414  void
416  {
417  try {
419  } catch (UnboundPortException) {
420  reportUnbound();
421  }
422  }
423 
424  protected:
429  void responderUnbind();
430 
435  void responderBind(RequestPort& request_port);
436 
440  Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override;
441 
442  bool
443  tryTiming(PacketPtr pkt) override
444  {
445  panic("%s was not expecting a %s\n", name(), __func__);
446  }
447 
448  bool
450  {
451  panic("%s was not expecting a timing snoop response\n", name());
452  }
453 };
454 
455 class [[deprecated]] SlavePort : public ResponsePort
456 {
457  public:
458  SlavePort(const std::string& name, SimObject* _owner,
459  PortID id=InvalidPortID) : ResponsePort(name, _owner, id)
460  {}
461 };
462 
463 inline Tick
465 {
466  try {
468  } catch (UnboundPortException) {
469  reportUnbound();
470  }
471 }
472 
473 inline Tick
475 {
476  try {
478  pkt, backdoor);
479  } catch (UnboundPortException) {
480  reportUnbound();
481  }
482 }
483 
484 inline void
486 {
487  try {
489  } catch (UnboundPortException) {
490  reportUnbound();
491  }
492 }
493 
494 inline bool
496 {
497  try {
499  } catch (UnboundPortException) {
500  reportUnbound();
501  }
502 }
503 
504 inline bool
506 {
507  try {
509  } catch (UnboundPortException) {
510  reportUnbound();
511  }
512 }
513 
514 inline bool
516 {
517  try {
519  } catch (UnboundPortException) {
520  reportUnbound();
521  }
522 }
523 
524 inline void
526 {
527  try {
529  } catch (UnboundPortException) {
530  reportUnbound();
531  }
532 }
533 
534 } // namespace gem5
535 
536 #endif //__MEM_PORT_HH__
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:252
gem5::RequestPort::tryTiming
bool tryTiming(PacketPtr pkt) const
Check if the responder can handle a timing request.
Definition: port.hh:505
gem5::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:49
gem5::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:495
gem5::RequestPort::recvFunctionalSnoop
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
Definition: port.hh:233
gem5::RequestPort::unbind
void unbind() override
Unbind this request port and the associated response port.
Definition: port.cc:141
gem5::Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:111
gem5::RequestPort::bind
void bind(Port &peer) override
Bind this request port to a response port.
Definition: port.cc:128
gem5::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:346
gem5::ResponsePort::sendRetryReq
void sendRetryReq()
Send a retry to the request port that previously attempted a sendTimingReq to this response port and ...
Definition: port.hh:401
gem5::ResponsePort::sendRetrySnoopResp
void sendRetrySnoopResp()
Send a retry to the request port that previously attempted a sendTimingSnoopResp to this response por...
Definition: port.hh:415
gem5::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:80
gem5::ResponsePort::_requestPort
RequestPort * _requestPort
Definition: port.hh:274
gem5::Port::reportUnbound
void reportUnbound() const
Definition: port.cc:60
gem5::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:68
gem5::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:464
gem5::ResponsePort::unbind
void unbind() override
We let the request port do the work, so these don't do anything.
Definition: port.hh:310
gem5::RequestPort::RequestPort
RequestPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Request port.
Definition: port.cc:117
gem5::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:95
gem5::ArmISA::a
Bitfield< 8 > a
Definition: misc_types.hh:65
gem5::ResponsePort::responderUnbind
void responderUnbind()
Called by the request port to unbind.
Definition: port.cc:183
gem5::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:49
gem5::RequestPort::recvRetrySnoopResp
void recvRetrySnoopResp() override
Called by the peer if sendTimingSnoopResp was called on this protocol (causing recvTimingSnoopResp to...
Definition: port.hh:245
gem5::RequestPort::recvRangeChange
virtual void recvRangeChange()
Called to receive an address range change from the peer response port.
Definition: port.hh:220
atomic.hh
gem5::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:101
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:253
gem5::AtomicResponseProtocol
Definition: atomic.hh:89
packet.hh
gem5::RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:77
gem5::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:474
gem5::RequestPort::~RequestPort
virtual ~RequestPort()
Definition: port.cc:123
gem5::FunctionalResponseProtocol
Definition: functional.hh:71
gem5::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:485
functional.hh
gem5::ResponsePort::responderBind
void responderBind(RequestPort &request_port)
Called by the request port to bind.
Definition: port.cc:190
gem5::SlavePort
Definition: port.hh:455
gem5::ResponsePort::~ResponsePort
virtual ~ResponsePort()
Definition: port.cc:178
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::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:51
gem5::ResponsePort::isSnooping
bool isSnooping() const
Find out if the peer request port is snooping or not.
Definition: port.hh:291
gem5::RequestPort::recvTimingSnoopReq
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
Definition: port.hh:239
gem5::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:525
gem5::MasterPort::MasterPort
MasterPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Definition: port.hh:254
gem5::MasterPort
Definition: port.hh:251
timing.hh
gem5::SlavePort::SlavePort
SlavePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Definition: port.hh:458
gem5::RequestPort::isSnooping
virtual bool isSnooping() const
Determine if this request port is snooping or not.
Definition: port.hh:113
gem5::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:370
gem5::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:387
gem5::RequestPort::getAddrRanges
AddrRangeList getAddrRanges() const
Get the address ranges of the connected responder port.
Definition: port.cc:151
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::TimingResponseProtocol
Definition: timing.hh:125
gem5::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:64
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
port.hh
name
const std::string & name()
Definition: trace.cc:49
gem5::MemBackdoor
Definition: backdoor.hh:41
gem5::TimingRequestProtocol::trySend
bool trySend(TimingResponseProtocol *peer, PacketPtr pkt) const
Check if the peer can handle a timing request.
Definition: timing.cc:56
gem5::ResponsePort::ResponsePort
ResponsePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Response port.
Definition: port.cc:172
gem5::ResponsePort::sendRangeChange
void sendRangeChange() const
Called by the owner to send a range change.
Definition: port.hh:296
gem5::AtomicRequestProtocol
Definition: atomic.hh:52
addr_range.hh
gem5::ResponsePort::bind
void bind(Port &peer) override
Attach to a peer port.
Definition: port.hh:311
gem5::ResponsePort::getAddrRanges
virtual AddrRangeList getAddrRanges() const =0
Get a list of the non-overlapping address ranges the owner is responsible for.
gem5::ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:268
gem5::ResponsePort::tryTiming
bool tryTiming(PacketPtr pkt) override
Availability request from the peer.
Definition: port.hh:443
gem5::ResponsePort::owner
SimObject & owner
Definition: port.hh:279
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
gem5::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:58
gem5::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:59
gem5::RequestPort::_responsePort
ResponsePort * _responsePort
Definition: port.hh:83
gem5::ResponsePort::defaultBackdoorWarned
bool defaultBackdoorWarned
Definition: port.hh:276
gem5::ArmISA::id
Bitfield< 33 > id
Definition: misc_types.hh:250
gem5::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:72
gem5::Port::UnboundPortException
Definition: port.hh:71
gem5::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:326
gem5::TimingRequestProtocol
Definition: timing.hh:51
std::list< AddrRange >
gem5::ResponsePort::recvAtomicBackdoor
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
Default implementations.
Definition: port.cc:197
gem5::ResponsePort::recvTimingSnoopResp
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition: port.hh:449
gem5::FunctionalRequestProtocol
Definition: functional.hh:51
gem5::RequestPort::owner
SimObject & owner
Definition: port.hh:86
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::RequestPort::recvAtomicSnoop
Tick recvAtomicSnoop(PacketPtr pkt) override
Default implementations.
Definition: port.hh:226
gem5::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:157
gem5::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:515
gem5::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:87
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177

Generated on Tue Sep 21 2021 12:25:34 for gem5 by doxygen 1.8.17