gem5 v23.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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"
54#include "sim/port.hh"
55
56namespace gem5
57{
58
59class SimObject;
60
62class MasterPort;
63class SlavePort;
64
65class ResponsePort;
66
79{
80 friend class ResponsePort;
81
82 private:
84
85 protected:
87
88 public:
89 [[deprecated("RequestPort ownership is deprecated. "
90 "Owner should now be registered in derived classes.")]]
91 RequestPort(const std::string& name, SimObject* _owner,
93
94 RequestPort(const std::string& name, PortID id=InvalidPortID);
95
96 virtual ~RequestPort();
97
102 void bind(Port &peer) override;
103
107 void unbind() override;
108
118 virtual bool isSnooping() const { return false; }
119
124
129 void printAddr(Addr a);
130
131 public:
132 /* The atomic protocol. */
133
144
156
157 public:
158 /* The functional protocol. */
159
167 void sendFunctional(PacketPtr pkt) const;
168
181 void sendMemBackdoorReq(const MemBackdoorReq &req,
182 MemBackdoorPtr &backdoor);
183
184 public:
185 /* The timing protocol. */
186
198 bool sendTimingReq(PacketPtr pkt);
199
211 bool tryTiming(PacketPtr pkt) const;
212
223
230 virtual void sendRetryResp();
231
232 protected:
240 virtual void recvRangeChange() { }
241
245 Tick
247 {
248 panic("%s was not expecting an atomic snoop request\n", name());
249 return 0;
250 }
251
252 void
254 {
255 panic("%s was not expecting a functional snoop request\n", name());
256 }
257
258 void
260 {
261 panic("%s was not expecting a timing snoop request.\n", name());
262 }
263
264 void
266 {
267 panic("%s was not expecting a snoop retry.\n", name());
268 }
269};
270
271class [[deprecated]] MasterPort : public RequestPort
272{
273 public:
274 using RequestPort::RequestPort;
275};
276
288{
289 friend class RequestPort;
290
291 private:
293
295
296 protected:
298
299 public:
300 [[deprecated("ResponsePort ownership is deprecated. "
301 "Owner should now be registered in derived classes.")]]
302 ResponsePort(const std::string& name, SimObject* _owner,
304
305 ResponsePort(const std::string& name, PortID id=InvalidPortID);
306
307 virtual ~ResponsePort();
308
314 bool isSnooping() const { return _requestPort->isSnooping(); }
315
320
328 virtual AddrRangeList getAddrRanges() const = 0;
329
333 void unbind() override {}
334 void bind(Port &peer) override {}
335
336 public:
337 /* The atomic protocol. */
338
348 Tick
350 {
351 try {
353 } catch (UnboundPortException) {
355 }
356 }
357
358 public:
359 /* The functional protocol. */
360
368 void
370 {
371 try {
373 } catch (UnboundPortException) {
375 }
376 }
377
378 public:
379 /* The timing protocol. */
380
392 bool
394 {
395 try {
397 } catch (UnboundPortException) {
399 }
400 }
401
409 void
411 {
412 try {
414 } catch (UnboundPortException) {
416 }
417 }
418
423 void
425 {
426 try {
428 } catch (UnboundPortException) {
430 }
431 }
432
437 void
439 {
440 try {
442 } catch (UnboundPortException) {
444 }
445 }
446
447 protected:
452 void responderUnbind();
453
458 void responderBind(RequestPort& request_port);
459
463 Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override;
464 void recvMemBackdoorReq(const MemBackdoorReq &req,
465 MemBackdoorPtr &backdoor) override;
466
467 bool
468 tryTiming(PacketPtr pkt) override
469 {
470 panic("%s was not expecting a %s\n", name(), __func__);
471 }
472
473 bool
475 {
476 panic("%s was not expecting a timing snoop response\n", name());
477 }
478};
479
480class [[deprecated]] SlavePort : public ResponsePort
481{
482 public:
483 using ResponsePort::ResponsePort;
484};
485
486inline Tick
488{
489 try {
491 } catch (UnboundPortException) {
493 }
494}
495
496inline Tick
498{
499 try {
501 pkt, backdoor);
502 } catch (UnboundPortException) {
504 }
505}
506
507inline void
509{
510 try {
512 } catch (UnboundPortException) {
514 }
515}
516
517inline void
519 MemBackdoorPtr &backdoor)
520{
521 try {
523 _responsePort, req, backdoor);
524 } catch (UnboundPortException) {
526 }
527}
528
529inline bool
531{
532 try {
534 } catch (UnboundPortException) {
536 }
537}
538
539inline bool
541{
542 try {
544 } catch (UnboundPortException) {
546 }
547}
548
549inline bool
551{
552 try {
554 } catch (UnboundPortException) {
556 }
557}
558
559inline void
561{
562 try {
564 } catch (UnboundPortException) {
566 }
567}
568
569} // namespace gem5
570
571#endif //__MEM_PORT_HH__
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
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
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
void sendMemBackdoorReq(FunctionalResponseProtocol *peer, const MemBackdoorReq &req, MemBackdoorPtr &backdoor)
Send a request for a back door to a range of memory.
Definition functional.cc:57
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
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:67
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Ports are used to interface objects to each other.
Definition port.hh:62
const std::string name() const
Return port name (for DPRINTF).
Definition port.hh:111
void reportUnbound() const
Definition port.cc:60
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:79
void sendMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &backdoor)
Send a request for a back door to a range of memory.
Definition port.hh:518
virtual void sendRetryResp()
Send a retry to the response port that previously attempted a sendTimingResp to this request port and...
Definition port.hh:560
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
Definition port.hh:259
virtual void recvRangeChange()
Called to receive an address range change from the peer response port.
Definition port.hh:240
SimObject & owner
Definition port.hh:86
virtual ~RequestPort()
Definition port.cc:143
void unbind() override
Unbind this request port and the associated response port.
Definition port.cc:161
virtual bool isSnooping() const
Determine if this request port is snooping or not.
Definition port.hh:118
bool tryTiming(PacketPtr pkt) const
Check if the responder can handle a timing request.
Definition port.hh:540
Tick recvAtomicSnoop(PacketPtr pkt) override
Default implementations.
Definition port.hh:246
ResponsePort * _responsePort
Definition port.hh:83
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:487
AddrRangeList getAddrRanges() const
Get the address ranges of the connected responder port.
Definition port.cc:171
void bind(Port &peer) override
Bind this request port to a response port.
Definition port.cc:148
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the responder port by calling its corresponding receive function.
Definition port.hh:530
void recvRetrySnoopResp() override
Called by the peer if sendTimingSnoopResp was called on this protocol (causing recvTimingSnoopResp to...
Definition port.hh:265
bool sendTimingSnoopResp(PacketPtr pkt)
Attempt to send a timing snoop response packet to the response port by calling its corresponding rece...
Definition port.hh:550
void sendFunctional(PacketPtr pkt) const
Send a functional request packet, where the data is instantly updated everywhere in the memory system...
Definition port.hh:508
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:177
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
Definition port.hh:253
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:497
A ResponsePort is a specialization of a port.
Definition port.hh:288
SimObject & owner
Definition port.hh:297
bool sendTimingResp(PacketPtr pkt)
Attempt to send a timing response to the request port by calling its corresponding receive function.
Definition port.hh:393
void sendFunctionalSnoop(PacketPtr pkt) const
Send a functional snoop request packet, where the data is instantly updated everywhere in the memory ...
Definition port.hh:369
bool tryTiming(PacketPtr pkt) override
Availability request from the peer.
Definition port.hh:468
void bind(Port &peer) override
Attach to a peer port.
Definition port.hh:334
void sendRetrySnoopResp()
Send a retry to the request port that previously attempted a sendTimingSnoopResp to this response por...
Definition port.hh:438
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
Default implementations.
Definition port.cc:238
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition port.hh:474
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:349
void sendTimingSnoopReq(PacketPtr pkt)
Attempt to send a timing snoop request packet to the request port by calling its corresponding receiv...
Definition port.hh:410
bool isSnooping() const
Find out if the peer request port is snooping or not.
Definition port.hh:314
void responderUnbind()
Called by the request port to unbind.
Definition port.cc:224
bool defaultBackdoorWarned
Definition port.hh:294
void unbind() override
We let the request port do the work, so these don't do anything.
Definition port.hh:333
void sendRangeChange() const
Called by the owner to send a range change.
Definition port.hh:319
void responderBind(RequestPort &request_port)
Called by the request port to bind.
Definition port.cc:231
virtual AddrRangeList getAddrRanges() const =0
Get a list of the non-overlapping address ranges the owner is responsible for.
void recvMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &backdoor) override
Receive a request for a back door to a range of memory.
Definition port.cc:249
void sendRetryReq()
Send a retry to the request port that previously attempted a sendTimingReq to this response port and ...
Definition port.hh:424
virtual ~ResponsePort()
Definition port.cc:219
RequestPort * _requestPort
Definition port.hh:292
Abstract superclass for simulation objects.
void sendRetryResp(TimingResponseProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingResp to this protocol and failed.
Definition timing.cc:72
bool trySend(TimingResponseProtocol *peer, PacketPtr pkt) const
Check if the peer can handle a timing request.
Definition timing.cc:56
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
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
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
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
void sendRetrySnoopResp(TimingRequestProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingSnoopResp to this peer and failed.
Definition timing.cc:101
void sendRetryReq(TimingRequestProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingReq to this protocol and failed.
Definition timing.cc:95
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 8 > a
Definition misc_types.hh:66
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition types.hh:246
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
uint64_t Tick
Tick count type.
Definition types.hh:58
Declaration of the Packet class.
Port Object Declaration.

Generated on Mon Jul 10 2023 14:24:33 for gem5 by doxygen 1.9.7