gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Andreas Hansson
38  */
39 
40 #ifndef __MEM_ADDR_MAPPER_HH__
41 #define __MEM_ADDR_MAPPER_HH__
42 
43 #include "mem/port.hh"
44 #include "params/AddrMapper.hh"
45 #include "params/RangeAddrMapper.hh"
46 #include "sim/sim_object.hh"
47 
57 class AddrMapper : public SimObject
58 {
59 
60  public:
61 
62  AddrMapper(const AddrMapperParams* params);
63 
64  virtual ~AddrMapper() { }
65 
66  Port &getPort(const std::string &if_name,
67  PortID idx=InvalidPortID) override;
68 
69  void init() override;
70 
71  protected:
72 
80  virtual Addr remapAddr(Addr addr) const = 0;
81 
83  {
84 
85  public:
86 
92  AddrMapperSenderState(Addr _origAddr) : origAddr(_origAddr)
93  { }
94 
97 
100 
101  };
102 
104  {
105 
106  public:
107 
108  MapperMasterPort(const std::string& _name, AddrMapper& _mapper)
109  : MasterPort(_name, &_mapper), mapper(_mapper)
110  { }
111 
112  protected:
113 
115  {
116  mapper.recvFunctionalSnoop(pkt);
117  }
118 
120  {
121  return mapper.recvAtomicSnoop(pkt);
122  }
123 
125  {
126  return mapper.recvTimingResp(pkt);
127  }
128 
130  {
131  mapper.recvTimingSnoopReq(pkt);
132  }
133 
135  {
136  mapper.recvRangeChange();
137  }
138 
139  bool isSnooping() const
140  {
141  return mapper.isSnooping();
142  }
143 
145  {
146  mapper.recvReqRetry();
147  }
148 
149  private:
150 
152 
153  };
154 
157 
158  class MapperSlavePort : public SlavePort
159  {
160 
161  public:
162 
163  MapperSlavePort(const std::string& _name, AddrMapper& _mapper)
164  : SlavePort(_name, &_mapper), mapper(_mapper)
165  { }
166 
167  protected:
168 
170  {
171  mapper.recvFunctional(pkt);
172  }
173 
175  {
176  return mapper.recvAtomic(pkt);
177  }
178 
180  {
181  return mapper.recvTimingReq(pkt);
182  }
183 
185  {
186  return mapper.recvTimingSnoopResp(pkt);
187  }
188 
190  {
191  return mapper.getAddrRanges();
192  }
193 
195  {
196  mapper.recvRespRetry();
197  }
198 
199  private:
200 
202 
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  void recvRangeChange();
233 };
234 
242 {
243 
244  public:
245 
246  RangeAddrMapper(const RangeAddrMapperParams* p);
247 
249 
251 
252  protected:
253 
260 
266 
267  Addr remapAddr(Addr addr) const;
268 
269 };
270 
271 #endif //__MEM_ADDR_MAPPER_HH__
bool isSnooping() const
Definition: addr_mapper.cc:180
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:75
MapperMasterPort masterPort
Instance of master port, facing the memory side.
Definition: addr_mapper.hh:156
Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the peer.
Definition: addr_mapper.hh:174
AddrMapper(const AddrMapperParams *params)
Definition: addr_mapper.cc:42
Ports are used to interface objects to each other.
Definition: port.hh:60
void recvRespRetry()
Definition: addr_mapper.cc:194
void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
Definition: addr_mapper.hh:114
Addr origAddr
The original address the packet was destined for.
Definition: addr_mapper.hh:99
void recvRangeChange()
Called to receive an address range change from the peer slave port.
Definition: addr_mapper.hh:134
Tick recvAtomicSnoop(PacketPtr pkt)
Definition: addr_mapper.cc:97
void recvReqRetry()
Definition: addr_mapper.cc:188
void recvTimingSnoopReq(PacketPtr pkt)
Definition: addr_mapper.cc:168
MapperSlavePort slavePort
Instance of slave port, i.e.
Definition: addr_mapper.hh:206
const PortID InvalidPortID
Definition: types.hh:238
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: addr_mapper.hh:124
void recvRespRetry()
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
Definition: addr_mapper.hh:194
ip6_addr_t addr
Definition: inet.hh:335
A SlavePort is a specialisation of a port.
Definition: port.hh:258
void recvRangeChange()
Definition: addr_mapper.cc:200
AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: addr_mapper.hh:189
virtual ~AddrMapper()
Definition: addr_mapper.hh:64
MapperSlavePort(const std::string &_name, AddrMapper &_mapper)
Definition: addr_mapper.hh:163
bool recvTimingSnoopResp(PacketPtr pkt)
Receive a timing snoop response from the peer.
Definition: addr_mapper.hh:184
std::vector< AddrRange > originalRanges
This contains a list of ranges the should be remapped.
Definition: addr_mapper.hh:259
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: addr_mapper.cc:57
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: addr_mapper.hh:144
uint64_t Tick
Tick count type.
Definition: types.hh:63
const Params * params() const
Definition: sim_object.hh:114
void recvFunctional(PacketPtr pkt)
Definition: addr_mapper.cc:69
Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from our peer.
Definition: addr_mapper.hh:119
virtual AddrRangeList getAddrRanges() const =0
bool recvTimingReq(PacketPtr pkt)
Definition: addr_mapper.cc:107
virtual Addr remapAddr(Addr addr) const =0
This function does the actual remapping of one address to another.
Port Object Declaration.
bool isSnooping() const
Determine if this master port is snooping or not.
Definition: addr_mapper.hh:139
bool recvTimingResp(PacketPtr pkt)
Definition: addr_mapper.cc:135
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
bool recvTimingSnoopResp(PacketPtr pkt)
Definition: addr_mapper.cc:174
A virtual base opaque structure used to hold state associated with the packet (e.g., an MSHR), specific to a SimObject that sees the packet.
Definition: packet.hh:403
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: addr_mapper.cc:50
MapperMasterPort(const std::string &_name, AddrMapper &_mapper)
Definition: addr_mapper.hh:108
An address mapper changes the packet addresses in going from the slave port side of the mapper to the...
Definition: addr_mapper.hh:57
void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the peer.
Definition: addr_mapper.hh:129
Tick recvAtomic(PacketPtr pkt)
Definition: addr_mapper.cc:87
Range address mapper that maps a set of original ranges to a set of remapped ranges, where a specific range is of the same size (original and remapped), only with an offset.
Definition: addr_mapper.hh:241
AddrMapperSenderState(Addr _origAddr)
Construct a new sender state to remember the original address.
Definition: addr_mapper.hh:92
void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the peer.
Definition: addr_mapper.hh:169
void recvFunctionalSnoop(PacketPtr pkt)
Definition: addr_mapper.cc:78
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
bool recvTimingReq(PacketPtr pkt)
Receive a timing request from the peer.
Definition: addr_mapper.hh:179
Bitfield< 0 > p
std::vector< AddrRange > remappedRanges
This contains a list of ranges that addresses should be remapped to.
Definition: addr_mapper.hh:265
Abstract superclass for simulation objects.
Definition: sim_object.hh:96

Generated on Fri Feb 28 2020 16:27:01 for gem5 by doxygen 1.8.13