PersistentTable.hh revision 7055
16145SN/A/*
28683SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
310973Sdavid.hashe@amd.com * All rights reserved.
46145SN/A *
56145SN/A * Redistribution and use in source and binary forms, with or without
66145SN/A * modification, are permitted provided that the following conditions are
76145SN/A * met: redistributions of source code must retain the above copyright
86145SN/A * notice, this list of conditions and the following disclaimer;
96145SN/A * redistributions in binary form must reproduce the above copyright
106145SN/A * notice, this list of conditions and the following disclaimer in the
116145SN/A * documentation and/or other materials provided with the distribution;
126145SN/A * neither the name of the copyright holders nor the names of its
136145SN/A * contributors may be used to endorse or promote products derived from
146145SN/A * this software without specific prior written permission.
156145SN/A *
166145SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176145SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186145SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196145SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206145SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216145SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226145SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236145SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246145SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256145SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266145SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276145SN/A */
286145SN/A
296145SN/A#ifndef __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__
3010441Snilay@cs.wisc.edu#define __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__
3110441Snilay@cs.wisc.edu
326145SN/A#include <iostream>
337055SN/A
346145SN/A#include "mem/gems_common/Map.hh"
356145SN/A#include "mem/protocol/AccessType.hh"
367039SN/A#include "mem/ruby/common/Address.hh"
379104SN/A#include "mem/ruby/common/Global.hh"
3810301Snilay@cs.wisc.edu#include "mem/ruby/common/NetDest.hh"
399105SN/A#include "mem/ruby/system/MachineID.hh"
408174SN/A
417039SN/Aclass PersistentTableEntry
427039SN/A{
437039SN/A  public:
4410970Sdavid.hashe@amd.com    void print(std::ostream& out) const {}
4510301Snilay@cs.wisc.edu
4610301Snilay@cs.wisc.edu    NetDest m_starving;
477039SN/A    NetDest m_marked;
487039SN/A    NetDest m_request_to_write;
496145SN/A};
507039SN/A
517039SN/Aclass PersistentTable
527039SN/A{
536876SN/A  public:
547039SN/A    // Constructors
557039SN/A    PersistentTable();
566145SN/A
577039SN/A    // Destructor
586145SN/A    ~PersistentTable();
5911049Snilay@cs.wisc.edu
6011049Snilay@cs.wisc.edu    // Public Methods
6111049Snilay@cs.wisc.edu    void persistentRequestLock(const Address& address, MachineID locker,
6211049Snilay@cs.wisc.edu                               AccessType type);
6311049Snilay@cs.wisc.edu    void persistentRequestUnlock(const Address& address, MachineID unlocker);
6411049Snilay@cs.wisc.edu    bool okToIssueStarving(const Address& address, MachineID machID) const;
6511049Snilay@cs.wisc.edu    MachineID findSmallest(const Address& address) const;
6611049Snilay@cs.wisc.edu    AccessType typeOfSmallest(const Address& address) const;
6711049Snilay@cs.wisc.edu    void markEntries(const Address& address);
687039SN/A    bool isLocked(const Address& addr) const;
6911025Snilay@cs.wisc.edu    int countStarvingForAddress(const Address& addr) const;
706145SN/A    int countReadStarvingForAddress(const Address& addr) const;
717039SN/A
727039SN/A    static void printConfig(std::ostream& out) {}
737039SN/A
7411025Snilay@cs.wisc.edu    void print(std::ostream& out) const;
756145SN/A
767039SN/A  private:
7711025Snilay@cs.wisc.edu    // Private copy constructor and assignment operator
7810974Sdavid.hashe@amd.com    PersistentTable(const PersistentTable& obj);
7911025Snilay@cs.wisc.edu    PersistentTable& operator=(const PersistentTable& obj);
8010974Sdavid.hashe@amd.com
8110974Sdavid.hashe@amd.com    // Data Members (m_prefix)
8210974Sdavid.hashe@amd.com    Map<Address, PersistentTableEntry>* m_map_ptr;
8311025Snilay@cs.wisc.edu};
848193SN/A
8510974Sdavid.hashe@amd.cominline std::ostream&
868193SN/Aoperator<<(std::ostream& out, const PersistentTable& obj)
876145SN/A{
887039SN/A    obj.print(out);
8911025Snilay@cs.wisc.edu    out << std::flush;
906145SN/A    return out;
917039SN/A}
9211025Snilay@cs.wisc.edu
936145SN/Ainline std::ostream&
947039SN/Aoperator<<(std::ostream& out, const PersistentTableEntry& obj)
9511025Snilay@cs.wisc.edu{
9611025Snilay@cs.wisc.edu    obj.print(out);
976145SN/A    out << std::flush;
9810969Sdavid.hashe@amd.com    return out;
9910969Sdavid.hashe@amd.com}
10010969Sdavid.hashe@amd.com
10111061Snilay@cs.wisc.edu#endif // __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__
10211061Snilay@cs.wisc.edu