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  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * Authors: Nathan Binkert
29  * Steve Reinhardt
30  */
31 
32 #ifndef __ARCH_ALPHA_TLB_HH__
33 #define __ARCH_ALPHA_TLB_HH__
34 
35 #include <map>
36 
37 #include "arch/alpha/ev5.hh"
38 #include "arch/alpha/isa_traits.hh"
39 #include "arch/alpha/pagetable.hh"
40 #include "arch/alpha/utility.hh"
41 #include "arch/alpha/vtophys.hh"
42 #include "arch/generic/tlb.hh"
43 #include "base/statistics.hh"
44 #include "mem/request.hh"
45 #include "params/AlphaTLB.hh"
46 
47 class ThreadContext;
48 
49 namespace AlphaISA {
50 
51 struct TlbEntry;
52 
53 class TLB : public BaseTLB
54 {
55  protected:
72 
73 
74  typedef std::multimap<Addr, int> PageTable;
75  PageTable lookupTable; // Quick lookup into page table
76 
77  std::vector<TlbEntry> table; // the Page Table
78  int nlu; // not last used entry (for replacement)
79 
80  void nextnlu() { if (++nlu >= table.size()) nlu = 0; }
81  TlbEntry *lookup(Addr vpn, uint8_t asn);
82 
83  public:
84  typedef AlphaTLBParams Params;
85  TLB(const Params *p);
86  virtual ~TLB();
87 
88  void takeOverFrom(BaseTLB *otlb) override {}
89 
90  void regStats() override;
91 
92  int getsize() const { return table.size(); }
93 
94  TlbEntry &index(bool advance = true);
95  void insert(Addr vaddr, TlbEntry &entry);
96 
97  void flushAll() override;
98  void flushProcesses();
99  void flushAddr(Addr addr, uint8_t asn);
100 
101  void
102  demapPage(Addr vaddr, uint64_t asn) override
103  {
104  assert(asn < (1 << 8));
105  flushAddr(vaddr, asn);
106  }
107 
108  // static helper functions... really EV5 VM traits
109  static bool
111  {
112  // unimplemented bits must be all 0 or all 1
113  Addr unimplBits = vaddr & VAddrUnImplMask;
114  return unimplBits == 0 || unimplBits == VAddrUnImplMask;
115  }
116 
117  static Fault checkCacheability(RequestPtr &req, bool itb = false);
118 
119  // Checkpointing
120  void serialize(CheckpointOut &cp) const override;
121  void unserialize(CheckpointIn &cp) override;
122 
123  // Most recently used page table entries
125  inline void
127  {
128  memset(EntryCache, 0, 3 * sizeof(TlbEntry*));
129  }
130 
131  inline TlbEntry *
133  EntryCache[2] = EntryCache[1];
134  EntryCache[1] = EntryCache[0];
135  EntryCache[0] = entry;
136  return entry;
137  }
138 
139  protected:
140  Fault translateData(RequestPtr req, ThreadContext *tc, bool write);
142 
143  public:
146  Translation *translation, Mode mode);
152 };
153 
154 } // namespace AlphaISA
155 
156 #endif // __ARCH_ALPHA_TLB_HH__
Stats::Scalar fetch_hits
Definition: tlb.hh:56
Stats::Formula data_acv
Definition: tlb.hh:70
Stats::Formula fetch_accesses
Definition: tlb.hh:59
AlphaTLBParams Params
Definition: tlb.hh:84
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:359
int nlu
Definition: tlb.hh:78
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Stats::Scalar write_acv
Definition: tlb.hh:66
ip6_addr_t addr
Definition: inet.hh:335
Stats::Scalar read_acv
Definition: tlb.hh:62
Stats::Formula data_misses
Definition: tlb.hh:69
int getsize() const
Definition: tlb.hh:92
void flushProcesses()
Definition: tlb.cc:293
Bitfield< 4, 0 > mode
Definition: miscregs.hh:1385
std::vector< TlbEntry > table
Definition: tlb.hh:77
TlbEntry & index(bool advance=true)
Definition: tlb.cc:591
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Declaration of Statistics objects.
Stats::Scalar write_misses
Definition: tlb.hh:65
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
Fault translateData(RequestPtr req, ThreadContext *tc, bool write)
Definition: tlb.cc:452
Stats::Scalar fetch_misses
Definition: tlb.hh:57
Definition: tlb.hh:53
void flushCache()
Definition: tlb.hh:126
Stats::Scalar read_hits
Definition: tlb.hh:60
Stats::Scalar fetch_acv
Definition: tlb.hh:58
static Fault checkCacheability(RequestPtr &req, bool itb=false)
Definition: tlb.cc:206
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:283
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:102
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:348
Stats::Scalar write_hits
Definition: tlb.hh:64
TlbEntry(Addr asn, Addr _vaddr, Addr _paddr, bool uncacheable, bool read_only)
Fault finalizePhysical(RequestPtr req, ThreadContext *tc, Mode mode) const
Definition: tlb.cc:626
void nextnlu()
Definition: tlb.hh:80
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:88
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void translateTiming(RequestPtr req, ThreadContext *tc, Translation *translation, Mode mode)
Definition: tlb.cc:611
TlbEntry * updateCache(TlbEntry *entry)
Definition: tlb.hh:132
Stats::Formula data_hits
Definition: tlb.hh:68
Stats::Scalar read_accesses
Definition: tlb.hh:63
void flushAddr(Addr addr, uint8_t asn)
Definition: tlb.cc:318
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2895
Stats::Scalar write_accesses
Definition: tlb.hh:67
const Addr VAddrUnImplMask
Definition: ev5.hh:45
Mode
Definition: tlb.hh:61
std::multimap< Addr, int > PageTable
Definition: tlb.hh:74
virtual ~TLB()
Definition: tlb.cc:72
static bool validVirtualAddress(Addr vaddr)
Definition: tlb.hh:110
std::ostream CheckpointOut
Definition: serialize.hh:67
TlbEntry * lookup(Addr vpn, uint8_t asn)
Definition: tlb.cc:164
Fault translateInst(RequestPtr req, ThreadContext *tc)
Definition: tlb.cc:375
Stats::Scalar read_misses
Definition: tlb.hh:61
TlbEntry * EntryCache[3]
Definition: tlb.hh:124
void insert(Addr vaddr, TlbEntry &entry)
Definition: tlb.cc:248
Stats::Formula data_accesses
Definition: tlb.hh:71
TLB(const Params *p)
Definition: tlb.cc:66
Fault translateFunctional(RequestPtr req, ThreadContext *tc, Mode mode)
translateFunctional stub function for future CheckerCPU support
Definition: tlb.cc:619
Bitfield< 0 > p
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
PageTable lookupTable
Definition: tlb.hh:75
Fault translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode)
Definition: tlb.cc:602
void regStats() override
Register statistics for this object.
Definition: tlb.cc:77

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