PersistentTable.hh revision 10301
18150SN/A/* 28150SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 38150SN/A * All rights reserved. 49988Snilay@cs.wisc.edu * 58825Snilay@cs.wisc.edu * Redistribution and use in source and binary forms, with or without 69988Snilay@cs.wisc.edu * modification, are permitted provided that the following conditions are 78150SN/A * met: redistributions of source code must retain the above copyright 88150SN/A * notice, this list of conditions and the following disclaimer; 98150SN/A * redistributions in binary form must reproduce the above copyright 108150SN/A * notice, this list of conditions and the following disclaimer in the 118150SN/A * documentation and/or other materials provided with the distribution; 128150SN/A * neither the name of the copyright holders nor the names of its 1310315Snilay@cs.wisc.edu * contributors may be used to endorse or promote products derived from 148891SAli.Saidi@ARM.com * this software without specific prior written permission. 1510315Snilay@cs.wisc.edu * 1610242Ssteve.reinhardt@amd.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1710038SAli.Saidi@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189885Sstever@gmail.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 199885Sstever@gmail.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209988Snilay@cs.wisc.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219055Ssaidi@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229348SAli.Saidi@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 239988Snilay@cs.wisc.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 248528SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 258528SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2610038SAli.Saidi@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2710038SAli.Saidi@ARM.com */ 2810038SAli.Saidi@ARM.com 2910038SAli.Saidi@ARM.com#ifndef __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__ 3010038SAli.Saidi@ARM.com#define __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__ 3110038SAli.Saidi@ARM.com 328150SN/A#include <iostream> 3310315Snilay@cs.wisc.edu 3410315Snilay@cs.wisc.edu#include "base/hashmap.hh" 358150SN/A#include "mem/protocol/AccessType.hh" 3610038SAli.Saidi@ARM.com#include "mem/ruby/common/Address.hh" 378150SN/A#include "mem/ruby/common/MachineID.hh" 388150SN/A#include "mem/ruby/common/NetDest.hh" 399449SAli.Saidi@ARM.com 409924Ssteve.reinhardt@amd.comclass PersistentTableEntry 419079SAli.Saidi@ARM.com{ 428660SN/A public: 439661SAli.Saidi@ARM.com PersistentTableEntry() {} 449661SAli.Saidi@ARM.com void print(std::ostream& out) const {} 4510038SAli.Saidi@ARM.com 4610315Snilay@cs.wisc.edu NetDest m_starving; 4710038SAli.Saidi@ARM.com NetDest m_marked; 488150SN/A NetDest m_request_to_write; 498150SN/A}; 508150SN/A 518150SN/Aclass PersistentTable 528150SN/A{ 538150SN/A public: 548150SN/A // Constructors 558150SN/A PersistentTable(); 568891SAli.Saidi@ARM.com 578150SN/A // Destructor 588150SN/A ~PersistentTable(); 598150SN/A 609885Sstever@gmail.com // Public Methods 618150SN/A void persistentRequestLock(const Address& address, MachineID locker, 629988Snilay@cs.wisc.edu AccessType type); 638891SAli.Saidi@ARM.com void persistentRequestUnlock(const Address& address, MachineID unlocker); 648721SN/A bool okToIssueStarving(const Address& address, MachineID machID) const; 658721SN/A MachineID findSmallest(const Address& address) const; 668891SAli.Saidi@ARM.com AccessType typeOfSmallest(const Address& address) const; 678891SAli.Saidi@ARM.com void markEntries(const Address& address); 688150SN/A bool isLocked(const Address& addr) const; 698528SN/A int countStarvingForAddress(const Address& addr) const; 708528SN/A int countReadStarvingForAddress(const Address& addr) const; 718528SN/A 728528SN/A void print(std::ostream& out) const; 738528SN/A 749988Snilay@cs.wisc.edu private: 758528SN/A // Private copy constructor and assignment operator 768528SN/A PersistentTable(const PersistentTable& obj); 778528SN/A PersistentTable& operator=(const PersistentTable& obj); 788528SN/A 798528SN/A // Data Members (m_prefix) 808528SN/A typedef m5::hash_map<Address, PersistentTableEntry> AddressMap; 819988Snilay@cs.wisc.edu AddressMap m_map; 828528SN/A}; 838528SN/A 848528SN/Ainline std::ostream& 858528SN/Aoperator<<(std::ostream& out, const PersistentTable& obj) 868528SN/A{ 878528SN/A obj.print(out); 889988Snilay@cs.wisc.edu out << std::flush; 8910315Snilay@cs.wisc.edu return out; 908528SN/A} 918528SN/A 929885Sstever@gmail.cominline std::ostream& 939885Sstever@gmail.comoperator<<(std::ostream& out, const PersistentTableEntry& obj) 949885Sstever@gmail.com{ 9510315Snilay@cs.wisc.edu obj.print(out); 969988Snilay@cs.wisc.edu out << std::flush; 9710315Snilay@cs.wisc.edu return out; 989885Sstever@gmail.com} 999885Sstever@gmail.com 1008150SN/A#endif // __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__ 1018150SN/A