16145Snate@binkert.org/*
26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
36145Snate@binkert.org * All rights reserved.
46145Snate@binkert.org *
56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without
66145Snate@binkert.org * modification, are permitted provided that the following conditions are
76145Snate@binkert.org * met: redistributions of source code must retain the above copyright
86145Snate@binkert.org * notice, this list of conditions and the following disclaimer;
96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright
106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
116145Snate@binkert.org * documentation and/or other materials provided with the distribution;
126145Snate@binkert.org * neither the name of the copyright holders nor the names of its
136145Snate@binkert.org * contributors may be used to endorse or promote products derived from
146145Snate@binkert.org * this software without specific prior written permission.
156145Snate@binkert.org *
166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276145Snate@binkert.org */
286145Snate@binkert.org
296145Snate@binkert.org/*
307039Snate@binkert.org * Common base class for a machine node.
316145Snate@binkert.org */
326145Snate@binkert.org
337039Snate@binkert.org#ifndef __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCACHEENTRY_HH__
347039Snate@binkert.org#define __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCACHEENTRY_HH__
356145Snate@binkert.org
367055Snate@binkert.org#include <iostream>
377055Snate@binkert.org
3812334Sgabeblack@google.com#include "base/logging.hh"
397039Snate@binkert.org#include "mem/ruby/common/Address.hh"
4014184Sgabeblack@google.com#include "mem/ruby/protocol/AccessPermission.hh"
416882SBrad.Beckmann@amd.com#include "mem/ruby/slicc_interface/AbstractEntry.hh"
426145Snate@binkert.org
436285Snate@binkert.orgclass DataBlock;
446285Snate@binkert.org
457039Snate@binkert.orgclass AbstractCacheEntry : public AbstractEntry
467039Snate@binkert.org{
477039Snate@binkert.org  public:
487039Snate@binkert.org    AbstractCacheEntry();
497039Snate@binkert.org    virtual ~AbstractCacheEntry() = 0;
506145Snate@binkert.org
518086SBrad.Beckmann@amd.com    // Get/Set permission of the entry
527839Snilay@cs.wisc.edu    void changePermission(AccessPermission new_perm);
537839Snilay@cs.wisc.edu
5410522Snilay@cs.wisc.edu    // The methods below are those called by ruby runtime, add when it
5510522Snilay@cs.wisc.edu    // is absolutely necessary and should all be virtual function.
5610522Snilay@cs.wisc.edu    virtual DataBlock& getDataBlk()
5710522Snilay@cs.wisc.edu    { panic("getDataBlk() not implemented!"); }
5810522Snilay@cs.wisc.edu
5911308Santhony.gutierrez@amd.com    int validBlocks;
6011308Santhony.gutierrez@amd.com    virtual int& getNumValidBlocks()
6111308Santhony.gutierrez@amd.com    {
6211308Santhony.gutierrez@amd.com        return validBlocks;
6311308Santhony.gutierrez@amd.com    }
6411308Santhony.gutierrez@amd.com
6511059Snilay@cs.wisc.edu    // Functions for locking and unlocking the cache entry.  These are required
6611059Snilay@cs.wisc.edu    // for supporting atomic memory accesses.
6711059Snilay@cs.wisc.edu    void setLocked(int context);
6811059Snilay@cs.wisc.edu    void clearLocked();
6911059Snilay@cs.wisc.edu    bool isLocked(int context) const;
7010522Snilay@cs.wisc.edu
7111086Snilay@cs.wisc.edu    void setSetIndex(uint32_t s) { m_set_index = s; }
7211086Snilay@cs.wisc.edu    uint32_t getSetIndex() const { return m_set_index; }
7311086Snilay@cs.wisc.edu
7411086Snilay@cs.wisc.edu    void setWayIndex(uint32_t s) { m_way_index = s; }
7511086Snilay@cs.wisc.edu    uint32_t getWayIndex() const { return m_way_index; }
7611086Snilay@cs.wisc.edu
7711086Snilay@cs.wisc.edu    // Address of this block, required by CacheMemory
7811086Snilay@cs.wisc.edu    Addr m_Address;
7911086Snilay@cs.wisc.edu    // Holds info whether the address is locked.
8011086Snilay@cs.wisc.edu    // Required for implementing LL/SC operations.
8111086Snilay@cs.wisc.edu    int m_locked;
8211086Snilay@cs.wisc.edu
8311086Snilay@cs.wisc.edu  private:
8411086Snilay@cs.wisc.edu    // Set and way coordinates of the entry within the cache memory object.
8511086Snilay@cs.wisc.edu    uint32_t m_set_index;
8611086Snilay@cs.wisc.edu    uint32_t m_way_index;
876145Snate@binkert.org};
886145Snate@binkert.org
897055Snate@binkert.orginline std::ostream&
907055Snate@binkert.orgoperator<<(std::ostream& out, const AbstractCacheEntry& obj)
916145Snate@binkert.org{
927039Snate@binkert.org    obj.print(out);
937055Snate@binkert.org    out << std::flush;
947039Snate@binkert.org    return out;
956145Snate@binkert.org}
966145Snate@binkert.org
977039Snate@binkert.org#endif // __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCACHEENTRY_HH__
98