gem5  v21.1.0.2
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 "mem/port.hh"
42 #include "params/AddrMapper.hh"
43 #include "params/RangeAddrMapper.hh"
44 #include "sim/sim_object.hh"
45 
46 namespace gem5
47 {
48 
58 class AddrMapper : public SimObject
59 {
60  public:
61  AddrMapper(const AddrMapperParams &params);
62 
63  virtual ~AddrMapper() = default;
64 
65  Port &getPort(const std::string &if_name,
66  PortID idx=InvalidPortID) override;
67 
68  void init() override;
69 
70  protected:
78  virtual Addr remapAddr(Addr addr) const = 0;
79 
81  {
82 
83  public:
84 
90  AddrMapperSenderState(Addr _origAddr) : origAddr(_origAddr)
91  {}
92 
95 
98  };
99 
101  {
102  public:
103  MapperRequestPort(const std::string& _name, AddrMapper& _mapper)
104  : RequestPort(_name, &_mapper), mapper(_mapper)
105  { }
106 
107  protected:
108  void
110  {
112  }
113 
114  Tick
116  {
117  return mapper.recvAtomicSnoop(pkt);
118  }
119 
120  bool
121  recvTimingResp(PacketPtr pkt) override
122  {
123  return mapper.recvTimingResp(pkt);
124  }
125 
126  void
128  {
130  }
131 
132  void
133  recvRangeChange() override
134  {
136  }
137 
138  bool
139  isSnooping() const override
140  {
141  return mapper.isSnooping();
142  }
143 
144  void
145  recvReqRetry() override
146  {
148  }
149 
150  private:
152  };
153 
156 
158  {
159  public:
160  MapperResponsePort(const std::string& _name, AddrMapper& _mapper)
161  : ResponsePort(_name, &_mapper), mapper(_mapper)
162  {}
163 
164  protected:
165  void
166  recvFunctional(PacketPtr pkt) override
167  {
168  mapper.recvFunctional(pkt);
169  }
170 
171  Tick
172  recvAtomic(PacketPtr pkt) override
173  {
174  return mapper.recvAtomic(pkt);
175  }
176 
177  bool
178  recvTimingReq(PacketPtr pkt) override
179  {
180  return mapper.recvTimingReq(pkt);
181  }
182 
183  bool
185  {
186  return mapper.recvTimingSnoopResp(pkt);
187  }
188 
190  getAddrRanges() const override
191  {
192  return mapper.getAddrRanges();
193  }
194 
195  void
196  recvRespRetry() override
197  {
199  }
200 
201  private:
203  };
204 
207 
208  void recvFunctional(PacketPtr pkt);
209 
210  void recvFunctionalSnoop(PacketPtr pkt);
211 
213 
215 
216  bool recvTimingReq(PacketPtr pkt);
217 
218  bool recvTimingResp(PacketPtr pkt);
219 
220  void recvTimingSnoopReq(PacketPtr pkt);
221 
222  bool recvTimingSnoopResp(PacketPtr pkt);
223 
224  virtual AddrRangeList getAddrRanges() const = 0;
225 
226  bool isSnooping() const;
227 
228  void recvReqRetry();
229 
230  void recvRespRetry();
231 
232  virtual void recvRangeChange();
233 };
234 
242 {
243  public:
244  RangeAddrMapper(const RangeAddrMapperParams &p);
245 
246  ~RangeAddrMapper() = default;
247 
248  AddrRangeList getAddrRanges() const override;
249 
250  void
251  init() override
252  {
255  }
256 
257  protected:
264 
270 
271  Addr remapAddr(Addr addr) const override;
272  void
273  recvRangeChange() override
274  {
275  // TODO Check that our peer is actually expecting to receive accesses
276  // in our output range(s).
277  }
278 };
279 
280 } // namespace gem5
281 
282 #endif //__MEM_ADDR_MAPPER_HH__
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:252
gem5::AddrMapper::MapperRequestPort
Definition: addr_mapper.hh:100
gem5::RangeAddrMapper::remapAddr
Addr remapAddr(Addr addr) const override
This function does the actual remapping of one address to another.
Definition: addr_mapper.cc:223
gem5::AddrMapper::MapperResponsePort::recvFunctional
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
Definition: addr_mapper.hh:166
gem5::AddrMapper::MapperRequestPort::recvTimingSnoopReq
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
Definition: addr_mapper.hh:127
gem5::AddrMapper::recvTimingReq
bool recvTimingReq(PacketPtr pkt)
Definition: addr_mapper.cc:108
gem5::AddrMapper::MapperResponsePort
Definition: addr_mapper.hh:157
gem5::AddrMapper::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: addr_mapper.cc:58
gem5::RangeAddrMapper::remappedRanges
std::vector< AddrRange > remappedRanges
This contains a list of ranges that addresses should be remapped to.
Definition: addr_mapper.hh:269
gem5::AddrMapper::recvTimingResp
bool recvTimingResp(PacketPtr pkt)
Definition: addr_mapper.cc:136
gem5::AddrMapper::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: addr_mapper.cc:51
gem5::AddrMapper::AddrMapperSenderState::AddrMapperSenderState
AddrMapperSenderState(Addr _origAddr)
Construct a new sender state to remember the original address.
Definition: addr_mapper.hh:90
std::vector
STL vector class.
Definition: stl.hh:37
gem5::AddrMapper::MapperRequestPort::recvTimingResp
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
Definition: addr_mapper.hh:121
gem5::AddrMapper::MapperResponsePort::recvAtomic
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
Definition: addr_mapper.hh:172
gem5::AddrMapper::AddrMapperSenderState::~AddrMapperSenderState
~AddrMapperSenderState()
Destructor.
Definition: addr_mapper.hh:94
gem5::AddrMapper::recvRespRetry
void recvRespRetry()
Definition: addr_mapper.cc:195
gem5::AddrMapper::MapperResponsePort::MapperResponsePort
MapperResponsePort(const std::string &_name, AddrMapper &_mapper)
Definition: addr_mapper.hh:160
gem5::AddrMapper::MapperRequestPort::recvRangeChange
void recvRangeChange() override
Called to receive an address range change from the peer response port.
Definition: addr_mapper.hh:133
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:253
gem5::AddrMapper::memSidePort
MapperRequestPort memSidePort
Instance of request port, facing the memory side.
Definition: addr_mapper.hh:155
gem5::AddrMapper::MapperResponsePort::recvTimingSnoopResp
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition: addr_mapper.hh:184
gem5::RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:77
gem5::AddrMapper::remapAddr
virtual Addr remapAddr(Addr addr) const =0
This function does the actual remapping of one address to another.
gem5::AddrMapper::recvAtomicSnoop
Tick recvAtomicSnoop(PacketPtr pkt)
Definition: addr_mapper.cc:98
gem5::RangeAddrMapper::~RangeAddrMapper
~RangeAddrMapper()=default
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
sim_object.hh
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::AddrMapper::MapperResponsePort::mapper
AddrMapper & mapper
Definition: addr_mapper.hh:202
gem5::AddrMapper::getAddrRanges
virtual AddrRangeList getAddrRanges() const =0
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::AddrMapper::MapperRequestPort::mapper
AddrMapper & mapper
Definition: addr_mapper.hh:151
port.hh
gem5::RangeAddrMapper::getAddrRanges
AddrRangeList getAddrRanges() const override
Definition: addr_mapper.cc:236
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::Packet::SenderState
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition: packet.hh:457
gem5::AddrMapper::MapperRequestPort::recvReqRetry
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: addr_mapper.hh:145
gem5::RangeAddrMapper::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: addr_mapper.hh:251
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::AddrMapper::recvTimingSnoopResp
bool recvTimingSnoopResp(PacketPtr pkt)
Definition: addr_mapper.cc:175
gem5::ResponsePort::sendRangeChange
void sendRangeChange() const
Called by the owner to send a range change.
Definition: port.hh:296
gem5::AddrMapper::recvTimingSnoopReq
void recvTimingSnoopReq(PacketPtr pkt)
Definition: addr_mapper.cc:169
gem5::AddrMapper::recvFunctional
void recvFunctional(PacketPtr pkt)
Definition: addr_mapper.cc:70
gem5::RangeAddrMapper::recvRangeChange
void recvRangeChange() override
Definition: addr_mapper.hh:273
gem5::RangeAddrMapper
Range address mapper that maps a set of original ranges to a set of remapped ranges,...
Definition: addr_mapper.hh:241
gem5::AddrMapper::isSnooping
bool isSnooping() const
Definition: addr_mapper.cc:181
gem5::ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:268
gem5::AddrMapper::AddrMapperSenderState
Definition: addr_mapper.hh:80
gem5::AddrMapper::recvRangeChange
virtual void recvRangeChange()
Definition: addr_mapper.cc:201
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
gem5::AddrMapper::cpuSidePort
MapperResponsePort cpuSidePort
Instance of response port, i.e.
Definition: addr_mapper.hh:206
gem5::AddrMapper::MapperResponsePort::recvRespRetry
void recvRespRetry() override
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
Definition: addr_mapper.hh:196
gem5::AddrMapper
An address mapper changes the packet addresses in going from the response port side of the mapper to ...
Definition: addr_mapper.hh:58
gem5::AddrMapper::recvFunctionalSnoop
void recvFunctionalSnoop(PacketPtr pkt)
Definition: addr_mapper.cc:79
gem5::AddrMapper::MapperResponsePort::getAddrRanges
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: addr_mapper.hh:190
gem5::AddrMapper::MapperRequestPort::MapperRequestPort
MapperRequestPort(const std::string &_name, AddrMapper &_mapper)
Definition: addr_mapper.hh:103
gem5::AddrMapper::MapperResponsePort::recvTimingReq
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the peer.
Definition: addr_mapper.hh:178
gem5::AddrMapper::MapperRequestPort::isSnooping
bool isSnooping() const override
Determine if this request port is snooping or not.
Definition: addr_mapper.hh:139
gem5::AddrMapper::recvReqRetry
void recvReqRetry()
Definition: addr_mapper.cc:189
gem5::AddrMapper::AddrMapperSenderState::origAddr
Addr origAddr
The original address the packet was destined for.
Definition: addr_mapper.hh:97
std::list< AddrRange >
gem5::AddrMapper::recvAtomic
Tick recvAtomic(PacketPtr pkt)
Definition: addr_mapper.cc:88
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::AddrMapper::MapperRequestPort::recvAtomicSnoop
Tick recvAtomicSnoop(PacketPtr pkt) override
Receive an atomic snoop request packet from our peer.
Definition: addr_mapper.hh:115
gem5::AddrMapper::~AddrMapper
virtual ~AddrMapper()=default
gem5::RangeAddrMapper::originalRanges
std::vector< AddrRange > originalRanges
This contains a list of ranges the should be remapped.
Definition: addr_mapper.hh:263
gem5::Named::_name
const std::string _name
Definition: named.hh:41
gem5::AddrMapper::MapperRequestPort::recvFunctionalSnoop
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
Definition: addr_mapper.hh:109
gem5::AddrMapper::AddrMapper
AddrMapper(const AddrMapperParams &params)
Definition: addr_mapper.cc:43
gem5::RangeAddrMapper::RangeAddrMapper
RangeAddrMapper(const RangeAddrMapperParams &p)
Definition: addr_mapper.cc:206
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Tue Sep 21 2021 12:25:27 for gem5 by doxygen 1.8.17