gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
port_wrapper.cc
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
28#include "mem/port_wrapper.hh"
29
30namespace gem5
31{
32
37
38void
47
48bool
50{
52 "RecvTimingRespCallback in port %s is empty.", name());
53 return recvTimingRespCb(packet);
54}
55
56void
58{
60 "RecvReqRetryCallback in port %s is empty.", name());
62}
63
64void
69
70void
72 RecvReqRetryCallback retry_cb)
73{
74 recvTimingRespCb = std::move(resp_cb);
75 recvReqRetryCb = std::move(retry_cb);
76}
77
82
85{
87 "GetAddrRangesCallback in port %s is empty.", name());
88 return getAddrRangesCb();
89}
90
91bool
93{
95 "RecvTimingReqCallback in port %s is empty.", name());
96 return recvTimingReqCb(packet);
97}
98
99void
101{
103 "RecvRespRetryCallback in port %s is empty.", name());
105}
106
107Tick
109{
110 panic_if(!recvAtomicCb, "RecvAtomicCallback in port %s is empty.", name());
111 return recvAtomicCb(packet);
112}
113
114Tick
116 MemBackdoorPtr& backdoor)
117{
119 return ResponsePort::recvAtomicBackdoor(packet, backdoor);
120 }
121 return recvAtomicBackdoorCb(packet, backdoor);
122}
123
124void
126{
128 "RecvFunctionalCallback in port %s is empty.", name());
129 recvFunctionalCb(packet);
130}
131
132void
134 MemBackdoorPtr& backdoor)
135{
138 return;
139 }
140 recvMemBackdoorReqCb(req, backdoor);
141}
142
143void
148
149void
151 RecvRespRetryCallback retry_cb)
152{
153 recvTimingReqCb = std::move(timing_cb);
154 recvRespRetryCb = std::move(retry_cb);
155}
156
157void
159 RecvAtomicBackdoorCallback backdoor_cb)
160{
161 recvAtomicCb = std::move(atomic_cb);
162 recvAtomicBackdoorCb = std::move(backdoor_cb);
163}
164
165void
168{
169 recvFunctionalCb = std::move(func_cb);
170 recvMemBackdoorReqCb = std::move(backdoor_cb);
171}
172
173} // namespace gem5
const std::string name() const
Return port name (for DPRINTF).
Definition port.hh:111
RecvTimingRespCallback recvTimingRespCb
RequestPortWrapper(const std::string &name, PortID id=InvalidPortID)
void recvRangeChange() override
Called to receive an address range change from the peer response port.
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
bool recvTimingResp(PacketPtr) override
Receive a timing response from the peer.
std::function< bool(PacketPtr)> RecvTimingRespCallback
void setRangeChangeCallback(RecvReqRetryCallback)
void setTimingCallbacks(RecvTimingRespCallback, RecvReqRetryCallback)
RecvReqRetryCallback recvReqRetryCb
RecvRangeChangeCallback recvRangeChangeCb
std::function< void()> RecvReqRetryCallback
virtual void recvRangeChange()
Called to receive an address range change from the peer response port.
Definition port.hh:297
RequestPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Request port.
Definition port.cc:125
void setTimingCallbacks(RecvTimingReqCallback, RecvRespRetryCallback)
RecvAtomicBackdoorCallback recvAtomicBackdoorCb
std::function< void()> RecvRespRetryCallback
std::function< void(const MemBackdoorReq &, MemBackdoorPtr &)> RecvMemBackdoorReqCallback
RecvMemBackdoorReqCallback recvMemBackdoorReqCb
ResponsePortWrapper(const std::string &name, PortID id=InvalidPortID)
Tick recvAtomic(PacketPtr) override
Receive an atomic request packet from the peer.
Tick recvAtomicBackdoor(PacketPtr, MemBackdoorPtr &) override
Default implementations.
void recvRespRetry() override
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
void setFunctionalCallbacks(RecvFunctionalCallback, RecvMemBackdoorReqCallback=nullptr)
RecvFunctionalCallback recvFunctionalCb
void setGetAddrRangesCallback(GetAddrRangesCallback)
std::function< AddrRangeList()> GetAddrRangesCallback
RecvAtomicCallback recvAtomicCb
std::function< void(PacketPtr)> RecvFunctionalCallback
void recvFunctional(PacketPtr) override
Receive a functional request packet from the peer.
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
RecvTimingReqCallback recvTimingReqCb
GetAddrRangesCallback getAddrRangesCb
void recvMemBackdoorReq(const MemBackdoorReq &, MemBackdoorPtr &) override
Receive a request for a back door to a range of memory.
std::function< bool(PacketPtr)> RecvTimingReqCallback
RecvRespRetryCallback recvRespRetryCb
std::function< Tick(PacketPtr, MemBackdoorPtr &)> RecvAtomicBackdoorCallback
std::function< Tick(PacketPtr)> RecvAtomicCallback
bool recvTimingReq(PacketPtr) override
Receive a timing request from the peer.
void setAtomicCallbacks(RecvAtomicCallback, RecvAtomicBackdoorCallback=nullptr)
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
Default implementations.
Definition port.cc:262
ResponsePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Response port.
Definition port.cc:218
void recvMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &backdoor) override
Receive a request for a back door to a range of memory.
Definition port.cc:273
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
Definition addr_range.hh:64
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition logging.hh:246
Bitfield< 33 > id
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
MemBackdoor * MemBackdoorPtr
Definition backdoor.hh:127
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
Packet * PacketPtr
PortWrapper Object Declaration.

Generated on Mon May 26 2025 09:19:12 for gem5 by doxygen 1.13.2