gem5  v19.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) 2006 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: Ali Saidi
29  */
30 
31 #ifndef __ARCH_SPARC_TLB_HH__
32 #define __ARCH_SPARC_TLB_HH__
33 
34 #include "arch/generic/tlb.hh"
35 #include "arch/sparc/asi.hh"
36 #include "arch/sparc/tlb_map.hh"
37 #include "base/logging.hh"
38 #include "mem/request.hh"
39 #include "params/SparcTLB.hh"
40 
41 class ThreadContext;
42 class Packet;
43 
44 namespace SparcISA
45 {
46 
47 const Addr StartVAddrHole = ULL(0x0000800000000000);
48 const Addr EndVAddrHole = ULL(0xFFFF7FFFFFFFFFFF);
49 const Addr VAddrAMask = ULL(0xFFFFFFFF);
50 const Addr PAddrImplMask = ULL(0x000000FFFFFFFFFF);
51 
52 class TLB : public BaseTLB
53 {
54  // These faults need to be able to populate the tlb in SE mode.
56  friend class FastDataAccessMMUMiss;
57 
58  // TLB state
59  protected:
60  // Only used when this is the data TLB.
61  uint64_t sfar;
62  uint64_t c0_tsb_ps0;
63  uint64_t c0_tsb_ps1;
64  uint64_t c0_config;
65  uint64_t cx_tsb_ps0;
66  uint64_t cx_tsb_ps1;
67  uint64_t cx_config;
68  uint64_t sfsr;
69  uint64_t tag_access;
70 
71  protected:
73  typedef TlbMap::iterator MapIter;
74 
76 
77  int size;
80 
81  uint64_t cacheState;
82  bool cacheValid;
83 
85 
86  enum FaultTypes {
89  SideEffect = 0x2,
90  AtomicToIo = 0x4,
91  IllegalAsi = 0x8,
92  LoadFromNfo = 0x10,
93  VaOutOfRange = 0x20,
95  };
96 
97  enum ContextType {
98  Primary = 0,
99  Secondary = 1,
101  };
102 
103  enum TsbPageSize {
106  };
107  public:
119  TlbEntry *lookup(Addr va, int partition_id, bool real, int context_id = 0,
120  bool update_used = true);
121 
123  void flushAll() override;
124 
125  protected:
127  void insert(Addr vpn, int partition_id, int context_id, bool real,
128  const PageTableEntry& PTE, int entry = -1);
129 
131  uint64_t TagRead(int entry);
132 
134  void demapAll(int partition_id);
135 
137  void demapContext(int partition_id, int context_id);
138 
141  void demapPage(Addr va, int partition_id, bool real, int context_id);
142 
144  bool validVirtualAddress(Addr va, bool am);
145 
146  void writeSfsr(bool write, ContextType ct,
147  bool se, FaultTypes ft, int asi);
148 
149  void clearUsedBits();
150 
151 
152  void writeTagAccess(Addr va, int context);
153 
154  Fault translateInst(const RequestPtr &req, ThreadContext *tc);
155  Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write);
156 
157  public:
158  typedef SparcTLBParams Params;
159  TLB(const Params *p);
160 
161  void takeOverFrom(BaseTLB *otlb) override {}
162 
163  void
164  demapPage(Addr vaddr, uint64_t asn) override
165  {
166  panic("demapPage(Addr) is not implemented.\n");
167  }
168 
169  void dumpAll();
170 
172  const RequestPtr &req, ThreadContext *tc, Mode mode) override;
173  void translateTiming(
174  const RequestPtr &req, ThreadContext *tc,
175  Translation *translation, Mode mode) override;
177  const RequestPtr &req,
178  ThreadContext *tc, Mode mode) const override;
181  void GetTsbPtr(ThreadContext *tc, Addr addr, int ctx, Addr *ptrs);
182 
183  // Checkpointing
184  void serialize(CheckpointOut &cp) const override;
185  void unserialize(CheckpointIn &cp) override;
186 
188  uint64_t TteRead(int entry);
189 
190  private:
191  void writeSfsr(Addr a, bool write, ContextType ct,
192  bool se, FaultTypes ft, int asi);
193 
194  uint64_t MakeTsbPtr(TsbPageSize ps, uint64_t tag_access, uint64_t c0_tsb,
195  uint64_t c0_config, uint64_t cX_tsb, uint64_t cX_config);
196 
197 
200 };
201 
202 }
203 
204 #endif // __ARCH_SPARC_TLB_HH__
void demapContext(int partition_id, int context_id)
Remove all entries that match a given context/partition id.
Definition: tlb.cc:288
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
uint64_t cx_config
Definition: tlb.hh:67
void writeSfsr(bool write, ContextType ct, bool se, FaultTypes ft, int asi)
Definition: tlb.cc:383
int usedEntries
Definition: tlb.hh:78
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
const Addr PAddrImplMask
Definition: tlb.hh:50
const Addr VAddrAMask
Definition: tlb.hh:49
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Bitfield< 3 > am
Definition: miscregs.hh:130
std::shared_ptr< Request > RequestPtr
Definition: request.hh:83
Bitfield< 8 > a
const Addr EndVAddrHole
Definition: tlb.hh:48
ip6_addr_t addr
Definition: inet.hh:335
Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write)
Definition: tlb.cc:533
uint64_t c0_config
Definition: tlb.hh:64
void clearUsedBits()
Definition: tlb.cc:83
bool validVirtualAddress(Addr va, bool am)
Checks if the virtual address provided is a valid one.
Definition: tlb.cc:373
uint64_t MakeTsbPtr(TsbPageSize ps, uint64_t tag_access, uint64_t c0_tsb, uint64_t c0_config, uint64_t cX_tsb, uint64_t cX_config)
Definition: tlb.cc:1327
Definition: cprintf.cc:42
Bitfield< 4, 0 > mode
TlbEntry * lookup(Addr va, int partition_id, bool real, int context_id=0, bool update_used=true)
lookup an entry in the TLB based on the partition id, and real bit if real is true or the partition i...
Definition: tlb.cc:198
ASI cacheAsi[2]
Definition: tlb.hh:199
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Definition: tlb.cc:837
Cycles doMmuRegRead(ThreadContext *tc, Packet *pkt)
Definition: tlb.cc:861
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:1384
RangeMap::iterator iterator
Definition: tlb_map.hh:48
void dumpAll()
Definition: tlb.cc:242
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:161
Definition: tlb.hh:52
Cycles doMmuRegWrite(ThreadContext *tc, Packet *pkt)
Definition: tlb.cc:1046
std::list< TlbEntry * > freeList
Definition: tlb.hh:84
TlbMap::iterator MapIter
Definition: tlb.hh:72
uint64_t cx_tsb_ps0
Definition: tlb.hh:65
void demapPage(Addr va, int partition_id, bool real, int context_id)
Remve all entries that match a certain partition id, (contextid), and va).
Definition: tlb.cc:256
const Addr StartVAddrHole
Definition: tlb.hh:47
uint64_t cx_tsb_ps1
Definition: tlb.hh:66
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:329
void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode) override
Definition: tlb.cc:846
TlbEntry * cacheEntry[2]
Definition: tlb.hh:198
TlbEntry * tlb
Definition: tlb.hh:75
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
#define ULL(N)
uint64_t constant
Definition: types.hh:50
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, Mode mode) const override
Do post-translation physical address finalization.
Definition: tlb.cc:854
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
TlbMap lookupTable
Definition: tlb.hh:72
Bitfield< 8 > va
void writeTagAccess(Addr va, int context)
Definition: tlb.cc:400
Mode
Definition: tlb.hh:59
void insert(Addr vpn, int partition_id, int context_id, bool real, const PageTableEntry &PTE, int entry=-1)
Insert a PTE into the TLB.
Definition: tlb.cc:97
SparcTLBParams Params
Definition: tlb.hh:158
void GetTsbPtr(ThreadContext *tc, Addr addr, int ctx, Addr *ptrs)
Definition: tlb.cc:1300
std::ostream CheckpointOut
Definition: serialize.hh:68
uint64_t tag_access
Definition: tlb.hh:69
Definition: asi.cc:34
uint64_t TagRead(int entry)
Given an entry id, read that tlb entries&#39; tag.
Definition: tlb.cc:357
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:1354
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:164
uint64_t TteRead(int entry)
Give an entry id, read that tlb entries&#39; tte.
Definition: tlb.cc:344
uint64_t c0_tsb_ps1
Definition: tlb.hh:63
int lastReplaced
Definition: tlb.hh:79
uint64_t sfsr
Definition: tlb.hh:68
TLB(const Params *p)
Definition: tlb.cc:55
bool cacheValid
Definition: tlb.hh:82
int size
Definition: tlb.hh:77
uint64_t c0_tsb_ps0
Definition: tlb.hh:62
uint64_t sfar
Definition: tlb.hh:61
uint64_t cacheState
Definition: tlb.hh:81
void demapAll(int partition_id)
Remove all non-locked entries from the tlb that match partition id.
Definition: tlb.cc:310
Bitfield< 18, 16 > ps
Bitfield< 0 > p
Fault translateInst(const RequestPtr &req, ThreadContext *tc)
Definition: tlb.cc:419
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
ASI
Definition: asi.hh:38

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13