mem-cache: Add match functions to QueueEntry
[gem5.git] / src / mem / abstract_mem.hh
index 6dbc79ea099aba67e6a27eab8c224469eb44739a..cf9ca74396ae14c7d6a3d40f00005c843f6cb8af 100644 (file)
  * AbstractMemory declaration
  */
 
-#ifndef __ABSTRACT_MEMORY_HH__
-#define __ABSTRACT_MEMORY_HH__
+#ifndef __MEM_ABSTRACT_MEMORY_HH__
+#define __MEM_ABSTRACT_MEMORY_HH__
 
+#include "mem/backdoor.hh"
 #include "mem/mem_object.hh"
 #include "params/AbstractMemory.hh"
 #include "sim/stats.hh"
@@ -79,13 +80,13 @@ class LockedAddr {
     static Addr mask(Addr paddr) { return (paddr & ~Addr_Mask); }
 
     // check for matching execution context
-    bool matchesContext(Request *req) const
+    bool matchesContext(const RequestPtr &req) const
     {
         return (contextId == req->contextId());
     }
 
-    LockedAddr(Request *req) : addr(mask(req->getPaddr())),
-                               contextId(req->contextId())
+    LockedAddr(const RequestPtr &req) : addr(mask(req->getPaddr())),
+                                        contextId(req->contextId())
     {}
 
     // constructor for unserialization use
@@ -110,11 +111,17 @@ class AbstractMemory : public MemObject
     // Pointer to host memory used to implement this memory
     uint8_t* pmemAddr;
 
+    // Backdoor to access this memory.
+    MemBackdoor backdoor;
+
     // Enable specific memories to be reported to the configuration table
-    bool confTableReported;
+    const bool confTableReported;
 
     // Should the memory appear in the global address map
-    bool inAddrMap;
+    const bool inAddrMap;
+
+    // Should KVM map this memory for the guest
+    const bool kvmMap;
 
     std::list<LockedAddr> lockedAddrList;
 
@@ -137,7 +144,7 @@ class AbstractMemory : public MemObject
     // this method must be called on *all* stores since even
     // non-conditional stores must clear any matching lock addresses.
     bool writeOK(PacketPtr pkt) {
-        Request *req = pkt->req;
+        const RequestPtr &req = pkt->req;
         if (lockedAddrList.empty()) {
             // no locked addrs: nothing to check, store_conditional fails
             bool isLLSC = pkt->isLLSC();
@@ -197,7 +204,7 @@ class AbstractMemory : public MemObject
     /**
      * Initialise this memory.
      */
-    void init();
+    void init() override;
 
     /**
      * See if this is a null memory that should never store data and
@@ -282,6 +289,14 @@ class AbstractMemory : public MemObject
      */
     bool isInAddrMap() const { return inAddrMap; }
 
+    /**
+     * When shadow memories are in use, KVM may want to make one or the other,
+     * but cannot map both into the guest address space.
+     *
+     * @return if this memory should be mapped into the KVM guest address space
+     */
+    bool isKvmMap() const { return kvmMap; }
+
     /**
      * Perform an untimed memory access and update all the state
      * (e.g. locked addresses) and statistics accordingly. The packet
@@ -304,8 +319,8 @@ class AbstractMemory : public MemObject
     /**
      * Register Statistics
      */
-    virtual void regStats();
+    void regStats() override;
 
 };
 
-#endif //__ABSTRACT_MEMORY_HH__
+#endif //__MEM_ABSTRACT_MEMORY_HH__