PersistentTable.hh revision 6791
1 2/* 3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer; 10 * redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution; 13 * neither the name of the copyright holders nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#ifndef PersistentTable_H 31#define PersistentTable_H 32 33#include "Global.h" 34#include "MachineID.h" 35#include "AccessType.h" 36 37class AbstractChip; 38 39template <class KEY_TYPE, class VALUE_TYPE> class Map; 40class Address; 41class PersistentTableEntry; 42 43class PersistentTable { 44public: 45 // Constructors 46 PersistentTable(AbstractChip* chip_ptr, int version); 47 48 // Destructor 49 ~PersistentTable(); 50 51 // Public Methods 52 void persistentRequestLock(const Address& address, MachineID locker, AccessType type); 53 void persistentRequestUnlock(const Address& address, MachineID unlocker); 54 bool okToIssueStarving(const Address& address) const; 55 MachineID findSmallest(const Address& address) const; 56 AccessType typeOfSmallest(const Address& address) const; 57 void markEntries(const Address& address); 58 bool isLocked(const Address& addr) const; 59 int countStarvingForAddress(const Address& addr) const; 60 int countReadStarvingForAddress(const Address& addr) const; 61 62 static void printConfig(ostream& out) {} 63 64 void print(ostream& out) const; 65private: 66 // Private Methods 67 68 // Private copy constructor and assignment operator 69 PersistentTable(const PersistentTable& obj); 70 PersistentTable& operator=(const PersistentTable& obj); 71 72 // Data Members (m_prefix) 73 Map<Address, PersistentTableEntry>* m_map_ptr; 74 AbstractChip* m_chip_ptr; 75 int m_version; 76}; 77 78// Output operator declaration 79ostream& operator<<(ostream& out, const PersistentTable& obj); 80 81// ******************* Definitions ******************* 82 83// Output operator definition 84extern inline 85ostream& operator<<(ostream& out, const PersistentTable& obj) 86{ 87 obj.print(out); 88 out << flush; 89 return out; 90} 91 92#endif //PersistentTable_H 93