gem5 v24.0.0.0
Loading...
Searching...
No Matches
addr_mapper.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met: redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer;
18 * redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution;
21 * neither the name of the copyright holders nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef __MEM_ADDR_MAPPER_HH__
39#define __MEM_ADDR_MAPPER_HH__
40
41#include <vector>
42
44#include "mem/packet.hh"
45#include "mem/port.hh"
46#include "params/AddrMapper.hh"
47#include "params/RangeAddrMapper.hh"
48#include "sim/sim_object.hh"
49
50namespace gem5
51{
52
62class AddrMapper : public SimObject
63{
64 public:
65 AddrMapper(const AddrMapperParams &params);
66
67 virtual ~AddrMapper() = default;
68
69 Port &getPort(const std::string &if_name,
70 PortID idx=InvalidPortID) override;
71
72 void init() override;
73
74 protected:
82 virtual Addr remapAddr(Addr addr) const = 0;
83
96 const AddrRange &range) = 0;
97
99 {
100
101 public:
102
108 AddrMapperSenderState(Addr _origAddr) : origAddr(_origAddr)
109 {}
110
113
116 };
117
119 {
120 public:
121 MapperRequestPort(const std::string& _name, AddrMapper& _mapper)
122 : RequestPort(_name), mapper(_mapper)
123 { }
124
125 protected:
126 void
128 {
130 }
131
132 Tick
134 {
135 return mapper.recvAtomicSnoop(pkt);
136 }
137
138 bool
140 {
141 return mapper.recvTimingResp(pkt);
142 }
143
144 void
146 {
148 }
149
150 void
152 {
154 }
155
156 bool
157 isSnooping() const override
158 {
159 return mapper.isSnooping();
160 }
161
162 void
163 recvReqRetry() override
164 {
166 }
167
168 private:
170 };
171
174
176 {
177 public:
178 MapperResponsePort(const std::string& _name, AddrMapper& _mapper)
179 : ResponsePort(_name), mapper(_mapper)
180 {}
181
182 protected:
183 void
185 {
187 }
188
190 MemBackdoorPtr &backdoor) override
191 {
192 mapper.recvMemBackdoorReq(req, backdoor);
193 }
194
195 Tick
196 recvAtomic(PacketPtr pkt) override
197 {
198 return mapper.recvAtomic(pkt);
199 }
200
201 Tick
203 {
204 return mapper.recvAtomicBackdoor(pkt, backdoor);
205 }
206
207 bool
209 {
210 return mapper.recvTimingReq(pkt);
211 }
212
213 bool
215 {
216 return mapper.recvTimingSnoopResp(pkt);
217 }
218
220 getAddrRanges() const override
221 {
222 return mapper.getAddrRanges();
223 }
224
225 void
226 recvRespRetry() override
227 {
229 }
230
231 private:
233 };
234
237
238 void recvFunctional(PacketPtr pkt);
239
241
242 void recvMemBackdoorReq(const MemBackdoorReq &req,
243 MemBackdoorPtr &backdoor);
244
246
248
250
251 bool recvTimingReq(PacketPtr pkt);
252
253 bool recvTimingResp(PacketPtr pkt);
254
256
258
259 virtual AddrRangeList getAddrRanges() const = 0;
260
261 bool isSnooping() const;
262
263 void recvReqRetry();
264
265 void recvRespRetry();
266
267 virtual void recvRangeChange();
268};
269
277{
278 public:
279 RangeAddrMapper(const RangeAddrMapperParams &p);
280
281 ~RangeAddrMapper() = default;
282
283 AddrRangeList getAddrRanges() const override;
284
285 void
286 init() override
287 {
290 }
291
292 protected:
299
305
306 Addr remapAddr(Addr addr) const override;
307
309 const AddrRange &range) override;
310
311 void
313 {
314 // TODO Check that our peer is actually expecting to receive accesses
315 // in our output range(s).
316 }
317
318 private:
320};
321
322} // namespace gem5
323
324#endif //__MEM_ADDR_MAPPER_HH__
Addr origAddr
The original address the packet was destined for.
AddrMapperSenderState(Addr _origAddr)
Construct a new sender state to remember the original address.
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
void recvRangeChange() override
Called to receive an address range change from the peer response port.
bool isSnooping() const override
Determine if this request port is snooping or not.
MapperRequestPort(const std::string &_name, AddrMapper &_mapper)
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
Tick recvAtomicSnoop(PacketPtr pkt) override
Receive an atomic snoop request packet from our peer.
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the peer.
MapperResponsePort(const std::string &_name, AddrMapper &_mapper)
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
Receive an atomic request packet from the peer, and optionally provide a backdoor to the data being a...
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
void recvRespRetry() override
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
void recvMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &backdoor) override
Receive a request for a back door to a range of memory.
An address mapper changes the packet addresses in going from the response port side of the mapper to ...
MapperRequestPort memSidePort
Instance of request port, facing the memory side.
virtual AddrRangeList getAddrRanges() const =0
virtual MemBackdoorPtr getRevertedBackdoor(MemBackdoorPtr &backdoor, const AddrRange &range)=0
This function returns a backdoor that fulfills the initiator request, based on the target backdoor at...
virtual void recvRangeChange()
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor)
MapperResponsePort cpuSidePort
Instance of response port, i.e.
Tick recvAtomicSnoop(PacketPtr pkt)
bool recvTimingResp(PacketPtr pkt)
void recvMemBackdoorReq(const MemBackdoorReq &req, MemBackdoorPtr &backdoor)
void recvFunctionalSnoop(PacketPtr pkt)
bool recvTimingReq(PacketPtr pkt)
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
void recvTimingSnoopReq(PacketPtr pkt)
virtual ~AddrMapper()=default
bool isSnooping() const
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void recvFunctional(PacketPtr pkt)
bool recvTimingSnoopResp(PacketPtr pkt)
Tick recvAtomic(PacketPtr pkt)
virtual Addr remapAddr(Addr addr) const =0
This function does the actual remapping of one address to another.
AddrMapper(const AddrMapperParams &params)
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition addr_range.hh:82
This class manages the backdoors for RangeAddrMapper.
const std::string _name
Definition named.hh:41
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Ports are used to interface objects to each other.
Definition port.hh:62
Range address mapper that maps a set of original ranges to a set of remapped ranges,...
MemBackdoorPtr getRevertedBackdoor(MemBackdoorPtr &backdoor, const AddrRange &range) override
This function returns a backdoor that fulfills the initiator request, based on the target backdoor at...
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
~RangeAddrMapper()=default
std::vector< AddrRange > originalRanges
This contains a list of ranges the should be remapped.
std::vector< AddrRange > remappedRanges
This contains a list of ranges that addresses should be remapped to.
RangeAddrMapper(const RangeAddrMapperParams &p)
Addr remapAddr(Addr addr) const override
This function does the actual remapping of one address to another.
AddrRangeList getAddrRanges() const override
BackdoorManager backdoorManager
void recvRangeChange() override
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
A ResponsePort is a specialization of a port.
Definition port.hh:349
void sendRangeChange() const
Called by the owner to send a range change.
Definition port.hh:380
Abstract superclass for simulation objects.
STL vector class.
Definition stl.hh:37
const Params & params() const
Port Object Declaration.
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
const PortID InvalidPortID
Definition types.hh:246
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
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
Declaration of the Packet class.
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition packet.hh:469

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