gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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/mem_object.hh"
44 #include "params/AddrMapper.hh"
45 #include "params/RangeAddrMapper.hh"
46 
56 class AddrMapper : public MemObject
57 {
58 
59  public:
60 
61  AddrMapper(const AddrMapperParams* params);
62 
63  virtual ~AddrMapper() { }
64 
65  virtual BaseMasterPort& getMasterPort(const std::string& if_name,
66  PortID idx = InvalidPortID);
67 
68  virtual BaseSlavePort& getSlavePort(const std::string& if_name,
69  PortID idx = InvalidPortID);
70 
71  virtual void init();
72 
73  protected:
74 
82  virtual Addr remapAddr(Addr addr) const = 0;
83 
85  {
86 
87  public:
88 
94  AddrMapperSenderState(Addr _origAddr) : origAddr(_origAddr)
95  { }
96 
99 
102 
103  };
104 
106  {
107 
108  public:
109 
110  MapperMasterPort(const std::string& _name, AddrMapper& _mapper)
111  : MasterPort(_name, &_mapper), mapper(_mapper)
112  { }
113 
114  protected:
115 
117  {
119  }
120 
122  {
123  return mapper.recvAtomicSnoop(pkt);
124  }
125 
127  {
128  return mapper.recvTimingResp(pkt);
129  }
130 
132  {
134  }
135 
137  {
139  }
140 
141  bool isSnooping() const
142  {
143  return mapper.isSnooping();
144  }
145 
147  {
149  }
150 
151  private:
152 
154 
155  };
156 
159 
160  class MapperSlavePort : public SlavePort
161  {
162 
163  public:
164 
165  MapperSlavePort(const std::string& _name, AddrMapper& _mapper)
166  : SlavePort(_name, &_mapper), mapper(_mapper)
167  { }
168 
169  protected:
170 
172  {
173  mapper.recvFunctional(pkt);
174  }
175 
177  {
178  return mapper.recvAtomic(pkt);
179  }
180 
182  {
183  return mapper.recvTimingReq(pkt);
184  }
185 
187  {
188  return mapper.recvTimingSnoopResp(pkt);
189  }
190 
192  {
193  return mapper.getAddrRanges();
194  }
195 
197  {
199  }
200 
201  private:
202 
204 
205  };
206 
209 
210  void recvFunctional(PacketPtr pkt);
211 
212  void recvFunctionalSnoop(PacketPtr pkt);
213 
215 
217 
218  bool recvTimingReq(PacketPtr pkt);
219 
220  bool recvTimingResp(PacketPtr pkt);
221 
222  void recvTimingSnoopReq(PacketPtr pkt);
223 
224  bool recvTimingSnoopResp(PacketPtr pkt);
225 
226  virtual AddrRangeList getAddrRanges() const = 0;
227 
228  bool isSnooping() const;
229 
230  void recvReqRetry();
231 
232  void recvRespRetry();
233 
234  void recvRangeChange();
235 };
236 
244 {
245 
246  public:
247 
248  RangeAddrMapper(const RangeAddrMapperParams* p);
249 
251 
253 
254  protected:
255 
262 
268 
269  Addr remapAddr(Addr addr) const;
270 
271 };
272 
273 #endif //__MEM_ADDR_MAPPER_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:167
MapperMasterPort masterPort
Instance of master port, facing the memory side.
Definition: addr_mapper.hh:158
Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the master port.
Definition: addr_mapper.hh:176
AddrMapper(const AddrMapperParams *params)
Definition: addr_mapper.cc:42
void recvRespRetry()
Definition: addr_mapper.cc:202
void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the slave port.
Definition: addr_mapper.hh:116
Addr origAddr
The original address the packet was destined for.
Definition: addr_mapper.hh:101
void recvRangeChange()
Called to receive an address range change from the peer slave port.
Definition: addr_mapper.hh:136
Tick recvAtomicSnoop(PacketPtr pkt)
Definition: addr_mapper.cc:105
void recvReqRetry()
Definition: addr_mapper.cc:196
void recvTimingSnoopReq(PacketPtr pkt)
Definition: addr_mapper.cc:176
MapperSlavePort slavePort
Instance of slave port, i.e.
Definition: addr_mapper.hh:208
const PortID InvalidPortID
Definition: types.hh:182
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the slave port.
Definition: addr_mapper.hh:126
void recvRespRetry()
Called by the master port if sendTimingResp was called on this slave port (causing recvTimingResp to ...
Definition: addr_mapper.hh:196
ip6_addr_t addr
Definition: inet.hh:335
MemObject declaration.
const Params * params() const
Definition: mem_object.hh:64
A SlavePort is a specialisation of a port.
Definition: port.hh:331
void recvRangeChange()
Definition: addr_mapper.cc:208
AddrRangeList getAddrRanges() const
Definition: addr_mapper.cc:249
virtual ~AddrMapper()
Definition: addr_mapper.hh:63
A BaseSlavePort is a protocol-agnostic slave port, responsible only for the structural connection to ...
Definition: port.hh:139
MapperSlavePort(const std::string &_name, AddrMapper &_mapper)
Definition: addr_mapper.hh:165
bool recvTimingSnoopResp(PacketPtr pkt)
Receive a timing snoop response from the master port.
Definition: addr_mapper.hh:186
std::vector< AddrRange > originalRanges
This contains a list of ranges the should be remapped.
Definition: addr_mapper.hh:261
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: addr_mapper.cc:50
RangeAddrMapper(const RangeAddrMapperParams *p)
Definition: addr_mapper.cc:213
void recvReqRetry()
Called by the slave port if sendTimingReq was called on this master port (causing recvTimingReq to be...
Definition: addr_mapper.hh:146
uint64_t Tick
Tick count type.
Definition: types.hh:63
void recvFunctional(PacketPtr pkt)
Definition: addr_mapper.cc:77
Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from the slave port.
Definition: addr_mapper.hh:121
virtual AddrRangeList getAddrRanges() const =0
bool recvTimingReq(PacketPtr pkt)
Definition: addr_mapper.cc:115
virtual Addr remapAddr(Addr addr) const =0
This function does the actual remapping of one address to another.
bool isSnooping() const
Definition: addr_mapper.cc:188
bool recvTimingResp(PacketPtr pkt)
Definition: addr_mapper.cc:143
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:245
bool recvTimingSnoopResp(PacketPtr pkt)
Definition: addr_mapper.cc:182
A virtual base opaque structure used to hold state associated with the packet (e.g., an MSHR), specific to a MemObject that sees the packet.
Definition: packet.hh:377
bool isSnooping() const
Determine if this master port is snooping or not.
Definition: addr_mapper.hh:141
AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: addr_mapper.hh:191
Addr remapAddr(Addr addr) const
This function does the actual remapping of one address to another.
Definition: addr_mapper.cc:236
MapperMasterPort(const std::string &_name, AddrMapper &_mapper)
Definition: addr_mapper.hh:110
An address mapper changes the packet addresses in going from the slave port side of the mapper to the...
Definition: addr_mapper.hh:56
void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the slave port.
Definition: addr_mapper.hh:131
Tick recvAtomic(PacketPtr pkt)
Definition: addr_mapper.cc:95
The MemObject class extends the ClockedObject with accessor functions to get its master and slave por...
Definition: mem_object.hh:60
A BaseMasterPort is a protocol-agnostic master port, responsible only for the structural connection t...
Definition: port.hh:115
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:243
AddrMapperSenderState(Addr _origAddr)
Construct a new sender state to remember the original address.
Definition: addr_mapper.hh:94
void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the master port.
Definition: addr_mapper.hh:171
virtual BaseMasterPort & getMasterPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a master port with a given name and index.
Definition: addr_mapper.cc:57
void recvFunctionalSnoop(PacketPtr pkt)
Definition: addr_mapper.cc:86
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:181
virtual BaseSlavePort & getSlavePort(const std::string &if_name, PortID idx=InvalidPortID)
Get a slave port with a given name and index.
Definition: addr_mapper.cc:67
bool recvTimingReq(PacketPtr pkt)
Receive a timing request from the master port.
Definition: addr_mapper.hh:181
Bitfield< 0 > p
std::vector< AddrRange > remappedRanges
This contains a list of ranges that addresses should be remapped to.
Definition: addr_mapper.hh:267

Generated on Fri Jun 9 2017 13:03:48 for gem5 by doxygen 1.8.6