DirectoryMemory.hh revision 10301
16145SN/A/* 26145SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36145SN/A * All rights reserved. 46145SN/A * 56145SN/A * Redistribution and use in source and binary forms, with or without 66145SN/A * modification, are permitted provided that the following conditions are 76145SN/A * met: redistributions of source code must retain the above copyright 86145SN/A * notice, this list of conditions and the following disclaimer; 96145SN/A * redistributions in binary form must reproduce the above copyright 106145SN/A * notice, this list of conditions and the following disclaimer in the 116145SN/A * documentation and/or other materials provided with the distribution; 126145SN/A * neither the name of the copyright holders nor the names of its 136145SN/A * contributors may be used to endorse or promote products derived from 146145SN/A * this software without specific prior written permission. 156145SN/A * 166145SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145SN/A */ 286145SN/A 297039SN/A#ifndef __MEM_RUBY_SYSTEM_DIRECTORYMEMORY_HH__ 307039SN/A#define __MEM_RUBY_SYSTEM_DIRECTORYMEMORY_HH__ 316145SN/A 327055SN/A#include <iostream> 337055SN/A#include <string> 347055SN/A 3510301Snilay@cs.wisc.edu#include "mem/protocol/DirectoryRequestType.hh" 367039SN/A#include "mem/ruby/common/Address.hh" 378644SN/A#include "mem/ruby/slicc_interface/AbstractEntry.hh" 3810301Snilay@cs.wisc.edu#include "mem/ruby/structures/MemoryVector.hh" 3910301Snilay@cs.wisc.edu#include "mem/ruby/structures/SparseMemory.hh" 407039SN/A#include "params/RubyDirectoryMemory.hh" 417039SN/A#include "sim/sim_object.hh" 426145SN/A 437039SN/Aclass DirectoryMemory : public SimObject 447039SN/A{ 457039SN/A public: 466876SN/A typedef RubyDirectoryMemoryParams Params; 476876SN/A DirectoryMemory(const Params *p); 487039SN/A ~DirectoryMemory(); 496145SN/A 507039SN/A void init(); 516145SN/A 527039SN/A uint64 mapAddressToLocalIdx(PhysAddress address); 537039SN/A static uint64 mapAddressToDirectoryVersion(PhysAddress address); 546285SN/A 557039SN/A bool isSparseImplementation() { return m_use_map; } 567039SN/A uint64 getSize() { return m_size_bytes; } 576285SN/A 587039SN/A bool isPresent(PhysAddress address); 598644SN/A AbstractEntry* lookup(PhysAddress address); 608644SN/A AbstractEntry* allocate(const PhysAddress& address, 618644SN/A AbstractEntry* new_entry); 626145SN/A 637039SN/A void invalidateBlock(PhysAddress address); 646285SN/A 657055SN/A void print(std::ostream& out) const; 669856SN/A void regStats(); 676145SN/A 689104SN/A void recordRequestType(DirectoryRequestType requestType); 699104SN/A 707039SN/A private: 717039SN/A // Private copy constructor and assignment operator 727039SN/A DirectoryMemory(const DirectoryMemory& obj); 737039SN/A DirectoryMemory& operator=(const DirectoryMemory& obj); 746145SN/A 757039SN/A private: 767055SN/A const std::string m_name; 778644SN/A AbstractEntry **m_entries; 787039SN/A // int m_size; // # of memory module blocks this directory is 797039SN/A // responsible for 807039SN/A uint64 m_size_bytes; 817039SN/A uint64 m_size_bits; 827039SN/A uint64 m_num_entries; 837039SN/A int m_version; 846145SN/A 857039SN/A static int m_num_directories; 867039SN/A static int m_num_directories_bits; 877039SN/A static uint64_t m_total_size_bytes; 887039SN/A static int m_numa_high_bit; 896285SN/A 907039SN/A MemoryVector* m_ram; 917039SN/A SparseMemory* m_sparseMemory; 927039SN/A bool m_use_map; 937039SN/A int m_map_levels; 946145SN/A}; 956145SN/A 967055SN/Ainline std::ostream& 977055SN/Aoperator<<(std::ostream& out, const DirectoryMemory& obj) 986145SN/A{ 997039SN/A obj.print(out); 1007055SN/A out << std::flush; 1017039SN/A return out; 1026145SN/A} 1036145SN/A 1047039SN/A#endif // __MEM_RUBY_SYSTEM_DIRECTORYMEMORY_HH__ 105