gem5 v24.0.0.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{
51 panic_if(!recvTimingRespCb, "RecvTimingRespCallback is empty.");
52 return recvTimingRespCb(packet);
53}
54
55void
57{
58 panic_if(!recvReqRetryCb, "RecvReqRetryCallback is empty.");
60}
61
62void
67
68void
70 RecvReqRetryCallback retry_cb)
71{
72 recvTimingRespCb = std::move(resp_cb);
73 recvReqRetryCb = std::move(retry_cb);
74}
75
80
83{
84 panic_if(!getAddrRangesCb, "GetAddrRangesCallback is empty.");
85 return getAddrRangesCb();
86}
87
88bool
90{
91 panic_if(!recvTimingReqCb, "RecvTimingReqCallback is empty.");
92 return recvTimingReqCb(packet);
93}
94
95void
97{
98 panic_if(!recvRespRetryCb, "RecvRespRetryCallback is empty.");
100}
101
102Tick
104{
105 panic_if(!recvAtomicCb, "RecvAtomicCallback is empty.");
106 return recvAtomicCb(packet);
107}
108
109Tick
111 MemBackdoorPtr& backdoor)
112{
114 return ResponsePort::recvAtomicBackdoor(packet, backdoor);
115 }
116 return recvAtomicBackdoorCb(packet, backdoor);
117}
118
119void
121{
122 panic_if(!recvFunctionalCb, "RecvFunctionalCallback is empty.");
123 recvFunctionalCb(packet);
124}
125
126void
128 MemBackdoorPtr& backdoor)
129{
132 return;
133 }
134 recvMemBackdoorReqCb(req, backdoor);
135}
136
137void
142
143void
145 RecvRespRetryCallback retry_cb)
146{
147 recvTimingReqCb = std::move(timing_cb);
148 recvRespRetryCb = std::move(retry_cb);
149}
150
151void
153 RecvAtomicBackdoorCallback backdoor_cb)
154{
155 recvAtomicCb = std::move(atomic_cb);
156 recvAtomicBackdoorCb = std::move(backdoor_cb);
157}
158
159void
162{
163 recvFunctionalCb = std::move(func_cb);
164 recvMemBackdoorReqCb = std::move(backdoor_cb);
165}
166
167} // namespace gem5
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
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
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
virtual void recvRangeChange()
Called to receive an address range change from the peer response port.
Definition port.hh:297
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)
A ResponsePort is a specialization of a port.
Definition port.hh:349
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
Default implementations.
Definition port.cc:262
void recvMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &backdoor) override
Receive a request for a back door to a range of memory.
Definition port.cc:273
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition logging.hh:214
Bitfield< 33 > id
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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
PortWrapper Object Declaration.
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0