summaryrefslogtreecommitdiff
path: root/src/mem/abstract_mem.hh
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2012-10-15 08:12:32 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2012-10-15 08:12:32 -0400
commit9baa35ba802f2cfb9fb9ecdebf111f4cd793a428 (patch)
tree80f13a9816d592a550be1f7f582afe9dc6c2c781 /src/mem/abstract_mem.hh
parentd7ad8dc608dd6de4ff9c930de79edcdc3bdf8d40 (diff)
downloadgem5-9baa35ba802f2cfb9fb9ecdebf111f4cd793a428.tar.xz
Mem: Separate the host and guest views of memory backing store
This patch moves all the memory backing store operations from the independent memory controllers to the global physical memory. The main reason for this patch is to allow address striping in a future set of patches, but at this point it already provides some useful functionality in that it is now possible to change the number of memory controllers and their address mapping in combination with checkpointing. Thus, the host and guest view of the memory backing store are now completely separate. With this patch, the individual memory controllers are far simpler as all responsibility for serializing/unserializing is moved to the physical memory. Currently, the functionality is more or less moved from AbstractMemory to PhysicalMemory without any major changes. However, in a future patch the physical memory will also resolve any ranges that are interleaved and properly assign the backing store to the memory controllers, and keep the host memory as a single contigous chunk per address range. Functionality for future extensions which involve CPU virtualization also enable the host to get pointers to the backing store.
Diffstat (limited to 'src/mem/abstract_mem.hh')
-rw-r--r--src/mem/abstract_mem.hh104
1 files changed, 72 insertions, 32 deletions
diff --git a/src/mem/abstract_mem.hh b/src/mem/abstract_mem.hh
index 66d4a1f16..d6d33c8ee 100644
--- a/src/mem/abstract_mem.hh
+++ b/src/mem/abstract_mem.hh
@@ -57,6 +57,43 @@
class System;
/**
+ * Locked address class that represents a physical address and a
+ * context id.
+ */
+class LockedAddr {
+
+ private:
+
+ // on alpha, minimum LL/SC granularity is 16 bytes, so lower
+ // bits need to masked off.
+ static const Addr Addr_Mask = 0xf;
+
+ public:
+
+ // locked address
+ Addr addr;
+
+ // locking hw context
+ const int contextId;
+
+ static Addr mask(Addr paddr) { return (paddr & ~Addr_Mask); }
+
+ // check for matching execution context
+ bool matchesContext(Request *req) const
+ {
+ return (contextId == req->contextId());
+ }
+
+ LockedAddr(Request *req) : addr(mask(req->getPaddr())),
+ contextId(req->contextId())
+ {}
+
+ // constructor for unserialization use
+ LockedAddr(Addr _addr, int _cid) : addr(_addr), contextId(_cid)
+ {}
+};
+
+/**
* An abstract memory represents a contiguous block of physical
* memory, with an associated address range, and also provides basic
* functionality for reading and writing this memory without any
@@ -79,34 +116,6 @@ class AbstractMemory : public MemObject
// Should the memory appear in the global address map
bool inAddrMap;
- class LockedAddr {
-
- public:
- // on alpha, minimum LL/SC granularity is 16 bytes, so lower
- // bits need to masked off.
- static const Addr Addr_Mask = 0xf;
-
- static Addr mask(Addr paddr) { return (paddr & ~Addr_Mask); }
-
- Addr addr; // locked address
- int contextId; // locking hw context
-
- // check for matching execution context
- bool matchesContext(Request *req)
- {
- return (contextId == req->contextId());
- }
-
- LockedAddr(Request *req) : addr(mask(req->getPaddr())),
- contextId(req->contextId())
- {
- }
- // constructor for unserialization use
- LockedAddr(Addr _addr, int _cid) : addr(_addr), contextId(_cid)
- {
- }
- };
-
std::list<LockedAddr> lockedAddrList;
// helper function for checkLockedAddrs(): we really want to
@@ -183,7 +192,41 @@ class AbstractMemory : public MemObject
typedef AbstractMemoryParams Params;
AbstractMemory(const Params* p);
- virtual ~AbstractMemory();
+ virtual ~AbstractMemory() {}
+
+ /**
+ * See if this is a null memory that should never store data and
+ * always return zero.
+ *
+ * @return true if null
+ */
+ bool isNull() const { return params()->null; }
+
+ /**
+ * See if this memory should be initialized to zero or not.
+ *
+ * @return true if zero
+ */
+ bool initToZero() const { return params()->zero; }
+
+ /**
+ * Set the host memory backing store to be used by this memory
+ * controller.
+ *
+ * @param pmem_addr Pointer to a segment of host memory
+ */
+ void setBackingStore(uint8_t* pmem_addr);
+
+ /**
+ * Get the list of locked addresses to allow checkpointing.
+ */
+ const std::list<LockedAddr>& getLockedAddrList() const
+ { return lockedAddrList; }
+
+ /**
+ * Add a locked address to allow for checkpointing.
+ */
+ void addLockedAddr(LockedAddr addr) { lockedAddrList.push_back(addr); }
/** read the system pointer
* Implemented for completeness with the setter
@@ -265,9 +308,6 @@ class AbstractMemory : public MemObject
*/
virtual void regStats();
- virtual void serialize(std::ostream &os);
- virtual void unserialize(Checkpoint *cp, const std::string &section);
-
};
#endif //__ABSTRACT_MEMORY_HH__