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>
3311168Sandreas.hansson@arm.com#include <unordered_map>
347055SN/A
357039SN/A#include "mem/ruby/common/Address.hh"
3610301Snilay@cs.wisc.edu#include "mem/ruby/common/MachineID.hh"
377039SN/A#include "mem/ruby/common/NetDest.hh"
3814184Sgabeblack@google.com#include "mem/ruby/protocol/AccessType.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
6111025Snilay@cs.wisc.edu    void persistentRequestLock(Addr address, MachineID locker,
627039SN/A                               AccessType type);
6311025Snilay@cs.wisc.edu    void persistentRequestUnlock(Addr address, MachineID unlocker);
6411025Snilay@cs.wisc.edu    bool okToIssueStarving(Addr address, MachineID machID) const;
6511025Snilay@cs.wisc.edu    MachineID findSmallest(Addr address) const;
6611025Snilay@cs.wisc.edu    AccessType typeOfSmallest(Addr address) const;
6711025Snilay@cs.wisc.edu    void markEntries(Addr address);
6811025Snilay@cs.wisc.edu    bool isLocked(Addr addr) const;
6911025Snilay@cs.wisc.edu    int countStarvingForAddress(Addr addr) const;
7011025Snilay@cs.wisc.edu    int countReadStarvingForAddress(Addr 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)
8011168Sandreas.hansson@arm.com    typedef std::unordered_map<Addr, 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