PersistentTable.hh revision 6797
12810SN/A 22810SN/A/* 32810SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 42810SN/A * All rights reserved. 52810SN/A * 62810SN/A * Redistribution and use in source and binary forms, with or without 72810SN/A * modification, are permitted provided that the following conditions are 82810SN/A * met: redistributions of source code must retain the above copyright 92810SN/A * notice, this list of conditions and the following disclaimer; 102810SN/A * redistributions in binary form must reproduce the above copyright 112810SN/A * notice, this list of conditions and the following disclaimer in the 122810SN/A * documentation and/or other materials provided with the distribution; 132810SN/A * neither the name of the copyright holders nor the names of its 142810SN/A * contributors may be used to endorse or promote products derived from 152810SN/A * this software without specific prior written permission. 162810SN/A * 172810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282810SN/A */ 292810SN/A 302810SN/A#ifndef PersistentTable_H 312810SN/A#define PersistentTable_H 324626SN/A 332810SN/A#include "mem/ruby/common/Global.hh" 342810SN/A#include "mem/gems_common/Map.hh" 355338Sstever@gmail.com#include "mem/ruby/common/Address.hh" 362810SN/A#include "mem/ruby/system/MachineID.hh" 372810SN/A#include "mem/protocol/AccessType.hh" 382810SN/A#include "mem/ruby/common/NetDest.hh" 395314SN/A 405314SN/Aclass PersistentTableEntry { 415314SN/Apublic: 425314SN/A void print(ostream& out) const {} 434628SN/A 442810SN/A NetDest m_starving; 452810SN/A NetDest m_marked; 464626SN/A NetDest m_request_to_write; 474626SN/A}; 484626SN/A 494626SN/Aclass PersistentTable { 502810SN/Apublic: 512810SN/A // Constructors 522810SN/A PersistentTable(); 532810SN/A 542810SN/A // Destructor 552810SN/A ~PersistentTable(); 562810SN/A 572810SN/A // Public Methods 582810SN/A void persistentRequestLock(const Address& address, MachineID locker, AccessType type); 594626SN/A void persistentRequestUnlock(const Address& address, MachineID unlocker); 602991SN/A bool okToIssueStarving(const Address& address, MachineID machID) const; 612810SN/A MachineID findSmallest(const Address& address) const; 622810SN/A AccessType typeOfSmallest(const Address& address) const; 632810SN/A void markEntries(const Address& address); 642810SN/A bool isLocked(const Address& addr) const; 652810SN/A int countStarvingForAddress(const Address& addr) const; 662810SN/A int countReadStarvingForAddress(const Address& addr) const; 672810SN/A 682810SN/A static void printConfig(ostream& out) {} 692810SN/A 702810SN/A void print(ostream& out) const; 712810SN/Aprivate: 722810SN/A // Private Methods 732810SN/A 742991SN/A // Private copy constructor and assignment operator 752810SN/A PersistentTable(const PersistentTable& obj); 762810SN/A PersistentTable& operator=(const PersistentTable& obj); 772810SN/A 782810SN/A // Data Members (m_prefix) 792810SN/A Map<Address, PersistentTableEntry>* m_map_ptr; 802810SN/A}; 812810SN/A 822810SN/A// ******************* Definitions ******************* 832810SN/A 842810SN/A// Output operator definition 852810SN/Aextern inline 862810SN/Aostream& operator<<(ostream& out, const PersistentTable& obj) 872810SN/A{ 882810SN/A obj.print(out); 894920SN/A out << flush; 902810SN/A return out; 914920SN/A} 924920SN/A 934920SN/A// Output operator definition 944920SN/Aextern inline 955314SN/Aostream& operator<<(ostream& out, const PersistentTableEntry& obj) 964920SN/A{ 974920SN/A obj.print(out); 984920SN/A out << flush; 994920SN/A return out; 1004920SN/A} 1015314SN/A 1024920SN/A#endif //PersistentTable_H 1034920SN/A