gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
port_wrapper.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Google, LLC.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
61 #ifndef __MEM_PORT_WRAPPER_HH__
62 #define __MEM_PORT_WRAPPER_HH__
63 
64 #include <functional>
65 
66 #include "mem/port.hh"
67 
68 namespace gem5
69 {
70 
76 {
77  public:
78  using RecvRangeChangeCallback = std::function<void()>;
79  // Timing Protocol
80  using RecvTimingRespCallback = std::function<bool(PacketPtr)>;
81  using RecvReqRetryCallback = std::function<void()>;
82 
83  RequestPortWrapper(const std::string& name, PortID id = InvalidPortID);
84 
85  void recvRangeChange() override;
86 
87  // TimingRequestProtocol
88  bool recvTimingResp(PacketPtr) override;
89  void recvReqRetry() override;
90 
93 
94  private:
98 };
99 
105 {
106  public:
107  using GetAddrRangesCallback = std::function<AddrRangeList()>;
108  // Timing Protocol
109  using RecvTimingReqCallback = std::function<bool(PacketPtr)>;
110  // Atomic Protocol
111  using RecvAtomicCallback = std::function<Tick(PacketPtr)>;
113  std::function<Tick(PacketPtr, MemBackdoorPtr&)>;
114 
115  // Functional Protocol
116  using RecvFunctionalCallback = std::function<void(PacketPtr)>;
118  std::function<void(const MemBackdoorReq&, MemBackdoorPtr&)>;
119 
120  using RecvRespRetryCallback = std::function<void()>;
121 
122  ResponsePortWrapper(const std::string& name, PortID id = InvalidPortID);
123 
124  AddrRangeList getAddrRanges() const override;
125 
126  // TimingResponseProtocol
127  bool recvTimingReq(PacketPtr) override;
128  void recvRespRetry() override;
129 
130  // AtomicResponseProtocol
131  Tick recvAtomic(PacketPtr) override;
133 
134  // FunctionalResponseProtocol
135  void recvFunctional(PacketPtr) override;
136  void recvMemBackdoorReq(const MemBackdoorReq&, MemBackdoorPtr&) override;
137 
141  RecvAtomicBackdoorCallback = nullptr);
143  RecvMemBackdoorReqCallback = nullptr);
144 
145  private:
153 };
154 
155 } // namespace gem5
156 
157 #endif //__MEM_PORT_WRAPPER_HH__
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
gem5::ResponsePortWrapper::recvTimingReqCb
RecvTimingReqCallback recvTimingReqCb
Definition: port_wrapper.hh:147
gem5::Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:111
gem5::ResponsePortWrapper::setTimingCallbacks
void setTimingCallbacks(RecvTimingReqCallback, RecvRespRetryCallback)
Definition: port_wrapper.cc:144
gem5::ResponsePortWrapper::recvAtomicCb
RecvAtomicCallback recvAtomicCb
Definition: port_wrapper.hh:149
gem5::AddrRangeList
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
Definition: addr_range.hh:57
gem5::RequestPortWrapper
The RequestPortWrapper converts inherit-based RequestPort into callback-based.
Definition: port_wrapper.hh:75
gem5::RequestPortWrapper::RecvTimingRespCallback
std::function< bool(PacketPtr)> RecvTimingRespCallback
Definition: port_wrapper.hh:80
gem5::ResponsePortWrapper
The ResponsePortWrapper converts inherit-based ResponsePort into callback-based.
Definition: port_wrapper.hh:104
gem5::ResponsePortWrapper::RecvFunctionalCallback
std::function< void(PacketPtr)> RecvFunctionalCallback
Definition: port_wrapper.hh:116
gem5::RequestPortWrapper::RecvRangeChangeCallback
std::function< void()> RecvRangeChangeCallback
Definition: port_wrapper.hh:78
gem5::ResponsePortWrapper::recvRespRetryCb
RecvRespRetryCallback recvRespRetryCb
Definition: port_wrapper.hh:148
gem5::RequestPortWrapper::recvTimingResp
bool recvTimingResp(PacketPtr) override
Receive a timing response from the peer.
Definition: port_wrapper.cc:49
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:246
gem5::ResponsePortWrapper::recvAtomicBackdoor
Tick recvAtomicBackdoor(PacketPtr, MemBackdoorPtr &) override
Default implementations.
Definition: port_wrapper.cc:110
gem5::ResponsePortWrapper::recvMemBackdoorReqCb
RecvMemBackdoorReqCallback recvMemBackdoorReqCb
Definition: port_wrapper.hh:152
gem5::RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:118
gem5::ResponsePortWrapper::ResponsePortWrapper
ResponsePortWrapper(const std::string &name, PortID id=InvalidPortID)
Definition: port_wrapper.cc:76
gem5::ResponsePortWrapper::recvAtomic
Tick recvAtomic(PacketPtr) override
Receive an atomic request packet from the peer.
Definition: port_wrapper.cc:103
gem5::ResponsePortWrapper::setAtomicCallbacks
void setAtomicCallbacks(RecvAtomicCallback, RecvAtomicBackdoorCallback=nullptr)
Definition: port_wrapper.cc:152
gem5::RequestPortWrapper::recvReqRetryCb
RecvReqRetryCallback recvReqRetryCb
Definition: port_wrapper.hh:97
gem5::RequestPortWrapper::recvReqRetry
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: port_wrapper.cc:56
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
gem5::RequestPortWrapper::recvRangeChange
void recvRangeChange() override
Called to receive an address range change from the peer response port.
Definition: port_wrapper.cc:39
gem5::ResponsePortWrapper::getAddrRangesCb
GetAddrRangesCallback getAddrRangesCb
Definition: port_wrapper.hh:146
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::ResponsePortWrapper::GetAddrRangesCallback
std::function< AddrRangeList()> GetAddrRangesCallback
Definition: port_wrapper.hh:107
gem5::ResponsePortWrapper::setGetAddrRangesCallback
void setGetAddrRangesCallback(GetAddrRangesCallback)
Definition: port_wrapper.cc:138
port.hh
gem5::ResponsePortWrapper::getAddrRanges
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: port_wrapper.cc:82
gem5::ResponsePortWrapper::recvAtomicBackdoorCb
RecvAtomicBackdoorCallback recvAtomicBackdoorCb
Definition: port_wrapper.hh:150
gem5::RequestPortWrapper::recvTimingRespCb
RecvTimingRespCallback recvTimingRespCb
Definition: port_wrapper.hh:96
gem5::ResponsePortWrapper::recvMemBackdoorReq
void recvMemBackdoorReq(const MemBackdoorReq &, MemBackdoorPtr &) override
Receive a request for a back door to a range of memory.
Definition: port_wrapper.cc:127
gem5::MemBackdoor
Definition: backdoor.hh:41
gem5::ResponsePortWrapper::RecvAtomicCallback
std::function< Tick(PacketPtr)> RecvAtomicCallback
Definition: port_wrapper.hh:111
gem5::RequestPortWrapper::setTimingCallbacks
void setTimingCallbacks(RecvTimingRespCallback, RecvReqRetryCallback)
Definition: port_wrapper.cc:69
gem5::ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:331
gem5::ResponsePortWrapper::recvTimingReq
bool recvTimingReq(PacketPtr) override
Receive a timing request from the peer.
Definition: port_wrapper.cc:89
gem5::ResponsePortWrapper::setFunctionalCallbacks
void setFunctionalCallbacks(RecvFunctionalCallback, RecvMemBackdoorReqCallback=nullptr)
Definition: port_wrapper.cc:160
gem5::ResponsePortWrapper::RecvAtomicBackdoorCallback
std::function< Tick(PacketPtr, MemBackdoorPtr &)> RecvAtomicBackdoorCallback
Definition: port_wrapper.hh:113
gem5::RequestPortWrapper::RecvReqRetryCallback
std::function< void()> RecvReqRetryCallback
Definition: port_wrapper.hh:81
gem5::RequestPortWrapper::RequestPortWrapper
RequestPortWrapper(const std::string &name, PortID id=InvalidPortID)
Definition: port_wrapper.cc:33
gem5::ResponsePortWrapper::recvFunctionalCb
RecvFunctionalCallback recvFunctionalCb
Definition: port_wrapper.hh:151
gem5::ResponsePortWrapper::recvFunctional
void recvFunctional(PacketPtr) override
Receive a functional request packet from the peer.
Definition: port_wrapper.cc:120
gem5::RequestPortWrapper::recvRangeChangeCb
RecvRangeChangeCallback recvRangeChangeCb
Definition: port_wrapper.hh:95
std::list< AddrRange >
gem5::RequestPortWrapper::setRangeChangeCallback
void setRangeChangeCallback(RecvReqRetryCallback)
Definition: port_wrapper.cc:63
gem5::ResponsePortWrapper::recvRespRetry
void recvRespRetry() override
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
Definition: port_wrapper.cc:96
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::ResponsePortWrapper::RecvTimingReqCallback
std::function< bool(PacketPtr)> RecvTimingReqCallback
Definition: port_wrapper.hh:109
gem5::MemBackdoorReq
Definition: backdoor.hh:129
gem5::ResponsePortWrapper::RecvRespRetryCallback
std::function< void()> RecvRespRetryCallback
Definition: port_wrapper.hh:120
gem5::ResponsePortWrapper::RecvMemBackdoorReqCallback
std::function< void(const MemBackdoorReq &, MemBackdoorPtr &)> RecvMemBackdoorReqCallback
Definition: port_wrapper.hh:118

Generated on Sun Jul 30 2023 01:56:58 for gem5 by doxygen 1.8.17