gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
abstract_mem.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  * Copyright (c) 2001-2005 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  * Authors: Ron Dreslinski
41  * Andreas Hansson
42  */
43 
49 #ifndef __ABSTRACT_MEMORY_HH__
50 #define __ABSTRACT_MEMORY_HH__
51 
52 #include "mem/mem_object.hh"
53 #include "params/AbstractMemory.hh"
54 #include "sim/stats.hh"
55 
56 
57 class System;
58 
63 class LockedAddr {
64 
65  private:
66 
67  // on alpha, minimum LL/SC granularity is 16 bytes, so lower
68  // bits need to masked off.
69  static const Addr Addr_Mask = 0xf;
70 
71  public:
72 
73  // locked address
75 
76  // locking hw context
78 
79  static Addr mask(Addr paddr) { return (paddr & ~Addr_Mask); }
80 
81  // check for matching execution context
82  bool matchesContext(Request *req) const
83  {
84  return (contextId == req->contextId());
85  }
86 
87  LockedAddr(Request *req) : addr(mask(req->getPaddr())),
88  contextId(req->contextId())
89  {}
90 
91  // constructor for unserialization use
92  LockedAddr(Addr _addr, int _cid) : addr(_addr), contextId(_cid)
93  {}
94 };
95 
103 class AbstractMemory : public MemObject
104 {
105  protected:
106 
107  // Address range of this memory
109 
110  // Pointer to host memory used to implement this memory
111  uint8_t* pmemAddr;
112 
113  // Enable specific memories to be reported to the configuration table
114  const bool confTableReported;
115 
116  // Should the memory appear in the global address map
117  const bool inAddrMap;
118 
119  // Should KVM map this memory for the guest
120  const bool kvmMap;
121 
123 
124  // helper function for checkLockedAddrs(): we really want to
125  // inline a quick check for an empty locked addr list (hopefully
126  // the common case), and do the full list search (if necessary) in
127  // this out-of-line function
128  bool checkLockedAddrList(PacketPtr pkt);
129 
130  // Record the address of a load-locked operation so that we can
131  // clear the execution context's lock flag if a matching store is
132  // performed
133  void trackLoadLocked(PacketPtr pkt);
134 
135  // Compare a store address with any locked addresses so we can
136  // clear the lock flag appropriately. Return value set to 'false'
137  // if store operation should be suppressed (because it was a
138  // conditional store and the address was no longer locked by the
139  // requesting execution context), 'true' otherwise. Note that
140  // this method must be called on *all* stores since even
141  // non-conditional stores must clear any matching lock addresses.
142  bool writeOK(PacketPtr pkt) {
143  Request *req = pkt->req;
144  if (lockedAddrList.empty()) {
145  // no locked addrs: nothing to check, store_conditional fails
146  bool isLLSC = pkt->isLLSC();
147  if (isLLSC) {
148  req->setExtraData(0);
149  }
150  return !isLLSC; // only do write if not an sc
151  } else {
152  // iterate over list...
153  return checkLockedAddrList(pkt);
154  }
155  }
156 
177 
183 
184 
185  private:
186 
187  // Prevent copying
189 
190  // Prevent assignment
192 
193  public:
194 
195  typedef AbstractMemoryParams Params;
196 
197  AbstractMemory(const Params* p);
198  virtual ~AbstractMemory() {}
199 
203  void init() override;
204 
211  bool isNull() const { return params()->null; }
212 
219  void setBackingStore(uint8_t* pmem_addr);
220 
225  { return lockedAddrList; }
226 
230  void addLockedAddr(LockedAddr addr) { lockedAddrList.push_back(addr); }
231 
235  System* system() const { return _system; }
236 
243  void system(System *sys) { _system = sys; }
244 
245  const Params *
246  params() const
247  {
248  return dynamic_cast<const Params *>(_params);
249  }
250 
256  AddrRange getAddrRange() const;
257 
263  uint64_t size() const { return range.size(); }
264 
270  Addr start() const { return range.start(); }
271 
278  bool isConfReported() const { return confTableReported; }
279 
286  bool isInAddrMap() const { return inAddrMap; }
287 
294  bool isKvmMap() const { return kvmMap; }
295 
303  void access(PacketPtr pkt);
304 
313  void functionalAccess(PacketPtr pkt);
314 
318  void regStats() override;
319 
320 };
321 
322 #endif //__ABSTRACT_MEMORY_HH__
void functionalAccess(PacketPtr pkt)
Perform an untimed memory read or write without changing anything but the memory itself.
bool isLLSC() const
Definition: packet.hh:527
bool isNull() const
See if this is a null memory that should never store data and always return zero. ...
const bool kvmMap
Addr start() const
Get the start address of the range.
Definition: addr_range.hh:227
virtual ~AbstractMemory()
ContextID contextId() const
Accessor function for context ID.
Definition: request.hh:694
void addLockedAddr(LockedAddr addr)
Add a locked address to allow for checkpointing.
const Params * params() const
void setExtraData(uint64_t extraData)
Accessor function for store conditional return value.
Definition: request.hh:680
bool matchesContext(Request *req) const
Definition: abstract_mem.hh:82
LockedAddr(Addr _addr, int _cid)
Definition: abstract_mem.hh:92
Locked address class that represents a physical address and a context id.
Definition: abstract_mem.hh:63
bool writeOK(PacketPtr pkt)
ip6_addr_t addr
Definition: inet.hh:335
MemObject declaration.
AbstractMemory(const AbstractMemory &)
Stats::Formula bwRead
Read bandwidth from this memory.
Stats::Vector numWrites
Number of write requests.
Definition: system.hh:83
A vector of scalar stats.
Definition: statistics.hh:2499
bool isConfReported() const
Should this memory be passed to the kernel and part of the OS physical memory layout.
bool checkLockedAddrList(PacketPtr pkt)
const ContextID contextId
Definition: abstract_mem.hh:77
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:72
Stats::Vector bytesWritten
Number of bytes written to this memory.
static Addr mask(Addr paddr)
Definition: abstract_mem.hh:79
AbstractMemoryParams Params
const bool inAddrMap
System * system() const
read the system pointer Implemented for completeness with the setter
uint8_t * pmemAddr
AddrRange getAddrRange() const
Get the address range.
void access(PacketPtr pkt)
Perform an untimed memory access and update all the state (e.g.
Stats::Vector bytesRead
Number of total bytes read from this memory.
Stats::Formula bwTotal
Total bandwidth from this memory.
const RequestPtr req
A pointer to the original request.
Definition: packet.hh:304
bool isKvmMap() const
When shadow memories are in use, KVM may want to make one or the other, but cannot map both into the ...
std::list< LockedAddr > lockedAddrList
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
uint64_t size() const
Get the memory size.
void trackLoadLocked(PacketPtr pkt)
Stats::Vector bytesInstRead
Number of instruction bytes read from this memory.
Addr start() const
Get the start address.
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2895
Stats::Vector numOther
Number of other requests.
AddrRange range
void regStats() override
Register Statistics.
Definition: abstract_mem.cc:81
void init() override
Initialise this memory.
Definition: abstract_mem.cc:66
void setBackingStore(uint8_t *pmem_addr)
Set the host memory backing store to be used by this memory controller.
Definition: abstract_mem.cc:75
The MemObject class extends the ClockedObject with accessor functions to get its master and slave por...
Definition: mem_object.hh:60
System * _system
Pointor to the System object.
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:107
LockedAddr(Request *req)
Definition: abstract_mem.hh:87
An abstract memory represents a contiguous block of physical memory, with an associated address range...
bool isInAddrMap() const
Some memories are used as shadow memories or should for other reasons not be part of the global addre...
AbstractMemory & operator=(const AbstractMemory &)
void system(System *sys)
Set the system pointer on this memory This can't be done via a python parameter because the system ne...
Bitfield< 0 > p
Stats::Formula bwWrite
Write bandwidth from this memory.
const std::list< LockedAddr > & getLockedAddrList() const
Get the list of locked addresses to allow checkpointing.
Stats::Formula bwInstRead
Read bandwidth from this memory.
Addr size() const
Get the size of the address range.
Definition: addr_range.hh:214
int ContextID
Globally unique thread context ID.
Definition: types.hh:175
const bool confTableReported
Stats::Vector numReads
Number of read requests.
static const Addr Addr_Mask
Definition: abstract_mem.hh:69

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