tlb.hh revision 2984
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.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert
292665Ssaidi@eecs.umich.edu *          Steve Reinhardt
302SN/A */
312SN/A
322SN/A#ifndef __ALPHA_MEMORY_HH__
332SN/A#define __ALPHA_MEMORY_HH__
342SN/A
352SN/A#include <map>
362SN/A
372432SN/A#include "arch/alpha/ev5.hh"
381147SN/A#include "arch/alpha/isa_traits.hh"
392984Sgblack@eecs.umich.edu#include "arch/alpha/utility.hh"
402984Sgblack@eecs.umich.edu#include "arch/alpha/vtophys.hh"
411147SN/A#include "base/statistics.hh"
422517SN/A#include "mem/request.hh"
432984Sgblack@eecs.umich.edu#include "sim/faults.hh"
4456SN/A#include "sim/sim_object.hh"
452SN/A
462680Sktlim@umich.educlass ThreadContext;
472SN/A
48674SN/Aclass AlphaTLB : public SimObject
492SN/A{
502SN/A  protected:
512SN/A    typedef std::multimap<Addr, int> PageTable;
522SN/A    PageTable lookupTable;	// Quick lookup into page table
532SN/A
542SN/A    AlphaISA::PTE *table;	// the Page Table
552SN/A    int size;			// TLB Size
562SN/A    int nlu;			// not last used entry (for replacement)
572SN/A
582SN/A    void nextnlu() { if (++nlu >= size) nlu = 0; }
592SN/A    AlphaISA::PTE *lookup(Addr vpn, uint8_t asn) const;
602SN/A
612SN/A  public:
62674SN/A    AlphaTLB(const std::string &name, int size);
63674SN/A    virtual ~AlphaTLB();
642SN/A
652SN/A    int getsize() const { return size; }
662SN/A
67555SN/A    AlphaISA::PTE &index(bool advance = true);
682SN/A    void insert(Addr vaddr, AlphaISA::PTE &pte);
692SN/A
702SN/A    void flushAll();
712SN/A    void flushProcesses();
722SN/A    void flushAddr(Addr addr, uint8_t asn);
732SN/A
742SN/A    // static helper functions... really EV5 VM traits
752SN/A    static bool validVirtualAddress(Addr vaddr) {
762SN/A        // unimplemented bits must be all 0 or all 1
771147SN/A        Addr unimplBits = vaddr & EV5::VAddrUnImplMask;
781147SN/A        return (unimplBits == 0) || (unimplBits == EV5::VAddrUnImplMask);
792SN/A    }
802SN/A
812532SN/A    static Fault checkCacheability(RequestPtr &req);
822SN/A
832SN/A    // Checkpointing
84217SN/A    virtual void serialize(std::ostream &os);
85237SN/A    virtual void unserialize(Checkpoint *cp, const std::string &section);
862SN/A};
872SN/A
88674SN/Aclass AlphaITB : public AlphaTLB
892SN/A{
902SN/A  protected:
91729SN/A    mutable Stats::Scalar<> hits;
92729SN/A    mutable Stats::Scalar<> misses;
93729SN/A    mutable Stats::Scalar<> acv;
94729SN/A    mutable Stats::Formula accesses;
952SN/A
962SN/A  public:
97674SN/A    AlphaITB(const std::string &name, int size);
982SN/A    virtual void regStats();
992SN/A
1002680Sktlim@umich.edu    Fault translate(RequestPtr &req, ThreadContext *tc) const;
1012SN/A};
1022SN/A
103674SN/Aclass AlphaDTB : public AlphaTLB
1042SN/A{
1052SN/A  protected:
106729SN/A    mutable Stats::Scalar<> read_hits;
107729SN/A    mutable Stats::Scalar<> read_misses;
108729SN/A    mutable Stats::Scalar<> read_acv;
109729SN/A    mutable Stats::Scalar<> read_accesses;
110729SN/A    mutable Stats::Scalar<> write_hits;
111729SN/A    mutable Stats::Scalar<> write_misses;
112729SN/A    mutable Stats::Scalar<> write_acv;
113729SN/A    mutable Stats::Scalar<> write_accesses;
114729SN/A    Stats::Formula hits;
115729SN/A    Stats::Formula misses;
116729SN/A    Stats::Formula acv;
117729SN/A    Stats::Formula accesses;
1182SN/A
1192SN/A  public:
120674SN/A    AlphaDTB(const std::string &name, int size);
1212SN/A    virtual void regStats();
1222SN/A
1232680Sktlim@umich.edu    Fault translate(RequestPtr &req, ThreadContext *tc, bool write) const;
1242SN/A};
1252SN/A
1262SN/A#endif // __ALPHA_MEMORY_HH__
127