SCons: Support building without an ISA
[gem5.git] / src / mem / cache / tags / fa_lru.hh
index 7855f845500467a8f465fcd3ef59cd0ab9c1422e..94ffeaa5810d3e7b06abd8ec07c4a5c84c00b5a6 100644 (file)
  * Declaration of a fully associative LRU tag store.
  */
 
-#ifndef __FA_LRU_HH__
-#define __FA_LRU_HH__
+#ifndef __MEM_CACHE_TAGS_FA_LRU_HH__
+#define __MEM_CACHE_TAGS_FA_LRU_HH__
 
 #include <list>
 
-#include "mem/cache/cache_blk.hh"
-#include "mem/packet.hh"
 #include "base/hashmap.hh"
-#include "mem/cache/tags/base_tags.hh"
+#include "mem/cache/blk.hh"
+#include "mem/cache/tags/base.hh"
+#include "mem/packet.hh"
 
 /**
  * A fully associative cache block.
@@ -78,22 +78,21 @@ class FALRU : public BaseTags
     typedef FALRUBlk BlkType;
     /** Typedef a list of pointers to the local block type. */
     typedef std::list<FALRUBlk*> BlkList;
+
   protected:
     /** The block size of the cache. */
-    const int blkSize;
+    const unsigned blkSize;
     /** The size of the cache. */
-    const int size;
-    /** The number of blocks in the cache. */
-    const int numBlks; // calculated internally
+    const unsigned size;
     /** The hit latency of the cache. */
-    const int hitLatency;
+    const unsigned hitLatency;
 
     /** Array of pointers to blocks at the cache size  boundaries. */
     FALRUBlk **cacheBoundaries;
     /** A mask for the FALRUBlk::inCache bits. */
     int cacheMask;
     /** The number of different size caches being tracked. */
-    int numCaches;
+    unsigned numCaches;
 
     /** The cache blocks. */
     FALRUBlk *blks;
@@ -139,11 +138,11 @@ class FALRU : public BaseTags
      */
 
     /** Hits in each cache size >= 128K. */
-    Stats::Vector<> hits;
+    Stats::Vector hits;
     /** Misses in each cache size >= 128K. */
-    Stats::Vector<> misses;
+    Stats::Vector misses;
     /** Total number of accesses. */
-    Stats::Scalar<> accesses;
+    Stats::Scalar accesses;
 
     /**
      * @}
@@ -156,7 +155,7 @@ public:
      * @param size The size of the cache.
      * @param hit_latency The hit latency of the cache.
      */
-    FALRU(int blkSize, int size, int hit_latency);
+    FALRU(unsigned blkSize, unsigned size, unsigned hit_latency);
 
     /**
      * Register the stats for this object.
@@ -165,40 +164,23 @@ public:
     void regStats(const std::string &name);
 
     /**
-     * Return true if the address is found in the cache.
-     * @param asid The address space ID.
-     * @param addr The address to look for.
-     * @return True if the address is in the cache.
-     */
-    bool probe(int asid, Addr addr) const;
-
-    /**
-     * Invalidate the cache block that contains the given addr.
-     * @param asid The address space ID.
-     * @param addr The address to invalidate.
+     * Invalidate a cache block.
+     * @param blk The block to invalidate.
      */
-    void invalidateBlk(int asid, Addr addr);
+    void invalidateBlk(BlkType *blk);
 
     /**
-     * Find the block in the cache and update the replacement data. Returns
-     * the access latency and the in cache flags as a side effect
+     * Access block and update replacement data.  May not succeed, in which case
+     * NULL pointer is returned.  This has all the implications of a cache
+     * access and should only be used as such.
+     * Returns the access latency and inCache flags as a side effect.
      * @param addr The address to look for.
      * @param asid The address space ID.
      * @param lat The latency of the access.
      * @param inCache The FALRUBlk::inCache flags.
      * @return Pointer to the cache block.
      */
