gem5  v20.1.0.0
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 
32 #ifndef __ARCH_POWER_TLB_HH__
33 #define __ARCH_POWER_TLB_HH__
34 
35 #include <map>
36 
37 #include "arch/generic/tlb.hh"
38 #include "arch/power/isa_traits.hh"
39 #include "arch/power/pagetable.hh"
40 #include "arch/power/utility.hh"
41 #include "base/statistics.hh"
42 #include "mem/request.hh"
43 #include "params/PowerTLB.hh"
44 
45 class ThreadContext;
46 
47 namespace PowerISA {
48 
49 // This is copied from the ARM ISA and has not been checked against the
50 // Power at all.
51 struct TlbEntry
52 {
54 
56  {
57  }
58 
59  TlbEntry(Addr asn, Addr vaddr, Addr paddr,
60  bool uncacheable, bool read_only)
61  : _pageStart(paddr)
62  {
63  if (uncacheable || read_only)
64  warn("Power TlbEntry does not support uncacheable"
65  " or read-only mappings\n");
66  }
67 
68  void
69  updateVaddr(Addr new_vaddr)
70  {
71  panic("unimplemented");
72  }
73 
74  Addr
76  {
77  return _pageStart;
78  }
79 
80  void
82  {
84  }
85 
86  void
88  {
90  }
91 };
92 
93 class TLB : public BaseTLB
94 {
95  protected:
96  typedef std::multimap<Addr, int> PageTable;
97  PageTable lookupTable; // Quick lookup into page table
98 
99  PowerISA::PTE *table; // the Page Table
100  int size; // TLB Size
101  int nlu; // not last used entry (for replacement)
102 
103  void
105  {
106  if (++nlu >= size) {
107  nlu = 0;
108  }
109  }
110 
111  PowerISA::PTE *lookup(Addr vpn, uint8_t asn) const;
112 
113  public:
114  typedef PowerTLBParams Params;
115  TLB(const Params *p);
116  virtual ~TLB();
117 
118  void takeOverFrom(BaseTLB *otlb) override {}
119 
120  int probeEntry(Addr vpn,uint8_t) const;
121  PowerISA::PTE *getEntry(unsigned) const;
122 
124 
125  int
126  getsize() const
127  {
128  return size;
129  }
130 
131  PowerISA::PTE &index(bool advance = true);
132  void insert(Addr vaddr, PowerISA::PTE &pte);
133  void insertAt(PowerISA::PTE &pte, unsigned Index, int _smallPages);
134  void flushAll() override;
135 
136  void
137  demapPage(Addr vaddr, uint64_t asn) override
138  {
139  panic("demapPage unimplemented.\n");
140  }
141 
142  // static helper functions... really
143  static bool validVirtualAddress(Addr vaddr);
144  static Fault checkCacheability(const RequestPtr &req);
145  Fault translateInst(const RequestPtr &req, ThreadContext *tc);
146  Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write);
148  const RequestPtr &req, ThreadContext *tc, Mode mode) override;
149  void translateTiming(
150  const RequestPtr &req, ThreadContext *tc,
151  Translation *translation, Mode mode) override;
153  const RequestPtr &req, ThreadContext *tc, Mode mode) override;
155  const RequestPtr &req,
156  ThreadContext *tc, Mode mode) const override;
157 
158  // Checkpointing
159  void serialize(CheckpointOut &cp) const override;
160  void unserialize(CheckpointIn &cp) override;
161 };
162 
163 } // namespace PowerISA
164 
165 #endif // __ARCH_POWER_TLB_HH__
PowerISA::TlbEntry::serialize
void serialize(CheckpointOut &cp) const
Definition: tlb.hh:81
utility.hh
PowerISA::TLB::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:205
PowerISA::TLB::PageTable
std::multimap< Addr, int > PageTable
Definition: tlb.hh:96
warn
#define warn(...)
Definition: logging.hh:239
PowerISA::TLB::translateAtomic
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Definition: tlb.cc:238
PowerISA::TlbEntry::TlbEntry
TlbEntry()
Definition: tlb.hh:55
PowerISA::TLB::lookupTable
PageTable lookupTable
Definition: tlb.hh:97
PowerISA::TLB::translateFunctional
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Definition: tlb.cc:250
UNSERIALIZE_SCALAR
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:797
PowerISA::TLB::nextnlu
void nextnlu()
Definition: tlb.hh:104
PowerISA::TlbEntry::_pageStart
Addr _pageStart
Definition: tlb.hh:53
PowerISA::TlbEntry
Definition: tlb.hh:51
tlb.hh
BaseTLB::Mode
Mode
Definition: tlb.hh:57
PowerISA::TLB::size
int size
Definition: tlb.hh:100
PowerISA::PTE
Definition: pagetable.hh:42
PowerISA::TLB::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:193
PowerISA::TLB::TLB
TLB(const Params *p)
Definition: tlb.cc:61
RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:82
PowerISA::TLB::validVirtualAddress
static bool validVirtualAddress(Addr vaddr)
PowerISA::TLB::translateInst
Fault translateInst(const RequestPtr &req, ThreadContext *tc)
Definition: tlb.cc:219
request.hh
BaseTLB
Definition: tlb.hh:50
pagetable.hh
PowerISA::TLB::checkCacheability
static Fault checkCacheability(const RequestPtr &req)
Definition: tlb.cc:142
PowerISA::TLB::insert
void insert(Addr vaddr, PowerISA::PTE &pte)
Definition: tlb.cc:178
PowerISA::TLB::nlu
int nlu
Definition: tlb.hh:101
PowerISA::TLB::translateTiming
void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode) override
Definition: tlb.cc:258
PowerISA::TLB::takeOverFrom
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:118
cp
Definition: cprintf.cc:40
PowerISA::TLB::translateData
Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write)
Definition: tlb.cc:232
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
PowerISA
Definition: decoder.cc:31
PowerISA::TLB::smallPages
int smallPages
Definition: tlb.hh:123
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
MipsISA::vaddr
vaddr
Definition: pra_constants.hh:275
PowerISA::TlbEntry::unserialize
void unserialize(CheckpointIn &cp)
Definition: tlb.hh:87
statistics.hh
PowerISA::TLB::finalizePhysical
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, Mode mode) const override
Do post-translation physical address finalization.
Definition: tlb.cc:266
ArmISA::mode
Bitfield< 4, 0 > mode
Definition: miscregs_types.hh:70
PowerISA::TLB::getsize
int getsize() const
Definition: tlb.hh:126
PowerISA::TlbEntry::updateVaddr
void updateVaddr(Addr new_vaddr)
Definition: tlb.hh:69
PowerISA::TLB::table
PowerISA::PTE * table
Definition: tlb.hh:99
PowerISA::TlbEntry::pageStart
Addr pageStart()
Definition: tlb.hh:75
PowerISA::TLB::probeEntry
int probeEntry(Addr vpn, uint8_t) const
Definition: tlb.cc:114
PowerISA::TLB::lookup
PowerISA::PTE * lookup(Addr vpn, uint8_t asn) const
Definition: tlb.cc:77
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:790
PowerISA::TLB::~TLB
virtual ~TLB()
Definition: tlb.cc:69
PowerISA::TLB::index
PowerISA::PTE & index(bool advance=true)
Definition: tlb.cc:273
PowerISA::TLB::demapPage
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:137
isa_traits.hh
PowerISA::TLB
Definition: tlb.hh:93
PowerISA::TlbEntry::TlbEntry
TlbEntry(Addr asn, Addr vaddr, Addr paddr, bool uncacheable, bool read_only)
Definition: tlb.hh:59
PowerISA::TLB::Params
PowerTLBParams Params
Definition: tlb.hh:114
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
PowerISA::TLB::getEntry
PowerISA::PTE * getEntry(unsigned) const
Definition: tlb.cc:106
PowerISA::TLB::flushAll
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:184
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
CheckpointIn
Definition: serialize.hh:67
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
PowerISA::TLB::insertAt
void insertAt(PowerISA::PTE &pte, unsigned Index, int _smallPages)
Definition: tlb.cc:154

Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17