PersistentTable.hh revision 11025:4872dbdea907
11917SN/A/*
21917SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
31917SN/A * All rights reserved.
41917SN/A *
51917SN/A * Redistribution and use in source and binary forms, with or without
61917SN/A * modification, are permitted provided that the following conditions are
71917SN/A * met: redistributions of source code must retain the above copyright
81917SN/A * notice, this list of conditions and the following disclaimer;
91917SN/A * redistributions in binary form must reproduce the above copyright
101917SN/A * notice, this list of conditions and the following disclaimer in the
111917SN/A * documentation and/or other materials provided with the distribution;
121917SN/A * neither the name of the copyright holders nor the names of its
131917SN/A * contributors may be used to endorse or promote products derived from
141917SN/A * this software without specific prior written permission.
151917SN/A *
161917SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
171917SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
181917SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
191917SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
201917SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
211917SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
221917SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231917SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241917SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251917SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261917SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu */
282665Ssaidi@eecs.umich.edu
291917SN/A#ifndef __MEM_RUBY_STRUCTURES_PERSISTENTTABLE_HH__
301917SN/A#define __MEM_RUBY_STRUCTURES_PERSISTENTTABLE_HH__
3111793Sbrandon.potter@amd.com
3211793Sbrandon.potter@amd.com#include <iostream>
331917SN/A
341917SN/A#include "base/hashmap.hh"
351917SN/A#include "mem/protocol/AccessType.hh"
361917SN/A#include "mem/ruby/common/Address.hh"
371917SN/A#include "mem/ruby/common/MachineID.hh"
381917SN/A#include "mem/ruby/common/NetDest.hh"
391917SN/A
402680Sktlim@umich.educlass PersistentTableEntry
418706Sandreas.hansson@arm.com{
422235SN/A  public:
431917SN/A    PersistentTableEntry() {}
441917SN/A    void print(std::ostream& out) const {}
451917SN/A
465569Snate@binkert.org    NetDest m_starving;
475569Snate@binkert.org    NetDest m_marked;
485569Snate@binkert.org    NetDest m_request_to_write;
495569Snate@binkert.org};
501917SN/A
515569Snate@binkert.orgclass PersistentTable
528852Sandreas.hansson@arm.com{
535569Snate@binkert.org  public:
541917SN/A    // Constructors
555569Snate@binkert.org    PersistentTable();
565569Snate@binkert.org
5713893Sgabeblack@google.com    // Destructor
582684Ssaidi@eecs.umich.edu    ~PersistentTable();
595569Snate@binkert.org
605569Snate@binkert.org    // Public Methods
6113893Sgabeblack@google.com    void persistentRequestLock(Addr address, MachineID locker,
622684Ssaidi@eecs.umich.edu                               AccessType type);
635569Snate@binkert.org    void persistentRequestUnlock(Addr address, MachineID unlocker);
645569Snate@binkert.org    bool okToIssueStarving(Addr address, MachineID machID) const;
6513893Sgabeblack@google.com    MachineID findSmallest(Addr address) const;
661917SN/A    AccessType typeOfSmallest(Addr address) const;
675569Snate@binkert.org    void markEntries(Addr address);
685569Snate@binkert.org    bool isLocked(Addr addr) const;
6913893Sgabeblack@google.com    int countStarvingForAddress(Addr addr) const;
701917SN/A    int countReadStarvingForAddress(Addr addr) const;
715569Snate@binkert.org
725569Snate@binkert.org    void print(std::ostream& out) const;
7313893Sgabeblack@google.com
745569Snate@binkert.org  private:
751917SN/A    // Private copy constructor and assignment operator
765569Snate@binkert.org    PersistentTable(const PersistentTable& obj);
775569Snate@binkert.org    PersistentTable& operator=(const PersistentTable& obj);
785569Snate@binkert.org
795569Snate@binkert.org    // Data Members (m_prefix)
805569Snate@binkert.org    typedef m5::hash_map<Addr, PersistentTableEntry> AddressMap;
815569Snate@binkert.org    AddressMap m_map;
821917SN/A};
835569Snate@binkert.org
845569Snate@binkert.orginline std::ostream&
858852Sandreas.hansson@arm.comoperator<<(std::ostream& out, const PersistentTable& obj)
8613893Sgabeblack@google.com{
875569Snate@binkert.org    obj.print(out);
885569Snate@binkert.org    out << std::flush;
895569Snate@binkert.org    return out;
905569Snate@binkert.org}
915569Snate@binkert.org
925569Snate@binkert.orginline std::ostream&
935569Snate@binkert.orgoperator<<(std::ostream& out, const PersistentTableEntry& obj)
945569Snate@binkert.org{
955569Snate@binkert.org    obj.print(out);
965569Snate@binkert.org    out << std::flush;
975569Snate@binkert.org    return out;
985569Snate@binkert.org}
995569Snate@binkert.org
1008852Sandreas.hansson@arm.com#endif // __MEM_RUBY_STRUCTURES_PERSISTENTTABLE_HH__
10113893Sgabeblack@google.com