tlb.hh revision 2650
12SN/A/* 21762SN/A * Copyright (c) 2001-2005 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272SN/A */ 282SN/A 292SN/A#ifndef __ALPHA_MEMORY_HH__ 302SN/A#define __ALPHA_MEMORY_HH__ 312SN/A 322SN/A#include <map> 332SN/A 342432SN/A#include "arch/alpha/ev5.hh" 351147SN/A#include "arch/alpha/isa_traits.hh" 362090SN/A#include "arch/alpha/faults.hh" 371147SN/A#include "base/statistics.hh" 382517SN/A#include "mem/request.hh" 3956SN/A#include "sim/sim_object.hh" 402SN/A 412SN/Aclass ExecContext; 422SN/A 43674SN/Aclass AlphaTLB : public SimObject 442SN/A{ 452SN/A protected: 462SN/A typedef std::multimap<Addr, int> PageTable; 472SN/A PageTable lookupTable; // Quick lookup into page table 482SN/A 492SN/A AlphaISA::PTE *table; // the Page Table 502SN/A int size; // TLB Size 512SN/A int nlu; // not last used entry (for replacement) 522SN/A 532SN/A void nextnlu() { if (++nlu >= size) nlu = 0; } 542SN/A AlphaISA::PTE *lookup(Addr vpn, uint8_t asn) const; 552SN/A 562SN/A public: 57674SN/A AlphaTLB(const std::string &name, int size); 58674SN/A virtual ~AlphaTLB(); 592SN/A 602SN/A int getsize() const { return size; } 612SN/A 62555SN/A AlphaISA::PTE &index(bool advance = true); 632SN/A void insert(Addr vaddr, AlphaISA::PTE &pte); 642SN/A 652SN/A void flushAll(); 662SN/A void flushProcesses(); 672SN/A void flushAddr(Addr addr, uint8_t asn); 682SN/A 692SN/A // static helper functions... really EV5 VM traits 702SN/A static bool validVirtualAddress(Addr vaddr) { 712SN/A // unimplemented bits must be all 0 or all 1 721147SN/A Addr unimplBits = vaddr & EV5::VAddrUnImplMask; 731147SN/A return (unimplBits == 0) || (unimplBits == EV5::VAddrUnImplMask); 742SN/A } 752SN/A 762532SN/A static Fault checkCacheability(RequestPtr &req); 772SN/A 782SN/A // Checkpointing 79217SN/A virtual void serialize(std::ostream &os); 80237SN/A virtual void unserialize(Checkpoint *cp, const std::string §ion); 812SN/A}; 822SN/A 83674SN/Aclass AlphaITB : public AlphaTLB 842SN/A{ 852SN/A protected: 86729SN/A mutable Stats::Scalar<> hits; 87729SN/A mutable Stats::Scalar<> misses; 88729SN/A mutable Stats::Scalar<> acv; 89729SN/A mutable Stats::Formula accesses; 902SN/A 912SN/A public: 92674SN/A AlphaITB(const std::string &name, int size); 932SN/A virtual void regStats(); 942SN/A 952532SN/A Fault translate(RequestPtr &req, ExecContext *xc) const; 962SN/A}; 972SN/A 98674SN/Aclass AlphaDTB : public AlphaTLB 992SN/A{ 1002SN/A protected: 101729SN/A mutable Stats::Scalar<> read_hits; 102729SN/A mutable Stats::Scalar<> read_misses; 103729SN/A mutable Stats::Scalar<> read_acv; 104729SN/A mutable Stats::Scalar<> read_accesses; 105729SN/A mutable Stats::Scalar<> write_hits; 106729SN/A mutable Stats::Scalar<> write_misses; 107729SN/A mutable Stats::Scalar<> write_acv; 108729SN/A mutable Stats::Scalar<> write_accesses; 109729SN/A Stats::Formula hits; 110729SN/A Stats::Formula misses; 111729SN/A Stats::Formula acv; 112729SN/A Stats::Formula accesses; 1132SN/A 1142SN/A public: 115674SN/A AlphaDTB(const std::string &name, int size); 1162SN/A virtual void regStats(); 1172SN/A 1182532SN/A Fault translate(RequestPtr &req, ExecContext *xc, bool write) const; 1192SN/A}; 1202SN/A 1212SN/A#endif // __ALPHA_MEMORY_HH__ 122