gem5 [DEVELOP-FOR-25.0]
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:
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
144
145 private:
153};
154
155} // namespace gem5
156
157#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
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 Mon May 26 2025 09:19:12 for gem5 by doxygen 1.13.2