PersistentTable.hh revision 6797
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef PersistentTable_H
31#define PersistentTable_H
32
33#include "mem/ruby/common/Global.hh"
34#include "mem/gems_common/Map.hh"
35#include "mem/ruby/common/Address.hh"
36#include "mem/ruby/system/MachineID.hh"
37#include "mem/protocol/AccessType.hh"
38#include "mem/ruby/common/NetDest.hh"
39
40class PersistentTableEntry {
41public:
42  void print(ostream& out) const {}
43
44  NetDest m_starving;
45  NetDest m_marked;
46  NetDest m_request_to_write;
47};
48
49class PersistentTable {
50public:
51  // Constructors
52  PersistentTable();
53
54  // Destructor
55  ~PersistentTable();
56
57  // Public Methods
58  void persistentRequestLock(const Address& address, MachineID locker, AccessType type);
59  void persistentRequestUnlock(const Address& address, MachineID unlocker);
60  bool okToIssueStarving(const Address& address, MachineID machID) const;
61  MachineID findSmallest(const Address& address) const;
62  AccessType typeOfSmallest(const Address& address) const;
63  void markEntries(const Address& address);
64  bool isLocked(const Address& addr) const;
65  int countStarvingForAddress(const Address& addr) const;
66  int countReadStarvingForAddress(const Address& addr) const;
67
68  static void printConfig(ostream& out) {}
69
70  void print(ostream& out) const;
71private:
72  // Private Methods
73
74  // Private copy constructor and assignment operator
75  PersistentTable(const PersistentTable& obj);
76  PersistentTable& operator=(const PersistentTable& obj);
77
78  // Data Members (m_prefix)
79  Map<Address, PersistentTableEntry>* m_map_ptr;
80};
81
82// ******************* Definitions *******************
83
84// Output operator definition
85extern inline
86ostream& operator<<(ostream& out, const PersistentTable& obj)
87{
88  obj.print(out);
89  out << flush;
90  return out;
91}
92
93// Output operator definition
94extern inline
95ostream& operator<<(ostream& out, const PersistentTableEntry& obj)
96{
97  obj.print(out);
98  out << flush;
99  return out;
100}
101
102#endif //PersistentTable_H
103