gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DirectoryMemory.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3  * Copyright (c) 2017 Google Inc.
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  * Authors: Lena Olson
30  */
31 
33 
34 #include "base/intmath.hh"
35 #include "debug/RubyCache.hh"
36 #include "debug/RubyStats.hh"
39 #include "sim/system.hh"
40 
41 using namespace std;
42 
46 
48  : SimObject(p)
49 {
50  m_version = p->version;
51  // In X86, there is an IO gap in the 3-4GB range.
52  if (p->system->getArch() == Arch::X86ISA && p->size > 0xc0000000){
53  // We need to add 1GB to the size for the gap
54  m_size_bytes = p->size + 0x40000000;
55  }
56  else {
57  m_size_bytes = p->size;
58  }
60  m_num_entries = 0;
61  m_numa_high_bit = p->numa_high_bit;
62 }
63 
64 void
66 {
69  for (int i = 0; i < m_num_entries; i++)
70  m_entries[i] = NULL;
71 
74 
75  if (m_numa_high_bit == 0) {
77  }
78  assert(m_numa_high_bit != 0);
79 }
80 
82 {
83  // free up all the directory entries
84  for (uint64_t i = 0; i < m_num_entries; i++) {
85  if (m_entries[i] != NULL) {
86  delete m_entries[i];
87  }
88  }
89  delete [] m_entries;
90 }
91 
92 uint64_t
94 {
95  if (m_num_directories_bits == 0)
96  return 0;
97 
98  uint64_t ret = bitSelect(address,
101  return ret;
102 }
103 
104 bool
106 {
107  bool ret = (mapAddressToDirectoryVersion(address) == m_version);
108  return ret;
109 }
110 
111 uint64_t
113 {
114  uint64_t ret;
115  if (m_num_directories_bits > 0) {
116  ret = bitRemove(address, m_numa_high_bit - m_num_directories_bits + 1,
118  } else {
119  ret = address;
120  }
121 
122  return ret >> (RubySystem::getBlockSizeBits());
123 }
124 
127 {
128  assert(isPresent(address));
129  DPRINTF(RubyCache, "Looking up address: %#x\n", address);
130 
131  uint64_t idx = mapAddressToLocalIdx(address);
132  assert(idx < m_num_entries);
133  return m_entries[idx];
134 }
135 
138 {
139  assert(isPresent(address));
140  uint64_t idx;
141  DPRINTF(RubyCache, "Looking up address: %#x\n", address);
142 
143  idx = mapAddressToLocalIdx(address);
144  assert(idx < m_num_entries);
145  entry->changePermission(AccessPermission_Read_Only);
146  m_entries[idx] = entry;
147 
148  return entry;
149 }
150 
151 void
152 DirectoryMemory::print(ostream& out) const
153 {
154 }
155 
156 void
157 DirectoryMemory::recordRequestType(DirectoryRequestType requestType) {
158  DPRINTF(RubyStats, "Recorded statistic: %s\n",
159  DirectoryRequestType_to_string(requestType));
160 }
161 
163 RubyDirectoryMemoryParams::create()
164 {
165  return new DirectoryMemory(this);
166 }
#define DPRINTF(x,...)
Definition: trace.hh:212
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
AbstractEntry ** m_entries
static int m_num_directories_bits
Addr bitSelect(Addr addr, unsigned int small, unsigned int big)
Definition: Address.cc:34
static int m_numa_high_bit
Bitfield< 7 > i
Definition: miscregs.hh:1378
RubyDirectoryMemoryParams Params
Addr bitRemove(Addr addr, unsigned int small, unsigned int big)
Definition: Address.cc:49
static int m_num_directories
static uint32_t getMemorySizeBits()
Definition: RubySystem.hh:76
AbstractEntry * allocate(Addr address, AbstractEntry *new_entry)
int ceilLog2(const T &n)
Definition: intmath.hh:174
void recordRequestType(DirectoryRequestType requestType)
uint64_t mapAddressToLocalIdx(Addr address)
bool isPresent(Addr address)
static uint64_t mapAddressToDirectoryVersion(Addr address)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void print(std::ostream &out) const
uint64_t m_num_entries
int floorLog2(unsigned x)
Definition: intmath.hh:100
void changePermission(AccessPermission new_perm)
DirectoryMemory(const Params *p)
AbstractEntry * lookup(Addr address)
Bitfield< 0 > p
static uint32_t getBlockSizeBits()
Definition: RubySystem.hh:75
static uint32_t getBlockSizeBytes()
Definition: RubySystem.hh:74
Abstract superclass for simulation objects.
Definition: sim_object.hh:94

Generated on Fri Jun 9 2017 13:03:50 for gem5 by doxygen 1.8.6