DirectoryMemory.hh revision 10441
15647Sgblack@eecs.umich.edu/* 25647Sgblack@eecs.umich.edu * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 35647Sgblack@eecs.umich.edu * All rights reserved. 45647Sgblack@eecs.umich.edu * 55647Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 65647Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 75647Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 85647Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 95647Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 105647Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 115647Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 125647Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 135647Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 145647Sgblack@eecs.umich.edu * this software without specific prior written permission. 155647Sgblack@eecs.umich.edu * 165647Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175647Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185647Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195647Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205647Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215647Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225647Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235647Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245647Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255647Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265647Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275647Sgblack@eecs.umich.edu */ 285647Sgblack@eecs.umich.edu 295647Sgblack@eecs.umich.edu#ifndef __MEM_RUBY_STRUCTURES_DIRECTORYMEMORY_HH__ 305647Sgblack@eecs.umich.edu#define __MEM_RUBY_STRUCTURES_DIRECTORYMEMORY_HH__ 315647Sgblack@eecs.umich.edu 325647Sgblack@eecs.umich.edu#include <iostream> 335647Sgblack@eecs.umich.edu#include <string> 345647Sgblack@eecs.umich.edu 355647Sgblack@eecs.umich.edu#include "mem/protocol/DirectoryRequestType.hh" 365647Sgblack@eecs.umich.edu#include "mem/ruby/common/Address.hh" 375647Sgblack@eecs.umich.edu#include "mem/ruby/slicc_interface/AbstractEntry.hh" 385647Sgblack@eecs.umich.edu#include "mem/ruby/structures/MemoryVector.hh" 395647Sgblack@eecs.umich.edu#include "mem/ruby/structures/SparseMemory.hh" 405647Sgblack@eecs.umich.edu#include "params/RubyDirectoryMemory.hh" 415647Sgblack@eecs.umich.edu#include "sim/sim_object.hh" 425647Sgblack@eecs.umich.edu 435647Sgblack@eecs.umich.educlass DirectoryMemory : public SimObject 445647Sgblack@eecs.umich.edu{ 455647Sgblack@eecs.umich.edu public: 465647Sgblack@eecs.umich.edu typedef RubyDirectoryMemoryParams Params; 475647Sgblack@eecs.umich.edu DirectoryMemory(const Params *p); 485647Sgblack@eecs.umich.edu ~DirectoryMemory(); 495647Sgblack@eecs.umich.edu 505647Sgblack@eecs.umich.edu void init(); 515647Sgblack@eecs.umich.edu 525647Sgblack@eecs.umich.edu uint64 mapAddressToLocalIdx(PhysAddress address); 535647Sgblack@eecs.umich.edu static uint64 mapAddressToDirectoryVersion(PhysAddress address); 545647Sgblack@eecs.umich.edu 555647Sgblack@eecs.umich.edu bool isSparseImplementation() { return m_use_map; } 565647Sgblack@eecs.umich.edu uint64 getSize() { return m_size_bytes; } 575647Sgblack@eecs.umich.edu 585648Sgblack@eecs.umich.edu bool isPresent(PhysAddress address); 595647Sgblack@eecs.umich.edu AbstractEntry* lookup(PhysAddress address); 605654Sgblack@eecs.umich.edu AbstractEntry* allocate(const PhysAddress& address, 615647Sgblack@eecs.umich.edu AbstractEntry* new_entry); 625654Sgblack@eecs.umich.edu 636046Sgblack@eecs.umich.edu void invalidateBlock(PhysAddress address); 645647Sgblack@eecs.umich.edu 655648Sgblack@eecs.umich.edu void print(std::ostream& out) const; 665648Sgblack@eecs.umich.edu void regStats(); 675647Sgblack@eecs.umich.edu 685647Sgblack@eecs.umich.edu void recordRequestType(DirectoryRequestType requestType); 695647Sgblack@eecs.umich.edu 705647Sgblack@eecs.umich.edu private: 715647Sgblack@eecs.umich.edu // Private copy constructor and assignment operator 725647Sgblack@eecs.umich.edu DirectoryMemory(const DirectoryMemory& obj); 735647Sgblack@eecs.umich.edu DirectoryMemory& operator=(const DirectoryMemory& obj); 745647Sgblack@eecs.umich.edu 755647Sgblack@eecs.umich.edu private: 765648Sgblack@eecs.umich.edu const std::string m_name; 775647Sgblack@eecs.umich.edu AbstractEntry **m_entries; 785648Sgblack@eecs.umich.edu // int m_size; // # of memory module blocks this directory is 795648Sgblack@eecs.umich.edu // responsible for 805648Sgblack@eecs.umich.edu uint64 m_size_bytes; 815648Sgblack@eecs.umich.edu uint64 m_size_bits; 825648Sgblack@eecs.umich.edu uint64 m_num_entries; 835648Sgblack@eecs.umich.edu int m_version; 845648Sgblack@eecs.umich.edu 855648Sgblack@eecs.umich.edu static int m_num_directories; 865648Sgblack@eecs.umich.edu static int m_num_directories_bits; 875648Sgblack@eecs.umich.edu static uint64_t m_total_size_bytes; 885648Sgblack@eecs.umich.edu static int m_numa_high_bit; 895648Sgblack@eecs.umich.edu 905648Sgblack@eecs.umich.edu MemoryVector* m_ram; 915648Sgblack@eecs.umich.edu SparseMemory* m_sparseMemory; 925648Sgblack@eecs.umich.edu bool m_use_map; 935648Sgblack@eecs.umich.edu int m_map_levels; 945648Sgblack@eecs.umich.edu}; 955648Sgblack@eecs.umich.edu 965648Sgblack@eecs.umich.eduinline std::ostream& 975648Sgblack@eecs.umich.eduoperator<<(std::ostream& out, const DirectoryMemory& obj) 985648Sgblack@eecs.umich.edu{ 995648Sgblack@eecs.umich.edu obj.print(out); 1005648Sgblack@eecs.umich.edu out << std::flush; 1015648Sgblack@eecs.umich.edu return out; 1025648Sgblack@eecs.umich.edu} 1035648Sgblack@eecs.umich.edu 1045648Sgblack@eecs.umich.edu#endif // __MEM_RUBY_STRUCTURES_DIRECTORYMEMORY_HH__ 1055648Sgblack@eecs.umich.edu