tlb.hh revision 2665
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"
392090SN/A#include "arch/alpha/faults.hh"
401147SN/A#include "base/statistics.hh"
412517SN/A#include "mem/request.hh"
4256SN/A#include "sim/sim_object.hh"
432SN/A
442SN/Aclass ExecContext;
452SN/A
46674SN/Aclass AlphaTLB : public SimObject
472SN/A{
482SN/A  protected:
492SN/A    typedef std::multimap<Addr, int> PageTable;
502SN/A    PageTable lookupTable;	// Quick lookup into page table
512SN/A
522SN/A    AlphaISA::PTE *table;	// the Page Table
532SN/A    int size;			// TLB Size
542SN/A    int nlu;			// not last used entry (for replacement)
552SN/A
562SN/A    void nextnlu() { if (++nlu >= size) nlu = 0; }
572SN/A    AlphaISA::PTE *lookup(Addr vpn, uint8_t asn) const;
582SN/A
592SN/A  public:
60674SN/A    AlphaTLB(const std::string &name, int size);
61674SN/A    virtual ~AlphaTLB();
622SN/A
632SN/A    int getsize() const { return size; }
642SN/A
65555SN/A    AlphaISA::PTE &index(bool advance = true);
662SN/A    void insert(Addr vaddr, AlphaISA::PTE &pte);
672SN/A
682SN/A    void flushAll();
692SN/A    void flushProcesses();
702SN/A    void flushAddr(Addr addr, uint8_t asn);
712SN/A
722SN/A    // static helper functions... really EV5 VM traits
732SN/A    static bool validVirtualAddress(Addr vaddr) {
742SN/A        // unimplemented bits must be all 0 or all 1
751147SN/A        Addr unimplBits = vaddr & EV5::VAddrUnImplMask;
761147SN/A        return (unimplBits == 0) || (unimplBits == EV5::VAddrUnImplMask);
772SN/A    }
782SN/A
792532SN/A    static Fault checkCacheability(RequestPtr &req);
802SN/A
812SN/A    // Checkpointing
82217SN/A    virtual void serialize(std::ostream &os);
83237SN/A    virtual void unserialize(Checkpoint *cp, const std::string &section);
842SN/A};
852SN/A
86674SN/Aclass AlphaITB : public AlphaTLB
872SN/A{
882SN/A  protected:
89729SN/A    mutable Stats::Scalar<> hits;
90729SN/A    mutable Stats::Scalar<> misses;
91729SN/A    mutable Stats::Scalar<> acv;
92729SN/A    mutable Stats::Formula accesses;
932SN/A
942SN/A  public:
95674SN/A    AlphaITB(const std::string &name, int size);
962SN/A    virtual void regStats();
972SN/A
982532SN/A    Fault translate(RequestPtr &req, ExecContext *xc) const;
992SN/A};
1002SN/A
101674SN/Aclass AlphaDTB : public AlphaTLB
1022SN/A{
1032SN/A  protected:
104729SN/A    mutable Stats::Scalar<> read_hits;
105729SN/A    mutable Stats::Scalar<> read_misses;
106729SN/A    mutable Stats::Scalar<> read_acv;
107729SN/A    mutable Stats::Scalar<> read_accesses;
108729SN/A    mutable Stats::Scalar<> write_hits;
109729SN/A    mutable Stats::Scalar<> write_misses;
110729SN/A    mutable Stats::Scalar<> write_acv;
111729SN/A    mutable Stats::Scalar<> write_accesses;
112729SN/A    Stats::Formula hits;
113729SN/A    Stats::Formula misses;
114729SN/A    Stats::Formula acv;
115729SN/A    Stats::Formula accesses;
1162SN/A
1172SN/A  public:
118674SN/A    AlphaDTB(const std::string &name, int size);
1192SN/A    virtual void regStats();
1202SN/A
1212532SN/A    Fault translate(RequestPtr &req, ExecContext *xc, bool write) const;
1222SN/A};
1232SN/A
1242SN/A#endif // __ALPHA_MEMORY_HH__
125