AbstractCacheEntry.hh revision 12334
11689SN/A/* 213590Srekai.gonzalezalberquilla@arm.com * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 39920Syasuko.eckert@amd.com * All rights reserved. 47944SGiacomo.Gabrielli@arm.com * 57944SGiacomo.Gabrielli@arm.com * Redistribution and use in source and binary forms, with or without 67944SGiacomo.Gabrielli@arm.com * modification, are permitted provided that the following conditions are 77944SGiacomo.Gabrielli@arm.com * met: redistributions of source code must retain the above copyright 87944SGiacomo.Gabrielli@arm.com * notice, this list of conditions and the following disclaimer; 97944SGiacomo.Gabrielli@arm.com * redistributions in binary form must reproduce the above copyright 107944SGiacomo.Gabrielli@arm.com * notice, this list of conditions and the following disclaimer in the 117944SGiacomo.Gabrielli@arm.com * documentation and/or other materials provided with the distribution; 127944SGiacomo.Gabrielli@arm.com * neither the name of the copyright holders nor the names of its 137944SGiacomo.Gabrielli@arm.com * contributors may be used to endorse or promote products derived from 147944SGiacomo.Gabrielli@arm.com * this software without specific prior written permission. 152326SN/A * 161689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 271689SN/A */ 281689SN/A 291689SN/A/* 301689SN/A * Common base class for a machine node. 311689SN/A */ 321689SN/A 331689SN/A#ifndef __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCACHEENTRY_HH__ 341689SN/A#define __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCACHEENTRY_HH__ 351689SN/A 361689SN/A#include <iostream> 371689SN/A 381689SN/A#include "base/logging.hh" 391689SN/A#include "mem/protocol/AccessPermission.hh" 402665Ssaidi@eecs.umich.edu#include "mem/ruby/common/Address.hh" 412665Ssaidi@eecs.umich.edu#include "mem/ruby/slicc_interface/AbstractEntry.hh" 422831Sksewell@umich.edu 431689SN/Aclass DataBlock; 441689SN/A 459944Smatt.horsnell@ARM.comclass AbstractCacheEntry : public AbstractEntry 469944Smatt.horsnell@ARM.com{ 479944Smatt.horsnell@ARM.com public: 482064SN/A AbstractCacheEntry(); 491060SN/A virtual ~AbstractCacheEntry() = 0; 501060SN/A 5113449Sgabeblack@google.com // Get/Set permission of the entry 522292SN/A void changePermission(AccessPermission new_perm); 531717SN/A 548232Snate@binkert.org // The methods below are those called by ruby runtime, add when it 554762Snate@binkert.org // is absolutely necessary and should all be virtual function. 566221Snate@binkert.org virtual DataBlock& getDataBlk() 574762Snate@binkert.org { panic("getDataBlk() not implemented!"); } 581060SN/A 598737Skoansin.tan@gmail.com int validBlocks; 608737Skoansin.tan@gmail.com virtual int& getNumValidBlocks() 618737Skoansin.tan@gmail.com { 625529Snate@binkert.org return validBlocks; 631061SN/A } 6413429Srekai.gonzalezalberquilla@arm.com 655606Snate@binkert.org // Functions for locking and unlocking the cache entry. These are required 668581Ssteve.reinhardt@amd.com // for supporting atomic memory accesses. 678581Ssteve.reinhardt@amd.com void setLocked(int context); 681060SN/A void clearLocked(); 692292SN/A bool isLocked(int context) const; 702292SN/A 712292SN/A void setSetIndex(uint32_t s) { m_set_index = s; } 722292SN/A uint32_t getSetIndex() const { return m_set_index; } 732292SN/A 742292SN/A void setWayIndex(uint32_t s) { m_way_index = s; } 752326SN/A uint32_t getWayIndex() const { return m_way_index; } 762292SN/A 772292SN/A // Address of this block, required by CacheMemory 782292SN/A Addr m_Address; 792292SN/A // Holds info whether the address is locked. 802292SN/A // Required for implementing LL/SC operations. 812292SN/A int m_locked; 825336Shines@cs.fsu.edu 832292SN/A private: 844873Sstever@eecs.umich.edu // Set and way coordinates of the entry within the cache memory object. 852292SN/A uint32_t m_set_index; 862292SN/A uint32_t m_way_index; 872292SN/A}; 884329Sktlim@umich.edu 895529Snate@binkert.orginline std::ostream& 904329Sktlim@umich.eduoperator<<(std::ostream& out, const AbstractCacheEntry& obj) 914329Sktlim@umich.edu{ 924329Sktlim@umich.edu obj.print(out); 9313561Snikos.nikoleris@arm.com out << std::flush; 942292SN/A return out; 952292SN/A} 962292SN/A 972292SN/A#endif // __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCACHEENTRY_HH__ 982292SN/A