gem5 v24.0.0.0
Loading...
Searching...
No Matches
abstract_mem.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012, 2019 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
46#ifndef __MEM_ABSTRACT_MEMORY_HH__
47#define __MEM_ABSTRACT_MEMORY_HH__
48
49#include "mem/backdoor.hh"
50#include "mem/port.hh"
51#include "params/AbstractMemory.hh"
52#include "sim/clocked_object.hh"
53#include "sim/stats.hh"
54
55namespace gem5
56{
57
58class System;
59
60namespace memory
61{
62
68{
69
70 private:
71
72 // on alpha, minimum LL/SC granularity is 16 bytes, so lower
73 // bits need to masked off.
74 static const Addr Addr_Mask = 0xf;
75
76 public:
77
78 // locked address
80
81 // locking hw context
83
84 static Addr mask(Addr paddr) { return (paddr & ~Addr_Mask); }
85
86 // check for matching execution context
87 bool matchesContext(const RequestPtr &req) const
88 {
89 assert(contextId != InvalidContextID);
90 assert(req->hasContextId());
91 return (contextId == req->contextId());
92 }
93
94 LockedAddr(const RequestPtr &req) : addr(mask(req->getPaddr())),
95 contextId(req->contextId())
96 {}
97
98 // constructor for unserialization use
99 LockedAddr(Addr _addr, int _cid) : addr(_addr), contextId(_cid)
100 {}
101};
102
111{
112 protected:
113
114 // Address range of this memory
116
117 // Pointer to host memory used to implement this memory
118 uint8_t* pmemAddr;
119
120 // Backdoor to access this memory.
122
123 // Enable specific memories to be reported to the configuration table
125
126 // Should the memory appear in the global address map
127 const bool inAddrMap;
128
129 // Should KVM map this memory for the guest
130 const bool kvmMap;
131
132 // Are writes allowed to this memory
133 const bool writeable;
134
135 // Should collect traffic statistics
136 const bool collectStats;
137
139
140 // helper function for checkLockedAddrs(): we really want to
141 // inline a quick check for an empty locked addr list (hopefully
142 // the common case), and do the full list search (if necessary) in
143 // this out-of-line function
145
146 // Record the address of a load-locked operation so that we can
147 // clear the execution context's lock flag if a matching store is
148 // performed
149 void trackLoadLocked(PacketPtr pkt);
150
151 // Compare a store address with any locked addresses so we can
152 // clear the lock flag appropriately. Return value set to 'false'
153 // if store operation should be suppressed (because it was a
154 // conditional store and the address was no longer locked by the
155 // requesting execution context), 'true' otherwise. Note that
156 // this method must be called on *all* stores since even
157 // non-conditional stores must clear any matching lock addresses.
158 bool
160 {
161 const RequestPtr &req = pkt->req;
162 if (!writeable)
163 return false;
164 if (lockedAddrList.empty()) {
165 // no locked addrs: nothing to check, store_conditional fails
166 bool isLLSC = pkt->isLLSC();
167 if (isLLSC) {
168 req->setExtraData(0);
169 }
170 return !isLLSC; // only do write if not an sc
171 } else {
172 // iterate over list...
173 return checkLockedAddrList(pkt);
174 }
175 }
176
182
212
213
214 private:
215
216 // Prevent copying
218
219 // Prevent assignment
221
222 public:
223
225
226 AbstractMemory(const Params &p);
227 virtual ~AbstractMemory() {}
228
229 void initState() override;
230
237 bool isNull() const { return params().null; }
238
245 void setBackingStore(uint8_t* pmem_addr);
246
247 void
249 {
250 if (lockedAddrList.empty() && backdoor.ptr())
251 bd_ptr = &backdoor;
252 }
253
259 {
260 return lockedAddrList;
261 }
262
266 void
272
276 System* system() const { return _system; }
277
284 void system(System *sys) { _system = sys; }
285
291 AddrRange getAddrRange() const;
292
300 inline uint8_t *
302 {
303 return pmemAddr + addr - range.start();
304 }
305
311 uint64_t size() const { return range.size(); }
312
318 Addr start() const { return range.start(); }
319
326 bool isConfReported() const { return confTableReported; }
327
334 bool isInAddrMap() const { return inAddrMap; }
335
342 bool isKvmMap() const { return kvmMap; }
343
351 void access(PacketPtr pkt);
352
361 void functionalAccess(PacketPtr pkt);
362};
363
364} // namespace memory
365} // namespace gem5
366
367#endif //__MEM_ABSTRACT_MEMORY_HH__
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition addr_range.hh:82
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
ClockedObjectParams Params
Parameters of ClockedObject.
uint8_t * ptr() const
Definition backdoor.hh:62
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
RequestPtr req
A pointer to the original request.
Definition packet.hh:377
bool isLLSC() const
Definition packet.hh:620
An abstract memory represents a contiguous block of physical memory, with an associated address range...
void access(PacketPtr pkt)
Perform an untimed memory access and update all the state (e.g.
uint64_t size() const
Get the memory size.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void trackLoadLocked(PacketPtr pkt)
void setBackingStore(uint8_t *pmem_addr)
Set the host memory backing store to be used by this memory controller.
bool isInAddrMap() const
Some memories are used as shadow memories or should for other reasons not be part of the global addre...
void system(System *sys)
Set the system pointer on this memory This can't be done via a python parameter because the system ne...
const std::list< LockedAddr > & getLockedAddrList() const
Get the list of locked addresses to allow checkpointing.
AbstractMemory & operator=(const AbstractMemory &)
AbstractMemory(const AbstractMemory &)
bool isNull() const
See if this is a null memory that should never store data and always return zero.
bool isKvmMap() const
When shadow memories are in use, KVM may want to make one or the other, but cannot map both into the ...
bool checkLockedAddrList(PacketPtr pkt)
uint8_t * toHostAddr(Addr addr) const
Transform a gem5 address space address into its physical counterpart in the host address space.
System * _system
Pointer to the System object.
void functionalAccess(PacketPtr pkt)
Perform an untimed memory read or write without changing anything but the memory itself.
void getBackdoor(MemBackdoorPtr &bd_ptr)
AddrRange getAddrRange() const
Get the address range.
Addr start() const
Get the start address.
std::list< LockedAddr > lockedAddrList
gem5::memory::AbstractMemory::MemStats stats
System * system() const
read the system pointer Implemented for completeness with the setter
bool isConfReported() const
Should this memory be passed to the kernel and part of the OS physical memory layout.
void addLockedAddr(LockedAddr addr)
Add a locked address to allow for checkpointing.
bool writeOK(PacketPtr pkt)
Locked address class that represents a physical address and a context id.
bool matchesContext(const RequestPtr &req) const
LockedAddr(Addr _addr, int _cid)
static const Addr Addr_Mask
LockedAddr(const RequestPtr &req)
static Addr mask(Addr paddr)
const ContextID contextId
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
A vector of scalar stats.
STL list class.
Definition stl.hh:51
ClockedObject declaration and implementation.
Addr start() const
Get the start address of the range.
Addr size() const
Get the size of the address range.
const Params & params() const
Port Object Declaration.
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
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
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
int ContextID
Globally unique thread context ID.
Definition types.hh:239
const ContextID InvalidContextID
Definition types.hh:240
statistics::Formula bwInstRead
Read bandwidth from this memory.
statistics::Vector bytesRead
Number of total bytes read from this memory.
statistics::Vector bytesInstRead
Number of instruction bytes read from this memory.
statistics::Formula bwTotal
Total bandwidth from this memory.
statistics::Vector numReads
Number of read requests.
void regStats() override
Callback to set stat parameters.
statistics::Vector numOther
Number of other requests.
statistics::Vector bytesWritten
Number of bytes written to this memory.
statistics::Vector numWrites
Number of write requests.
statistics::Formula bwRead
Read bandwidth from this memory.
statistics::Formula bwWrite
Write bandwidth from this memory.
Definition mem.h:38

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