gem5  v22.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/pagetable.hh"
39 #include "base/statistics.hh"
40 #include "mem/request.hh"
41 #include "params/PowerTLB.hh"
42 
43 namespace gem5
44 {
45 
46 class ThreadContext;
47 
48 namespace PowerISA {
49 
50 // This is copied from the ARM ISA and has not been checked against the
51 // Power at all.
52 struct TlbEntry
53 {
55 
57  {
58  }
59 
60  TlbEntry(Addr asn, Addr vaddr, Addr paddr,
61  bool uncacheable, bool read_only)
62  : _pageStart(paddr)
63  {
64  if (uncacheable || read_only)
65  warn("Power TlbEntry does not support uncacheable"
66  " or read-only mappings\n");
67  }
68 
69  void
70  updateVaddr(Addr new_vaddr)
71  {
72  panic("unimplemented");
73  }
74 
75  Addr
77  {
78  return _pageStart;
79  }
80 
81  void
83  {
85  }
86 
87  void
89  {
91  }
92 };
93 
94 class TLB : public BaseTLB
95 {
96  protected:
97  typedef std::multimap<Addr, int> PageTable;
98  PageTable lookupTable; // Quick lookup into page table
99 
100  PowerISA::PTE *table; // the Page Table
101  int size; // TLB Size
102  int nlu; // not last used entry (for replacement)
103 
104  void
106  {
107  if (++nlu >= size) {
108  nlu = 0;
109  }
110  }
111 
112  PowerISA::PTE *lookup(Addr vpn, uint8_t asn) const;
113 
114  public:
115  typedef PowerTLBParams Params;
116  TLB(const Params &p);
117  virtual ~TLB();
118 
119  void takeOverFrom(BaseTLB *otlb) override {}
120 
121  int probeEntry(Addr vpn,uint8_t) const;
122  PowerISA::PTE *getEntry(unsigned) const;
123 
125 
126  int
127  getsize() const
128  {
129  return size;
130  }
131 
132  PowerISA::PTE &index(bool advance = true);
134  void insertAt(PowerISA::PTE &pte, unsigned Index, int _smallPages);
135  void flushAll() override;
136 
137  void
138  demapPage(Addr vaddr, uint64_t asn) override
139  {
140  panic("demapPage unimplemented.\n");
141  }
142 
143  // static helper functions... really
145  static Fault checkCacheability(const RequestPtr &req);
147  Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write);
149  const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override;
151  const RequestPtr &req, ThreadContext *tc,
152  BaseMMU::Translation *translation, BaseMMU::Mode mode) override;
154  const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override;
156  const RequestPtr &req,
157  ThreadContext *tc, BaseMMU::Mode mode) const override;
158 
159  // Checkpointing
160  void serialize(CheckpointOut &cp) const override;
161  void unserialize(CheckpointIn &cp) override;
162 };
163 
164 } // namespace PowerISA
165 } // namespace gem5
166 
167 #endif // __ARCH_POWER_TLB_HH__
void flushAll() override
Remove all entries from the TLB.
void serialize(CheckpointOut &cp) const override
Serialize an object.
PowerISA::PTE * getEntry(unsigned) const
void insertAt(PowerISA::PTE &pte, unsigned Index, int _smallPages)
Definition: tlb.cc:154
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
PowerISA::PTE * table
Definition: tlb.hh:100
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) const override
Do post-translation physical address finalization.
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:138
PowerISA::PTE * lookup(Addr vpn, uint8_t asn) const
Definition: tlb.cc:73
static bool validVirtualAddress(Addr vaddr)
Fault translateInst(const RequestPtr &req, ThreadContext *tc)
Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
PowerISA::PTE & index(bool advance=true)
PageTable lookupTable
Definition: tlb.hh:98
PowerTLBParams Params
Definition: tlb.hh:115
void insert(Addr vaddr, PowerISA::PTE &pte)
int getsize() const
Definition: tlb.hh:127
void nextnlu()
Definition: tlb.hh:105
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:119
void translateTiming(const RequestPtr &req, ThreadContext *tc, BaseMMU::Translation *translation, BaseMMU::Mode mode) override
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
int probeEntry(Addr vpn, uint8_t) const
static Fault checkCacheability(const RequestPtr &req)
Definition: tlb.cc:139
std::multimap< Addr, int > PageTable
Definition: tlb.hh:97
TLB(const Params &p)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
#define warn(...)
Definition: logging.hh:246
Bitfield< 4, 0 > mode
Definition: misc_types.hh:74
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:575
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:568
Declaration of Statistics objects.
void unserialize(CheckpointIn &cp)
Definition: tlb.hh:88
TlbEntry(Addr asn, Addr vaddr, Addr paddr, bool uncacheable, bool read_only)
Definition: tlb.hh:60
void updateVaddr(Addr new_vaddr)
Definition: tlb.hh:70
void serialize(CheckpointOut &cp) const
Definition: tlb.hh:82

Generated on Wed Dec 21 2022 10:22:15 for gem5 by doxygen 1.9.1