Deleted Added
sdiff udiff text old ( 10314:94b6b28fc968 ) new ( 10520:7740e0d97d48 )
full compact
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 33 unchanged lines hidden (view full) ---

42
43DirectoryMemory::DirectoryMemory(const Params *p)
44 : SimObject(p)
45{
46 m_version = p->version;
47 m_size_bytes = p->size;
48 m_size_bits = floorLog2(m_size_bytes);
49 m_num_entries = 0;
50 m_numa_high_bit = p->numa_high_bit;
51}
52
53void
54DirectoryMemory::init()
55{
56 m_num_entries = m_size_bytes / RubySystem::getBlockSizeBytes();
57 m_entries = new AbstractEntry*[m_num_entries];
58 for (int i = 0; i < m_num_entries; i++)
59 m_entries[i] = NULL;
60 m_ram = g_system_ptr->getMemoryVector();
61
62 m_num_directories++;
63 m_num_directories_bits = ceilLog2(m_num_directories);
64 m_total_size_bytes += m_size_bytes;
65
66 if (m_numa_high_bit == 0) {
67 m_numa_high_bit = RubySystem::getMemorySizeBits() - 1;
68 }
69 assert(m_numa_high_bit != 0);
70}
71
72DirectoryMemory::~DirectoryMemory()
73{
74 // free up all the directory entries
75 for (uint64 i = 0; i < m_num_entries; i++) {
76 if (m_entries[i] != NULL) {
77 delete m_entries[i];
78 }
79 }
80 delete [] m_entries;
81}
82
83uint64
84DirectoryMemory::mapAddressToDirectoryVersion(PhysAddress address)
85{
86 if (m_num_directories_bits == 0)
87 return 0;
88

--- 24 unchanged lines hidden (view full) ---

113}
114
115AbstractEntry*
116DirectoryMemory::lookup(PhysAddress address)
117{
118 assert(isPresent(address));
119 DPRINTF(RubyCache, "Looking up address: %s\n", address);
120
121 uint64_t idx = mapAddressToLocalIdx(address);
122 assert(idx < m_num_entries);
123 return m_entries[idx];
124}
125
126AbstractEntry*
127DirectoryMemory::allocate(const PhysAddress& address, AbstractEntry* entry)
128{
129 assert(isPresent(address));
130 uint64 idx;
131 DPRINTF(RubyCache, "Looking up address: %s\n", address);
132
133 idx = mapAddressToLocalIdx(address);
134 assert(idx < m_num_entries);
135 entry->getDataBlk().assign(m_ram->getBlockPtr(address));
136 entry->changePermission(AccessPermission_Read_Only);
137 m_entries[idx] = entry;
138
139 return entry;
140}
141
142void
143DirectoryMemory::print(ostream& out) const
144{
145}
146
147void
148DirectoryMemory::recordRequestType(DirectoryRequestType requestType) {
149 DPRINTF(RubyStats, "Recorded statistic: %s\n",
150 DirectoryRequestType_to_string(requestType));
151}
152
153DirectoryMemory *
154RubyDirectoryMemoryParams::create()
155{
156 return new DirectoryMemory(this);
157}