gem5 v25.0.0.1
Loading...
Searching...
No Matches
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
60
61#ifndef __MEM_PORT_WRAPPER_HH__
62#define __MEM_PORT_WRAPPER_HH__
63
64#include <functional>
65
66#include "mem/port.hh"
67
68namespace 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:
97 panic("RecvTimingRespCallback in port %s is empty.", name());
98 return false;
99 };
101 panic("RecvReqRetryCallback in port %s is empty.", name());
102 };
103};
104
110{
111 public:
112 using GetAddrRangesCallback = std::function<AddrRangeList()>;
113 // Timing Protocol
114 using RecvTimingReqCallback = std::function<bool(PacketPtr)>;
115 // Atomic Protocol
116 using RecvAtomicCallback = std::function<Tick(PacketPtr)>;
118 std::function<Tick(PacketPtr, MemBackdoorPtr&)>;
119
120 // Functional Protocol
121 using RecvFunctionalCallback = std::function<void(PacketPtr)>;
123 std::function<void(const MemBackdoorReq&, MemBackdoorPtr&)>;
124
125 using RecvRespRetryCallback = std::function<void()>;
126
127 ResponsePortWrapper(const std::string& name, PortID id = InvalidPortID);
128
129 AddrRangeList getAddrRanges() const override;
130
131 // TimingResponseProtocol
132 bool recvTimingReq(PacketPtr) override;
133 void recvRespRetry() override;
134
135 // AtomicResponseProtocol
136 Tick recvAtomic(PacketPtr) override;
138
139 // FunctionalResponseProtocol
140 void recvFunctional(PacketPtr) override;
141 void recvMemBackdoorReq(const MemBackdoorReq&, MemBackdoorPtr&) override;
142
149
150 private:
152 panic("GetAddrRangesCallback in port %s is empty.", name());
153 return AddrRangeList();
154 };
156 panic("RecvTimingReqCallback in port %s is empty.", name());
157 return false;
158 };
160 panic("RecvRespRetryCallback in port %s is empty.", name());
161 };
163 panic("RecvAtomicCallback in port %s is empty.", name());
164 return 0;
165 };
168 panic("RecvFunctionalCallback in port %s is empty.", name());
169 };
171};
172
173} // namespace gem5
174
175#endif //__MEM_PORT_WRAPPER_HH__
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< void()> RecvRangeChangeCallback
std::function< bool(PacketPtr)> RecvTimingRespCallback
void setRangeChangeCallback(RecvReqRetryCallback)
void setTimingCallbacks(RecvTimingRespCallback, RecvReqRetryCallback)
RecvReqRetryCallback recvReqRetryCb
RecvRangeChangeCallback recvRangeChangeCb
std::function< void()> RecvReqRetryCallback
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)
ResponsePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Response port.
Definition port.cc:218
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
Definition addr_range.hh:64
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:220
Port Object Declaration.
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
const PortID InvalidPortID
Definition types.hh:246
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

Generated on Sat Oct 18 2025 08:06:45 for gem5 by doxygen 1.14.0