ruby: handle llsc accesses through CacheEntry, not CacheMemory
[gem5.git] / src / mem / abstract_mem.hh
index 66d4a1f16ce583b973e8f5fb774ed3fafa74fc43..6dbc79ea099aba67e6a27eab8c224469eb44739a 100644 (file)
 
 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 ContextID 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
@@ -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,39 @@ class AbstractMemory : public MemObject
     typedef AbstractMemoryParams Params;
 
     AbstractMemory(const Params* p);
-    virtual ~AbstractMemory();
+    virtual ~AbstractMemory() {}
+
+    /**
+     * Initialise this memory.
+     */
+    void init();
+
+    /**
+     * 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; }
+
+    /**
+     * 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
@@ -223,7 +264,7 @@ class AbstractMemory : public MemObject
      *
      * @return the start address of the memory
      */
-    Addr start() const { return range.start; }
+    Addr start() const { return range.start(); }
 
     /**
      *  Should this memory be passed to the kernel and part of the OS
@@ -265,9 +306,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__