PersistentTable.hh revision 8607
112047Schristian.menard@tu-dresden.de/* 212047Schristian.menard@tu-dresden.de * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 312047Schristian.menard@tu-dresden.de * All rights reserved. 412047Schristian.menard@tu-dresden.de * 512047Schristian.menard@tu-dresden.de * Redistribution and use in source and binary forms, with or without 612047Schristian.menard@tu-dresden.de * modification, are permitted provided that the following conditions are 712047Schristian.menard@tu-dresden.de * met: redistributions of source code must retain the above copyright 812047Schristian.menard@tu-dresden.de * notice, this list of conditions and the following disclaimer; 912047Schristian.menard@tu-dresden.de * redistributions in binary form must reproduce the above copyright 1012047Schristian.menard@tu-dresden.de * notice, this list of conditions and the following disclaimer in the 1112047Schristian.menard@tu-dresden.de * documentation and/or other materials provided with the distribution; 1212047Schristian.menard@tu-dresden.de * neither the name of the copyright holders nor the names of its 1312047Schristian.menard@tu-dresden.de * contributors may be used to endorse or promote products derived from 1412047Schristian.menard@tu-dresden.de * this software without specific prior written permission. 1512047Schristian.menard@tu-dresden.de * 1612047Schristian.menard@tu-dresden.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712047Schristian.menard@tu-dresden.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812047Schristian.menard@tu-dresden.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912047Schristian.menard@tu-dresden.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012047Schristian.menard@tu-dresden.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112047Schristian.menard@tu-dresden.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212047Schristian.menard@tu-dresden.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312047Schristian.menard@tu-dresden.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412047Schristian.menard@tu-dresden.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512047Schristian.menard@tu-dresden.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612047Schristian.menard@tu-dresden.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712047Schristian.menard@tu-dresden.de */ 2812047Schristian.menard@tu-dresden.de 2912047Schristian.menard@tu-dresden.de#ifndef __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__ 3012047Schristian.menard@tu-dresden.de#define __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__ 3112047Schristian.menard@tu-dresden.de 3212047Schristian.menard@tu-dresden.de#include <iostream> 3312047Schristian.menard@tu-dresden.de 3412047Schristian.menard@tu-dresden.de#include "base/hashmap.hh" 3512047Schristian.menard@tu-dresden.de#include "mem/protocol/AccessType.hh" 3612047Schristian.menard@tu-dresden.de#include "mem/ruby/common/Address.hh" 3712047Schristian.menard@tu-dresden.de#include "mem/ruby/common/Global.hh" 3812047Schristian.menard@tu-dresden.de#include "mem/ruby/common/NetDest.hh" 3912047Schristian.menard@tu-dresden.de#include "mem/ruby/system/MachineID.hh" 4012047Schristian.menard@tu-dresden.de 4112047Schristian.menard@tu-dresden.declass PersistentTableEntry 4212047Schristian.menard@tu-dresden.de{ 4312047Schristian.menard@tu-dresden.de public: 4412047Schristian.menard@tu-dresden.de PersistentTableEntry() {} 4512047Schristian.menard@tu-dresden.de void print(std::ostream& out) const {} 4612047Schristian.menard@tu-dresden.de 4712047Schristian.menard@tu-dresden.de NetDest m_starving; 4812047Schristian.menard@tu-dresden.de NetDest m_marked; 4912047Schristian.menard@tu-dresden.de NetDest m_request_to_write; 5012047Schristian.menard@tu-dresden.de}; 5112047Schristian.menard@tu-dresden.de 5212047Schristian.menard@tu-dresden.declass PersistentTable 5312047Schristian.menard@tu-dresden.de{ 5412047Schristian.menard@tu-dresden.de public: 5512047Schristian.menard@tu-dresden.de // Constructors 5612047Schristian.menard@tu-dresden.de PersistentTable(); 5712047Schristian.menard@tu-dresden.de 5812047Schristian.menard@tu-dresden.de // Destructor 5912047Schristian.menard@tu-dresden.de ~PersistentTable(); 6012047Schristian.menard@tu-dresden.de 6112047Schristian.menard@tu-dresden.de // Public Methods 6212047Schristian.menard@tu-dresden.de void persistentRequestLock(const Address& address, MachineID locker, 6312047Schristian.menard@tu-dresden.de AccessType type); 6412047Schristian.menard@tu-dresden.de void persistentRequestUnlock(const Address& address, MachineID unlocker); 6512047Schristian.menard@tu-dresden.de bool okToIssueStarving(const Address& address, MachineID machID) const; 6612047Schristian.menard@tu-dresden.de MachineID findSmallest(const Address& address) const; 6712047Schristian.menard@tu-dresden.de AccessType typeOfSmallest(const Address& address) const; 6812047Schristian.menard@tu-dresden.de void markEntries(const Address& address); 6912047Schristian.menard@tu-dresden.de bool isLocked(const Address& addr) const; 7012047Schristian.menard@tu-dresden.de int countStarvingForAddress(const Address& addr) const; 7112047Schristian.menard@tu-dresden.de int countReadStarvingForAddress(const Address& addr) const; 7212047Schristian.menard@tu-dresden.de 7312047Schristian.menard@tu-dresden.de static void printConfig(std::ostream& out) {} 7412047Schristian.menard@tu-dresden.de 7512047Schristian.menard@tu-dresden.de void print(std::ostream& out) const; 7612047Schristian.menard@tu-dresden.de 7712047Schristian.menard@tu-dresden.de private: 7812047Schristian.menard@tu-dresden.de // Private copy constructor and assignment operator 7912047Schristian.menard@tu-dresden.de PersistentTable(const PersistentTable& obj); 8012047Schristian.menard@tu-dresden.de PersistentTable& operator=(const PersistentTable& obj); 8112047Schristian.menard@tu-dresden.de 8212047Schristian.menard@tu-dresden.de // Data Members (m_prefix) 8312047Schristian.menard@tu-dresden.de typedef m5::hash_map<Address, PersistentTableEntry> AddressMap; 8412047Schristian.menard@tu-dresden.de AddressMap m_map; 8512047Schristian.menard@tu-dresden.de}; 8612047Schristian.menard@tu-dresden.de 8712047Schristian.menard@tu-dresden.deinline std::ostream& 8812047Schristian.menard@tu-dresden.deoperator<<(std::ostream& out, const PersistentTable& obj) 8912047Schristian.menard@tu-dresden.de{ 9012047Schristian.menard@tu-dresden.de obj.print(out); 9112047Schristian.menard@tu-dresden.de out << std::flush; 9212047Schristian.menard@tu-dresden.de return out; 9312047Schristian.menard@tu-dresden.de} 9412047Schristian.menard@tu-dresden.de 9512047Schristian.menard@tu-dresden.deinline std::ostream& 9612047Schristian.menard@tu-dresden.deoperator<<(std::ostream& out, const PersistentTableEntry& obj) 9712047Schristian.menard@tu-dresden.de{ 9812047Schristian.menard@tu-dresden.de obj.print(out); 9912047Schristian.menard@tu-dresden.de out << std::flush; 10012047Schristian.menard@tu-dresden.de return out; 10112047Schristian.menard@tu-dresden.de} 10212047Schristian.menard@tu-dresden.de 10312047Schristian.menard@tu-dresden.de#endif // __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__ 10412047Schristian.menard@tu-dresden.de