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  * Copyright (c) 2007-2008 The Florida State University
5  * Copyright (c) 2009 The University of Edinburgh
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met: redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer;
12  * redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution;
15  * neither the name of the copyright holders nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * Authors: Nathan Binkert
32  * Steve Reinhardt
33  * Stephen Hines
34  * Timothy M. Jones
35  */
36 
37 #ifndef __ARCH_POWER_TLB_HH__
38 #define __ARCH_POWER_TLB_HH__
39 
40 #include <map>
41 
42 #include "arch/generic/tlb.hh"
43 #include "arch/power/isa_traits.hh"
44 #include "arch/power/pagetable.hh"
45 #include "arch/power/utility.hh"
46 #include "arch/power/vtophys.hh"
47 #include "base/statistics.hh"
48 #include "mem/request.hh"
49 #include "params/PowerTLB.hh"
50 
51 class ThreadContext;
52 
53 namespace PowerISA {
54 
55 // This is copied from the ARM ISA and has not been checked against the
56 // Power at all.
57 struct TlbEntry
58 {
60 
62  {
63  }
64 
65  TlbEntry(Addr asn, Addr vaddr, Addr paddr,
66  bool uncacheable, bool read_only)
67  : _pageStart(paddr)
68  {
69  if (uncacheable || read_only)
70  warn("Power TlbEntry does not support uncacheable"
71  " or read-only mappings\n");
72  }
73 
74  void
75  updateVaddr(Addr new_vaddr)
76  {
77  panic("unimplemented");
78  }
79 
80  Addr
82  {
83  return _pageStart;
84  }
85 
86  void
88  {
90  }
91 
92  void
94  {
96  }
97 };
98 
99 class TLB : public BaseTLB
100 {
101  protected:
102  typedef std::multimap<Addr, int> PageTable;
103  PageTable lookupTable; // Quick lookup into page table
104 
105  PowerISA::PTE *table; // the Page Table
106  int size; // TLB Size
107  int nlu; // not last used entry (for replacement)
108 
109  void
111  {
112  if (++nlu >= size) {
113  nlu = 0;
114  }
115  }
116 
117  PowerISA::PTE *lookup(Addr vpn, uint8_t asn) const;
118 
130 
131  public:
132  typedef PowerTLBParams Params;
133  TLB(const Params *p);
134  virtual ~TLB();
135 
136  void takeOverFrom(BaseTLB *otlb) override {}
137 
138  int probeEntry(Addr vpn,uint8_t) const;
139  PowerISA::PTE *getEntry(unsigned) const;
140 
142 
143  int
144  getsize() const
145  {
146  return size;
147  }
148 
149  PowerISA::PTE &index(bool advance = true);
150  void insert(Addr vaddr, PowerISA::PTE &pte);
151  void insertAt(PowerISA::PTE &pte, unsigned Index, int _smallPages);
152  void flushAll() override;
153 
154  void
155  demapPage(Addr vaddr, uint64_t asn) override
156  {
157  panic("demapPage unimplemented.\n");
158  }
159 
160  // static helper functions... really
161  static bool validVirtualAddress(Addr vaddr);
162  static Fault checkCacheability(RequestPtr &req);
164  Fault translateData(RequestPtr req, ThreadContext *tc, bool write);
167  Translation *translation, Mode mode);
173 
174  // Checkpointing
175  void serialize(CheckpointOut &cp) const override;
176  void unserialize(CheckpointIn &cp) override;
177 
178  void regStats() override;
179 };
180 
181 } // namespace PowerISA
182 
183 #endif // __ARCH_POWER_TLB_HH__
Stats::Scalar read_misses
Definition: tlb.hh:120
void unserialize(CheckpointIn &cp)
Definition: tlb.hh:93
int getsize() const
Definition: tlb.hh:144
Fault translateFunctional(RequestPtr req, ThreadContext *tc, Mode mode)
Stub function for CheckerCPU compilation support.
Definition: tlb.cc:333
Fault translateInst(RequestPtr req, ThreadContext *tc)
Definition: tlb.cc:282
void updateVaddr(Addr new_vaddr)
Definition: tlb.hh:75
#define panic(...)
Definition: misc.hh:153
void insertAt(PowerISA::PTE &pte, unsigned Index, int _smallPages)
Definition: tlb.cc:160
int smallPages
Definition: tlb.hh:141
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
std::multimap< Addr, int > PageTable
Definition: tlb.hh:102
Stats::Scalar write_accesses
Definition: tlb.hh:126
PowerISA::PTE & index(bool advance=true)
Definition: tlb.cc:346
PowerTLBParams Params
Definition: tlb.hh:132
Stats::Scalar read_accesses
Definition: tlb.hh:122
Stats::Scalar write_acv
Definition: tlb.hh:125
Stats::Scalar read_hits
Definition: tlb.hh:119
bool uncacheable
Definition: pagetable.hh:118
void insert(Addr vaddr, PowerISA::PTE &pte)
Definition: tlb.cc:184
Bitfield< 4, 0 > mode
Definition: miscregs.hh:1385
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:136
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
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:155
void serialize(CheckpointOut &cp) const
Definition: tlb.hh:87
Stats::Formula hits
Definition: tlb.hh:127
Fault finalizePhysical(RequestPtr req, ThreadContext *tc, Mode mode) const
Definition: tlb.cc:340
#define warn(...)
Definition: misc.hh:219
Definition: tlb.hh:53
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:145
void nextnlu()
Definition: tlb.hh:110
Stats::Scalar read_acv
Definition: tlb.hh:121
void regStats() override
Register statistics for this object.
Definition: tlb.cc:225
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:199
int nlu
Definition: tlb.hh:107
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Fault translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode)
Definition: tlb.cc:313
PowerISA::PTE * table
Definition: tlb.hh:105
Stats::Scalar write_hits
Definition: tlb.hh:123
Stats::Formula accesses
Definition: tlb.hh:129
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:143
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2895
TlbEntry(Addr asn, Addr vaddr, Addr paddr, bool uncacheable, bool read_only)
Definition: tlb.hh:65
TLB(const Params *p)
Definition: tlb.cc:67
Mode
Definition: tlb.hh:61
void translateTiming(RequestPtr req, ThreadContext *tc, Translation *translation, Mode mode)
Definition: tlb.cc:325
PowerISA::PTE * getEntry(unsigned) const
Definition: tlb.cc:112
Addr _pageStart
Definition: tlb.hh:59
static Fault checkCacheability(RequestPtr &req)
Definition: tlb.cc:148
std::ostream CheckpointOut
Definition: serialize.hh:67
PageTable lookupTable
Definition: tlb.hh:103
Fault translateData(RequestPtr req, ThreadContext *tc, bool write)
Definition: tlb.cc:301
PowerISA::PTE * lookup(Addr vpn, uint8_t asn) const
Definition: tlb.cc:83
static bool validVirtualAddress(Addr vaddr)
Stats::Scalar write_misses
Definition: tlb.hh:124
int size
Definition: tlb.hh:106
Stats::Formula misses
Definition: tlb.hh:128
Addr pageStart()
Definition: tlb.hh:81
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:211
int probeEntry(Addr vpn, uint8_t) const
Definition: tlb.cc:120
virtual ~TLB()
Definition: tlb.cc:75
Bitfield< 0 > p
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:190

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