gem5  v20.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 
30 #ifndef __ARCH_MIPS_TLB_HH__
31 #define __ARCH_MIPS_TLB_HH__
32 
33 #include <map>
34 
35 #include "arch/generic/tlb.hh"
36 #include "arch/mips/isa_traits.hh"
37 #include "arch/mips/pagetable.hh"
38 #include "arch/mips/utility.hh"
39 #include "base/statistics.hh"
40 #include "mem/request.hh"
41 #include "params/MipsTLB.hh"
42 #include "sim/sim_object.hh"
43 
44 class ThreadContext;
45 
46 /* MIPS does not distinguish between a DTLB and an ITLB -> unified TLB
47  However, to maintain compatibility with other architectures, we'll
48  simply create an ITLB and DTLB that will point to the real TLB */
49 namespace MipsISA {
50 
51 class TLB : public BaseTLB
52 {
53  protected:
54  typedef std::multimap<Addr, int> PageTable;
55  PageTable lookupTable; // Quick lookup into page table
56 
57  MipsISA::PTE *table; // the Page Table
58  int size; // TLB Size
59  int nlu; // not last used entry (for replacement)
60 
61  void nextnlu() { if (++nlu >= size) nlu = 0; }
62  MipsISA::PTE *lookup(Addr vpn, uint8_t asn) const;
63 
75 
76  public:
77  typedef MipsTLBParams Params;
78  TLB(const Params *p);
79 
80  int probeEntry(Addr vpn,uint8_t) const;
81  MipsISA::PTE *getEntry(unsigned) const;
82  virtual ~TLB();
83 
84  void takeOverFrom(BaseTLB *otlb) override {}
85 
87  int getsize() const { return size; }
88 
89  MipsISA::PTE &index(bool advance = true);
90  void insert(Addr vaddr, MipsISA::PTE &pte);
91  void insertAt(MipsISA::PTE &pte, unsigned Index, int _smallPages);
92  void flushAll() override;
93  void demapPage(Addr vaddr, uint64_t asn) override
94  {
95  panic("demapPage unimplemented.\n");
96  }
97 
98  // static helper functions... really
99  static bool validVirtualAddress(Addr vaddr);
100 
101  static Fault checkCacheability(const RequestPtr &req);
102 
103  // Checkpointing
104  void serialize(CheckpointOut &cp) const override;
105  void unserialize(CheckpointIn &cp) override;
106 
107  void regStats() override;
108 
110  const RequestPtr &req, ThreadContext *tc, Mode mode) override;
111  void translateTiming(
112  const RequestPtr &req, ThreadContext *tc,
113  Translation *translation, Mode mode) override;
115  const RequestPtr &req, ThreadContext *tc, Mode mode) override;
117  const RequestPtr &req,
118  ThreadContext *tc, Mode mode) const override;
119 };
120 
121 }
122 
123 
124 
125 #endif // __MIPS_MEMORY_HH__
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:163
MipsISA::PTE & index(bool advance=true)
Definition: tlb.cc:308
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Definition: tlb.cc:293
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:194
MipsISA::PTE * table
Definition: tlb.hh:57
Stats::Scalar read_hits
Definition: tlb.hh:64
Stats::Scalar read_acv
Definition: tlb.hh:66
int size
Definition: tlb.hh:58
MipsISA::PTE * lookup(Addr vpn, uint8_t asn) const
Definition: tlb.cc:72
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
std::shared_ptr< Request > RequestPtr
Definition: request.hh:81
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:185
void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode) override
Definition: tlb.cc:285
void regStats() override
Callback to set stat parameters.
Definition: tlb.cc:221
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Definition: tlb.cc:278
Stats::Formula hits
Definition: tlb.hh:72
Definition: cprintf.cc:40
std::multimap< Addr, int > PageTable
Definition: tlb.hh:54
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:2505
int getsize() const
Definition: tlb.hh:87
TLB(const Params *p)
Definition: tlb.cc:57
MipsISA::PTE * getEntry(unsigned) const
Definition: tlb.cc:102
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:93
Definition: tlb.hh:50
Stats::Scalar write_misses
Definition: tlb.hh:69
Stats::Scalar write_hits
Definition: tlb.hh:68
int nlu
Definition: tlb.hh:59
static bool validVirtualAddress(Addr vaddr)
void nextnlu()
Definition: tlb.hh:61
virtual ~TLB()
Definition: tlb.cc:65
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
Stats::Scalar read_misses
Definition: tlb.hh:65
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3009
MipsTLBParams Params
Definition: tlb.hh:77
Mode
Definition: tlb.hh:57
int probeEntry(Addr vpn, uint8_t) const
Definition: tlb.cc:110
std::ostream CheckpointOut
Definition: serialize.hh:63
Stats::Scalar write_acv
Definition: tlb.hh:70
static Fault checkCacheability(const RequestPtr &req)
Definition: tlb.cc:138
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:206
Bitfield< 11, 7 > mode
Definition: dt_constants.hh:95
Stats::Scalar read_accesses
Definition: tlb.hh:67
void insertAt(MipsISA::PTE &pte, unsigned Index, int _smallPages)
Definition: tlb.cc:151
PageTable lookupTable
Definition: tlb.hh:55
Stats::Scalar write_accesses
Definition: tlb.hh:71
Bitfield< 0 > p
std::shared_ptr< FaultBase > Fault
Definition: types.hh:238
Stats::Formula accesses
Definition: tlb.hh:74
Stats::Formula misses
Definition: tlb.hh:73
void insert(Addr vaddr, MipsISA::PTE &pte)
Definition: tlb.cc:179
int smallPages
Definition: tlb.hh:86
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, Mode mode) const override
Do post-translation physical address finalization.
Definition: tlb.cc:300
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:84

Generated on Thu May 28 2020 16:11:01 for gem5 by doxygen 1.8.13