abstract_mem.hh (9235:5aa4896ed55a) abstract_mem.hh (9293:df7c3f99ebca)
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

--- 43 unchanged lines hidden (view full) ---

52#include "mem/mem_object.hh"
53#include "params/AbstractMemory.hh"
54#include "sim/stats.hh"
55
56
57class System;
58
59/**
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

--- 43 unchanged lines hidden (view full) ---

52#include "mem/mem_object.hh"
53#include "params/AbstractMemory.hh"
54#include "sim/stats.hh"
55
56
57class System;
58
59/**
60 * Locked address class that represents a physical address and a
61 * context id.
62 */
63class 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
74 Addr addr;
75
76 // locking hw context
77 const int contextId;
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
96/**
60 * An abstract memory represents a contiguous block of physical
61 * memory, with an associated address range, and also provides basic
62 * functionality for reading and writing this memory without any
63 * timing information. It is a MemObject since any subclass must have
64 * at least one slave port.
65 */
66class AbstractMemory : public MemObject
67{

--- 6 unchanged lines hidden (view full) ---

74 uint8_t* pmemAddr;
75
76 // Enable specific memories to be reported to the configuration table
77 bool confTableReported;
78
79 // Should the memory appear in the global address map
80 bool inAddrMap;
81
97 * An abstract memory represents a contiguous block of physical
98 * memory, with an associated address range, and also provides basic
99 * functionality for reading and writing this memory without any
100 * timing information. It is a MemObject since any subclass must have
101 * at least one slave port.
102 */
103class AbstractMemory : public MemObject
104{

--- 6 unchanged lines hidden (view full) ---

111 uint8_t* pmemAddr;
112
113 // Enable specific memories to be reported to the configuration table
114 bool confTableReported;
115
116 // Should the memory appear in the global address map
117 bool inAddrMap;
118
82 class LockedAddr {
83
84 public:
85 // on alpha, minimum LL/SC granularity is 16 bytes, so lower
86 // bits need to masked off.
87 static const Addr Addr_Mask = 0xf;
88
89 static Addr mask(Addr paddr) { return (paddr & ~Addr_Mask); }
90
91 Addr addr; // locked address
92 int contextId; // locking hw context
93
94 // check for matching execution context
95 bool matchesContext(Request *req)
96 {
97 return (contextId == req->contextId());
98 }
99
100 LockedAddr(Request *req) : addr(mask(req->getPaddr())),
101 contextId(req->contextId())
102 {
103 }
104 // constructor for unserialization use
105 LockedAddr(Addr _addr, int _cid) : addr(_addr), contextId(_cid)
106 {
107 }
108 };
109
110 std::list<LockedAddr> lockedAddrList;
111
112 // helper function for checkLockedAddrs(): we really want to
113 // inline a quick check for an empty locked addr list (hopefully
114 // the common case), and do the full list search (if necessary) in
115 // this out-of-line function
116 bool checkLockedAddrList(PacketPtr pkt);
117

--- 60 unchanged lines hidden (view full) ---

178 // Prevent assignment
179 AbstractMemory& operator=(const AbstractMemory&);
180
181 public:
182
183 typedef AbstractMemoryParams Params;
184
185 AbstractMemory(const Params* p);
119 std::list<LockedAddr> lockedAddrList;
120
121 // helper function for checkLockedAddrs(): we really want to
122 // inline a quick check for an empty locked addr list (hopefully
123 // the common case), and do the full list search (if necessary) in
124 // this out-of-line function
125 bool checkLockedAddrList(PacketPtr pkt);
126

--- 60 unchanged lines hidden (view full) ---

187 // Prevent assignment
188 AbstractMemory& operator=(const AbstractMemory&);
189
190 public:
191
192 typedef AbstractMemoryParams Params;
193
194 AbstractMemory(const Params* p);
186 virtual ~AbstractMemory();
195 virtual ~AbstractMemory() {}
187
196
197 /**
198 * See if this is a null memory that should never store data and
199 * always return zero.
200 *
201 * @return true if null
202 */
203 bool isNull() const { return params()->null; }
204
205 /**
206 * See if this memory should be initialized to zero or not.
207 *
208 * @return true if zero
209 */
210 bool initToZero() const { return params()->zero; }
211
212 /**
213 * Set the host memory backing store to be used by this memory
214 * controller.
215 *
216 * @param pmem_addr Pointer to a segment of host memory
217 */
218 void setBackingStore(uint8_t* pmem_addr);
219
220 /**
221 * Get the list of locked addresses to allow checkpointing.
222 */
223 const std::list<LockedAddr>& getLockedAddrList() const
224 { return lockedAddrList; }
225
226 /**
227 * Add a locked address to allow for checkpointing.
228 */
229 void addLockedAddr(LockedAddr addr) { lockedAddrList.push_back(addr); }
230
188 /** read the system pointer
189 * Implemented for completeness with the setter
190 * @return pointer to the system object */
191 System* system() const { return _system; }
192
193 /** Set the system pointer on this memory
194 * This can't be done via a python parameter because the system needs
195 * pointers to all the memories and the reverse would create a cycle in the

--- 64 unchanged lines hidden (view full) ---

260 */
261 void functionalAccess(PacketPtr pkt);
262
263 /**
264 * Register Statistics
265 */
266 virtual void regStats();
267
231 /** read the system pointer
232 * Implemented for completeness with the setter
233 * @return pointer to the system object */
234 System* system() const { return _system; }
235
236 /** Set the system pointer on this memory
237 * This can't be done via a python parameter because the system needs
238 * pointers to all the memories and the reverse would create a cycle in the

--- 64 unchanged lines hidden (view full) ---

303 */
304 void functionalAccess(PacketPtr pkt);
305
306 /**
307 * Register Statistics
308 */
309 virtual void regStats();
310
268 virtual void serialize(std::ostream &os);
269 virtual void unserialize(Checkpoint *cp, const std::string &section);
270
271};
272
273#endif //__ABSTRACT_MEMORY_HH__
311};
312
313#endif //__ABSTRACT_MEMORY_HH__