gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tlb.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2005 The Regents of The University of Michigan
3  * Copyright (c) 2007 MIPS Technologies, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer;
10  * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution;
13  * neither the name of the copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Authors: Nathan Binkert
30  * Steve Reinhardt
31  * Jaidev Patwardhan
32  * Korey Sewell
33  */
34 
35 #ifndef __ARCH_MIPS_TLB_HH__
36 #define __ARCH_MIPS_TLB_HH__
37 
38 #include <map>
39 
40 #include "arch/generic/tlb.hh"
41 #include "arch/mips/isa_traits.hh"
42 #include "arch/mips/pagetable.hh"
43 #include "arch/mips/utility.hh"
44 #include "arch/mips/vtophys.hh"
45 #include "base/statistics.hh"
46 #include "mem/request.hh"
47 #include "params/MipsTLB.hh"
48 #include "sim/sim_object.hh"
49 
50 class ThreadContext;
51 
52 /* MIPS does not distinguish between a DTLB and an ITLB -> unified TLB
53  However, to maintain compatibility with other architectures, we'll
54  simply create an ITLB and DTLB that will point to the real TLB */
55 namespace MipsISA {
56 
57 class TLB : public BaseTLB
58 {
59  protected:
60  typedef std::multimap<Addr, int> PageTable;
61  PageTable lookupTable; // Quick lookup into page table
62 
63  MipsISA::PTE *table; // the Page Table
64  int size; // TLB Size
65  int nlu; // not last used entry (for replacement)
66 
67  void nextnlu() { if (++nlu >= size) nlu = 0; }
68  MipsISA::PTE *lookup(Addr vpn, uint8_t asn) const;
69 
81 
82  public:
83  typedef MipsTLBParams Params;
84  TLB(const Params *p);
85 
86  int probeEntry(Addr vpn,uint8_t) const;
87  MipsISA::PTE *getEntry(unsigned) const;
88  virtual ~TLB();
89 
90  void takeOverFrom(BaseTLB *otlb) override {}
91 
93  int getsize() const { return size; }
94 
95  MipsISA::PTE &index(bool advance = true);
96  void insert(Addr vaddr, MipsISA::PTE &pte);
97  void insertAt(MipsISA::PTE &pte, unsigned Index, int _smallPages);
98  void flushAll() override;
99  void demapPage(Addr vaddr, uint64_t asn) override
100  {
101  panic("demapPage unimplemented.\n");
102  }
103 
104  // static helper functions... really
105  static bool validVirtualAddress(Addr vaddr);
106 
107  static Fault checkCacheability(RequestPtr &req);
108 
109  // Checkpointing
110  void serialize(CheckpointOut &cp) const override;
111  void unserialize(CheckpointIn &cp) override;
112 
113  void regStats() override;
114 
117  Translation *translation, Mode mode);
118 
124 
125  private:
127  Fault translateData(RequestPtr req, ThreadContext *tc, bool write);
128 };
129 
130 }
131 
132 
133 
134 #endif // __MIPS_MEMORY_HH__
MipsISA::PTE & index(bool advance=true)
Definition: tlb.cc:346
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:201
MipsISA::PTE * table
Definition: tlb.hh:63
Stats::Scalar read_hits
Definition: tlb.hh:70
#define panic(...)
Definition: misc.hh:153
MipsISA::PTE * lookup(Addr vpn, uint8_t asn) const
Definition: tlb.cc:79
Stats::Scalar read_acv
Definition: tlb.hh:72
int size
Definition: tlb.hh:64
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:192
MipsISA::PTE * getEntry(unsigned) const
Definition: tlb.cc:109
void regStats() override
Register statistics for this object.
Definition: tlb.cc:228
Stats::Formula hits
Definition: tlb.hh:78
std::multimap< Addr, int > PageTable
Definition: tlb.hh:60
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
TLB(const Params *p)
Definition: tlb.cc:63
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:99
Definition: tlb.hh:53
int probeEntry(Addr vpn, uint8_t) const
Definition: tlb.cc:117
Fault translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode)
Definition: tlb.cc:315
Stats::Scalar write_misses
Definition: tlb.hh:75
Stats::Scalar write_hits
Definition: tlb.hh:74
int nlu
Definition: tlb.hh:65
static bool validVirtualAddress(Addr vaddr)
void nextnlu()
Definition: tlb.hh:67
Fault translateData(RequestPtr req, ThreadContext *tc, bool write)
Definition: tlb.cc:300
virtual ~TLB()
Definition: tlb.cc:71
Fault translateFunctional(RequestPtr req, ThreadContext *tc, Mode mode)
Function stub for CheckerCPU compilation issues.
Definition: tlb.cc:332
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Stats::Scalar read_misses
Definition: tlb.hh:71
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2895
MipsTLBParams Params
Definition: tlb.hh:83
Mode
Definition: tlb.hh:61
std::ostream CheckpointOut
Definition: serialize.hh:67
Stats::Scalar write_acv
Definition: tlb.hh:76
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:213
Bitfield< 11, 7 > mode
Definition: dt_constants.hh:97
Stats::Scalar read_accesses
Definition: tlb.hh:73
static Fault checkCacheability(RequestPtr &req)
Definition: tlb.cc:145
Fault translateInst(RequestPtr req, ThreadContext *tc)
Definition: tlb.cc:285
void insertAt(MipsISA::PTE &pte, unsigned Index, int _smallPages)
Definition: tlb.cc:158
int getsize() const
Definition: tlb.hh:93
Fault finalizePhysical(RequestPtr req, ThreadContext *tc, Mode mode) const
Definition: tlb.cc:339
void translateTiming(RequestPtr req, ThreadContext *tc, Translation *translation, Mode mode)
Definition: tlb.cc:324
PageTable lookupTable
Definition: tlb.hh:61
Stats::Scalar write_accesses
Definition: tlb.hh:77
Bitfield< 0 > p
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
Stats::Formula accesses
Definition: tlb.hh:80
Stats::Formula misses
Definition: tlb.hh:79
void insert(Addr vaddr, MipsISA::PTE &pte)
Definition: tlb.cc:186
int smallPages
Definition: tlb.hh:92
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:90

Generated on Fri Jun 9 2017 13:03:36 for gem5 by doxygen 1.8.6