PersistentTable.hh revision 10441
16791SN/A/*
26791SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
36791SN/A * All rights reserved.
46791SN/A *
56791SN/A * Redistribution and use in source and binary forms, with or without
66791SN/A * modification, are permitted provided that the following conditions are
76791SN/A * met: redistributions of source code must retain the above copyright
86791SN/A * notice, this list of conditions and the following disclaimer;
96791SN/A * redistributions in binary form must reproduce the above copyright
106791SN/A * notice, this list of conditions and the following disclaimer in the
116791SN/A * documentation and/or other materials provided with the distribution;
126791SN/A * neither the name of the copyright holders nor the names of its
136791SN/A * contributors may be used to endorse or promote products derived from
146791SN/A * this software without specific prior written permission.
156791SN/A *
166791SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176791SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186791SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196791SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206791SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216791SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226791SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236791SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246791SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256791SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266791SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276791SN/A */
286791SN/A
2910441Snilay@cs.wisc.edu#ifndef __MEM_RUBY_STRUCTURES_PERSISTENTTABLE_HH__
3010441Snilay@cs.wisc.edu#define __MEM_RUBY_STRUCTURES_PERSISTENTTABLE_HH__
316791SN/A
327055SN/A#include <iostream>
337055SN/A
347455SN/A#include "base/hashmap.hh"
357039SN/A#include "mem/protocol/AccessType.hh"
367039SN/A#include "mem/ruby/common/Address.hh"
3710301Snilay@cs.wisc.edu#include "mem/ruby/common/MachineID.hh"
387039SN/A#include "mem/ruby/common/NetDest.hh"
396791SN/A
407039SN/Aclass PersistentTableEntry
417039SN/A{
427039SN/A  public:
438607SN/A    PersistentTableEntry() {}
447055SN/A    void print(std::ostream& out) const {}
456791SN/A
467039SN/A    NetDest m_starving;
477039SN/A    NetDest m_marked;
487039SN/A    NetDest m_request_to_write;
496797SN/A};
506791SN/A
517039SN/Aclass PersistentTable
527039SN/A{
537039SN/A  public:
547039SN/A    // Constructors
557039SN/A    PersistentTable();
566791SN/A
577039SN/A    // Destructor
587039SN/A    ~PersistentTable();
597054SN/A
607039SN/A    // Public Methods
617039SN/A    void persistentRequestLock(const Address& address, MachineID locker,
627039SN/A                               AccessType type);
637039SN/A    void persistentRequestUnlock(const Address& address, MachineID unlocker);
647039SN/A    bool okToIssueStarving(const Address& address, MachineID machID) const;
657039SN/A    MachineID findSmallest(const Address& address) const;
667039SN/A    AccessType typeOfSmallest(const Address& address) const;
677039SN/A    void markEntries(const Address& address);
687039SN/A    bool isLocked(const Address& addr) const;
697039SN/A    int countStarvingForAddress(const Address& addr) const;
707039SN/A    int countReadStarvingForAddress(const Address& addr) const;
716791SN/A
727055SN/A    void print(std::ostream& out) const;
736791SN/A
747039SN/A  private:
757039SN/A    // Private copy constructor and assignment operator
767039SN/A    PersistentTable(const PersistentTable& obj);
777039SN/A    PersistentTable& operator=(const PersistentTable& obj);
786791SN/A
797039SN/A    // Data Members (m_prefix)
807455SN/A    typedef m5::hash_map<Address, PersistentTableEntry> AddressMap;
817455SN/A    AddressMap m_map;
826791SN/A};
836791SN/A
847055SN/Ainline std::ostream&
857055SN/Aoperator<<(std::ostream& out, const PersistentTable& obj)
866791SN/A{
877039SN/A    obj.print(out);
887055SN/A    out << std::flush;
897039SN/A    return out;
906791SN/A}
916791SN/A
927055SN/Ainline std::ostream&
937055SN/Aoperator<<(std::ostream& out, const PersistentTableEntry& obj)
946797SN/A{
957039SN/A    obj.print(out);
967055SN/A    out << std::flush;
977039SN/A    return out;
986797SN/A}
996797SN/A
10010441Snilay@cs.wisc.edu#endif // __MEM_RUBY_STRUCTURES_PERSISTENTTABLE_HH__
101