AbstractCacheEntry.hh revision 11308:7d8836fd043d
112027Sjungma@eit.uni-kl.de/*
212027Sjungma@eit.uni-kl.de * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
312027Sjungma@eit.uni-kl.de * All rights reserved.
412027Sjungma@eit.uni-kl.de *
512027Sjungma@eit.uni-kl.de * Redistribution and use in source and binary forms, with or without
612027Sjungma@eit.uni-kl.de * modification, are permitted provided that the following conditions are
712027Sjungma@eit.uni-kl.de * met: redistributions of source code must retain the above copyright
812027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer;
912027Sjungma@eit.uni-kl.de * redistributions in binary form must reproduce the above copyright
1012027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer in the
1112027Sjungma@eit.uni-kl.de * documentation and/or other materials provided with the distribution;
1212027Sjungma@eit.uni-kl.de * neither the name of the copyright holders nor the names of its
1312027Sjungma@eit.uni-kl.de * contributors may be used to endorse or promote products derived from
1412027Sjungma@eit.uni-kl.de * this software without specific prior written permission.
1512027Sjungma@eit.uni-kl.de *
1612027Sjungma@eit.uni-kl.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712027Sjungma@eit.uni-kl.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812027Sjungma@eit.uni-kl.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912027Sjungma@eit.uni-kl.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012027Sjungma@eit.uni-kl.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112027Sjungma@eit.uni-kl.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212027Sjungma@eit.uni-kl.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312027Sjungma@eit.uni-kl.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412027Sjungma@eit.uni-kl.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512027Sjungma@eit.uni-kl.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612027Sjungma@eit.uni-kl.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712027Sjungma@eit.uni-kl.de */
2812027Sjungma@eit.uni-kl.de
2912027Sjungma@eit.uni-kl.de/*
3012027Sjungma@eit.uni-kl.de * Common base class for a machine node.
3112027Sjungma@eit.uni-kl.de */
3212027Sjungma@eit.uni-kl.de
3312027Sjungma@eit.uni-kl.de#ifndef __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCACHEENTRY_HH__
3412027Sjungma@eit.uni-kl.de#define __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCACHEENTRY_HH__
3512027Sjungma@eit.uni-kl.de
3612027Sjungma@eit.uni-kl.de#include <iostream>
3712027Sjungma@eit.uni-kl.de
3812027Sjungma@eit.uni-kl.de#include "base/misc.hh"
3912027Sjungma@eit.uni-kl.de#include "mem/protocol/AccessPermission.hh"
4012027Sjungma@eit.uni-kl.de#include "mem/ruby/common/Address.hh"
4112027Sjungma@eit.uni-kl.de#include "mem/ruby/slicc_interface/AbstractEntry.hh"
4212027Sjungma@eit.uni-kl.de
4312027Sjungma@eit.uni-kl.declass DataBlock;
4412027Sjungma@eit.uni-kl.de
4512027Sjungma@eit.uni-kl.declass AbstractCacheEntry : public AbstractEntry
4612027Sjungma@eit.uni-kl.de{
4712027Sjungma@eit.uni-kl.de  public:
4812027Sjungma@eit.uni-kl.de    AbstractCacheEntry();
4912027Sjungma@eit.uni-kl.de    virtual ~AbstractCacheEntry() = 0;
5012027Sjungma@eit.uni-kl.de
5112027Sjungma@eit.uni-kl.de    // Get/Set permission of the entry
5212027Sjungma@eit.uni-kl.de    void changePermission(AccessPermission new_perm);
5312027Sjungma@eit.uni-kl.de
5412027Sjungma@eit.uni-kl.de    // The methods below are those called by ruby runtime, add when it
5512027Sjungma@eit.uni-kl.de    // is absolutely necessary and should all be virtual function.
5612027Sjungma@eit.uni-kl.de    virtual DataBlock& getDataBlk()
5712027Sjungma@eit.uni-kl.de    { panic("getDataBlk() not implemented!"); }
5812027Sjungma@eit.uni-kl.de
5912027Sjungma@eit.uni-kl.de    int validBlocks;
6012027Sjungma@eit.uni-kl.de    virtual int& getNumValidBlocks()
6112027Sjungma@eit.uni-kl.de    {
6212027Sjungma@eit.uni-kl.de        return validBlocks;
6312027Sjungma@eit.uni-kl.de    }
6412027Sjungma@eit.uni-kl.de
6512027Sjungma@eit.uni-kl.de    // Functions for locking and unlocking the cache entry.  These are required
6612027Sjungma@eit.uni-kl.de    // for supporting atomic memory accesses.
6712027Sjungma@eit.uni-kl.de    void setLocked(int context);
6812027Sjungma@eit.uni-kl.de    void clearLocked();
6912027Sjungma@eit.uni-kl.de    bool isLocked(int context) const;
7012027Sjungma@eit.uni-kl.de
7112027Sjungma@eit.uni-kl.de    void setSetIndex(uint32_t s) { m_set_index = s; }
7212027Sjungma@eit.uni-kl.de    uint32_t getSetIndex() const { return m_set_index; }
7312027Sjungma@eit.uni-kl.de
7412027Sjungma@eit.uni-kl.de    void setWayIndex(uint32_t s) { m_way_index = s; }
7512027Sjungma@eit.uni-kl.de    uint32_t getWayIndex() const { return m_way_index; }
7612027Sjungma@eit.uni-kl.de
7712027Sjungma@eit.uni-kl.de    // Address of this block, required by CacheMemory
7812027Sjungma@eit.uni-kl.de    Addr m_Address;
7912027Sjungma@eit.uni-kl.de    // Holds info whether the address is locked.
8012027Sjungma@eit.uni-kl.de    // Required for implementing LL/SC operations.
8112027Sjungma@eit.uni-kl.de    int m_locked;
8212027Sjungma@eit.uni-kl.de
8312027Sjungma@eit.uni-kl.de  private:
8412027Sjungma@eit.uni-kl.de    // Set and way coordinates of the entry within the cache memory object.
8512027Sjungma@eit.uni-kl.de    uint32_t m_set_index;
8612027Sjungma@eit.uni-kl.de    uint32_t m_way_index;
8712027Sjungma@eit.uni-kl.de};
8812027Sjungma@eit.uni-kl.de
8912027Sjungma@eit.uni-kl.deinline std::ostream&
9012027Sjungma@eit.uni-kl.deoperator<<(std::ostream& out, const AbstractCacheEntry& obj)
9112027Sjungma@eit.uni-kl.de{
9212027Sjungma@eit.uni-kl.de    obj.print(out);
9312027Sjungma@eit.uni-kl.de    out << std::flush;
9412027Sjungma@eit.uni-kl.de    return out;
9512027Sjungma@eit.uni-kl.de}
9612027Sjungma@eit.uni-kl.de
9712027Sjungma@eit.uni-kl.de#endif // __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCACHEENTRY_HH__
9812027Sjungma@eit.uni-kl.de