if (m_use_map) {
m_sparseMemory = new SparseMemory(m_map_levels);
+ g_system_ptr->registerSparseMemory(m_sparseMemory);
} else {
- m_entries = new Directory_Entry*[m_num_entries];
+ m_entries = new AbstractEntry*[m_num_entries];
for (int i = 0; i < m_num_entries; i++)
m_entries[i] = NULL;
m_ram = g_system_ptr->getMemoryVector();
return ret >> (RubySystem::getBlockSizeBits());
}
-Directory_Entry&
+AbstractEntry*
DirectoryMemory::lookup(PhysAddress address)
{
assert(isPresent(address));
- Directory_Entry* entry;
- uint64 idx;
DPRINTF(RubyCache, "Looking up address: %s\n", address);
if (m_use_map) {
- if (m_sparseMemory->exist(address)) {
- entry = m_sparseMemory->lookup(address);
- assert(entry != NULL);
- } else {
- // Note: SparseMemory internally creates a new Directory Entry
- m_sparseMemory->add(address);
- entry = m_sparseMemory->lookup(address);
- entry->changePermission(AccessPermission_Read_Write);
- }
+ return m_sparseMemory->lookup(address);
} else {
- idx = mapAddressToLocalIdx(address);
+ uint64_t idx = mapAddressToLocalIdx(address);
assert(idx < m_num_entries);
- entry = m_entries[idx];
-
- if (entry == NULL) {
- entry = new Directory_Entry();
- entry->getDataBlk().assign(m_ram->getBlockPtr(address));
- entry->changePermission(AccessPermission_Read_Only);
- m_entries[idx] = entry;
- }
+ return m_entries[idx];
}
-
- return *entry;
}
-#if 0
-Directory_Entry&
-DirectoryMemory::lookup(PhysAddress address)
+AbstractEntry*
+DirectoryMemory::allocate(const PhysAddress& address, AbstractEntry* entry)
{
assert(isPresent(address));
- Index index = address.memoryModuleIndex();
-
- if (index < 0 || index > m_size) {
- WARN_EXPR(address.getAddress());
- WARN_EXPR(index);
- WARN_EXPR(m_size);
- ERROR_MSG("Directory Memory Assertion: accessing memory out of range");
- }
- Directory_Entry* entry = m_entries[index];
+ uint64 idx;
+ DPRINTF(RubyCache, "Looking up address: %s\n", address);
- // allocate the directory entry on demand.
- if (entry == NULL) {
- entry = new Directory_Entry;
+ if (m_use_map) {
+ m_sparseMemory->add(address, entry);
+ entry->changePermission(AccessPermission_Read_Write);
+ } else {
+ idx = mapAddressToLocalIdx(address);
+ assert(idx < m_num_entries);
entry->getDataBlk().assign(m_ram->getBlockPtr(address));
-
- // store entry to the table
- m_entries[index] = entry;
+ entry->changePermission(AccessPermission_Read_Only);
+ m_entries[idx] = entry;
}
- return *entry;
+ return entry;
}
-#endif
void
DirectoryMemory::invalidateBlock(PhysAddress address)