PersistentTable.hh revision 14184
1955SN/A/* 2955SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 31762SN/A * All rights reserved. 4955SN/A * 5955SN/A * Redistribution and use in source and binary forms, with or without 6955SN/A * modification, are permitted provided that the following conditions are 7955SN/A * met: redistributions of source code must retain the above copyright 8955SN/A * notice, this list of conditions and the following disclaimer; 9955SN/A * redistributions in binary form must reproduce the above copyright 10955SN/A * notice, this list of conditions and the following disclaimer in the 11955SN/A * documentation and/or other materials provided with the distribution; 12955SN/A * neither the name of the copyright holders nor the names of its 13955SN/A * contributors may be used to endorse or promote products derived from 14955SN/A * this software without specific prior written permission. 15955SN/A * 16955SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17955SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18955SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19955SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20955SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21955SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22955SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23955SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24955SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25955SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26955SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27955SN/A */ 282665Ssaidi@eecs.umich.edu 294762Snate@binkert.org#ifndef __MEM_RUBY_STRUCTURES_PERSISTENTTABLE_HH__ 30955SN/A#define __MEM_RUBY_STRUCTURES_PERSISTENTTABLE_HH__ 315522Snate@binkert.org 326143Snate@binkert.org#include <iostream> 334762Snate@binkert.org#include <unordered_map> 345522Snate@binkert.org 35955SN/A#include "mem/ruby/common/Address.hh" 365522Snate@binkert.org#include "mem/ruby/common/MachineID.hh" 37955SN/A#include "mem/ruby/common/NetDest.hh" 385522Snate@binkert.org#include "mem/ruby/protocol/AccessType.hh" 394202Sbinkertn@umich.edu 405742Snate@binkert.orgclass PersistentTableEntry 41955SN/A{ 424381Sbinkertn@umich.edu public: 434381Sbinkertn@umich.edu PersistentTableEntry() {} 448334Snate@binkert.org void print(std::ostream& out) const {} 45955SN/A 46955SN/A NetDest m_starving; 474202Sbinkertn@umich.edu NetDest m_marked; 48955SN/A NetDest m_request_to_write; 494382Sbinkertn@umich.edu}; 504382Sbinkertn@umich.edu 514382Sbinkertn@umich.educlass PersistentTable 526654Snate@binkert.org{ 535517Snate@binkert.org public: 548614Sgblack@eecs.umich.edu // Constructors 557674Snate@binkert.org PersistentTable(); 566143Snate@binkert.org 576143Snate@binkert.org // Destructor 586143Snate@binkert.org ~PersistentTable(); 598233Snate@binkert.org 608233Snate@binkert.org // Public Methods 618233Snate@binkert.org void persistentRequestLock(Addr address, MachineID locker, 628233Snate@binkert.org AccessType type); 638233Snate@binkert.org void persistentRequestUnlock(Addr address, MachineID unlocker); 648334Snate@binkert.org bool okToIssueStarving(Addr address, MachineID machID) const; 658334Snate@binkert.org MachineID findSmallest(Addr address) const; 668233Snate@binkert.org AccessType typeOfSmallest(Addr address) const; 678233Snate@binkert.org void markEntries(Addr address); 688233Snate@binkert.org bool isLocked(Addr addr) const; 698233Snate@binkert.org int countStarvingForAddress(Addr addr) const; 708233Snate@binkert.org int countReadStarvingForAddress(Addr addr) const; 718233Snate@binkert.org 726143Snate@binkert.org void print(std::ostream& out) const; 738233Snate@binkert.org 748233Snate@binkert.org private: 758233Snate@binkert.org // Private copy constructor and assignment operator 766143Snate@binkert.org PersistentTable(const PersistentTable& obj); 776143Snate@binkert.org PersistentTable& operator=(const PersistentTable& obj); 786143Snate@binkert.org 796143Snate@binkert.org // Data Members (m_prefix) 808233Snate@binkert.org typedef std::unordered_map<Addr, PersistentTableEntry> AddressMap; 818233Snate@binkert.org AddressMap m_map; 828233Snate@binkert.org}; 836143Snate@binkert.org 848233Snate@binkert.orginline std::ostream& 858233Snate@binkert.orgoperator<<(std::ostream& out, const PersistentTable& obj) 868233Snate@binkert.org{ 878233Snate@binkert.org obj.print(out); 886143Snate@binkert.org out << std::flush; 896143Snate@binkert.org return out; 906143Snate@binkert.org} 914762Snate@binkert.org 926143Snate@binkert.orginline std::ostream& 938233Snate@binkert.orgoperator<<(std::ostream& out, const PersistentTableEntry& obj) 948233Snate@binkert.org{ 958233Snate@binkert.org obj.print(out); 968233Snate@binkert.org out << std::flush; 978233Snate@binkert.org return out; 986143Snate@binkert.org} 998233Snate@binkert.org 1008233Snate@binkert.org#endif // __MEM_RUBY_STRUCTURES_PERSISTENTTABLE_HH__ 1018233Snate@binkert.org