-    FALRUBlk* findBlock(Addr addr, int asid, int &lat, int *inCache = 0);
-
-    /**
-     * Find the block in the cache and update the replacement data. Returns
-     * the access latency and the in cache flags as a side effect
-     * @param req The req whose block to find
-     * @param lat The latency of the access.
-     * @param inCache The FALRUBlk::inCache flags.
-     * @return Pointer to the cache block.
-     */
-    FALRUBlk* findBlock(Packet * &pkt, int &lat, int *inCache = 0);
+    FALRUBlk* accessBlock(Addr addr, int &lat, int context_src, int *inCache = 0);
 
     /**
      * Find the block in the cache, do not update the replacement data.
@@ -206,17 +188,17 @@ public:
      * @param asid The address space ID.
      * @return Pointer to the cache block.
      */
-    FALRUBlk* findBlock(Addr addr, int asid) const;
+    FALRUBlk* findBlock(Addr addr) const;
 
     /**
      * Find a replacement block for the address provided.
-     * @param req The request to a find a replacement candidate for.
+     * @param pkt The request to a find a replacement candidate for.
      * @param writebacks List for any writebacks to be performed.
-     * @param compress_blocks List of blocks to compress, for adaptive comp.
      * @return The block to place the replacement in.
      */
-    FALRUBlk* findReplacement(Packet * &pkt, PacketList* & writebacks,
-                              BlkList &compress_blocks);
+    FALRUBlk* findVictim(Addr addr, PacketList & writebacks);
+
+    void insertBlock(Addr addr, BlkType *blk, int context_src);
 
     /**
      * Return the hit latency of this cache.
@@ -231,7 +213,8 @@ public:
      * Return the block size of this cache.
      * @return The block size.
      */
-    int getBlockSize()
+    unsigned
+    getBlockSize() const
     {
         return blkSize;
     }
@@ -240,7 +223,8 @@ public:
      * Return the subblock size of this cache, always the block size.
      * @return The block size.
      */
-    int getSubBlockSize()
+    unsigned
+    getSubBlockSize() const
     {
         return blkSize;
     }
@@ -259,10 +243,9 @@ public:
      * Generate the tag from the addres. For fully associative this is just the
      * block address.
      * @param addr The address to get the tag from.
-     * @param blk ignored here
      * @return The tag.
      */
-    Addr extractTag(Addr addr, FALRUBlk *blk) const
+    Addr extractTag(Addr addr) const
     {
         return blkAlign(addr);
     }
@@ -299,48 +282,10 @@ public:
     }
 
     /**
-     * Read the data out of the internal storage of a cache block. FALRU
-     * currently doesn't support data storage.
-     * @param blk The cache block to read.
-     * @param data The buffer to read the data into.
-     * @return The data from the cache block.
+     *iterated through all blocks and clear all locks
+     *Needed to clear all lock tracking at once
      */
-    void readData(FALRUBlk *blk, uint8_t *data)
-    {
-    }
-
-    /**
-     * Write data into the internal storage of a cache block. FALRU
-     * currently doesn't support data storage.
-     * @param blk The cache block to be written.
-     * @param data The data to write.
-     * @param size The number of bytes to write.
-     * @param writebacks A list for any writebacks to be performed. May be
-     * needed when writing to a compressed block.
-     */
-    void writeData(FALRUBlk *blk, uint8_t *data, int size,
-                   PacketList* &writebacks)
-    {
-    }
-
-    /**
-     * Unimplemented. Perform a cache block copy from block aligned addresses.
-     * @param source The block aligned source address.
-     * @param dest The block aligned destination adddress.
-     * @param asid The address space ID.
-     * @param writebacks List for any generated writeback requests.
-     */
-    void doCopy(Addr source, Addr dest, int asid, PacketList* &writebacks)
-    {
-    }
-
-    /**
-     * Unimplemented.
-     */
-    void fixCopy(Packet * &pkt, PacketList* &writebacks)
-    {
-    }
-
+    virtual void clearLocks();
 };
 
-#endif
+#endif // __MEM_CACHE_TAGS_FA_LRU_HH__