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) 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/misc.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 class TLB : public BaseTLB
48 {
49  // These faults need to be able to populate the tlb in SE mode.
51  friend class FastDataAccessMMUMiss;
52 
53  // TLB state
54  protected:
55  // Only used when this is the data TLB.
56  uint64_t sfar;
57  uint64_t c0_tsb_ps0;
58  uint64_t c0_tsb_ps1;
59  uint64_t c0_config;
60  uint64_t cx_tsb_ps0;
61  uint64_t cx_tsb_ps1;
62  uint64_t cx_config;
63  uint64_t sfsr;
64  uint64_t tag_access;
65 
66  protected:
68  typedef TlbMap::iterator MapIter;
69 
71 
72  int size;
75 
76  uint64_t cacheState;
77  bool cacheValid;
78 
80 
81  enum FaultTypes {
84  SideEffect = 0x2,
85  AtomicToIo = 0x4,
86  IllegalAsi = 0x8,
87  LoadFromNfo = 0x10,
88  VaOutOfRange = 0x20,
90  };
91 
92  enum ContextType {
93  Primary = 0,
94  Secondary = 1,
95  Nucleus = 2
96  };
97 
98  enum TsbPageSize {
99  Ps0,
101  };
102  public:
114  TlbEntry *lookup(Addr va, int partition_id, bool real, int context_id = 0,
115  bool update_used = true);
116 
118  void flushAll() override;
119 
120  protected:
122  void insert(Addr vpn, int partition_id, int context_id, bool real,
123  const PageTableEntry& PTE, int entry = -1);
124 
126  uint64_t TagRead(int entry);
127 
129  void demapAll(int partition_id);
130 
132  void demapContext(int partition_id, int context_id);
133 
136  void demapPage(Addr va, int partition_id, bool real, int context_id);
137 
139  bool validVirtualAddress(Addr va, bool am);
140 
141  void writeSfsr(bool write, ContextType ct,
142  bool se, FaultTypes ft, int asi);
143 
144  void clearUsedBits();
145 
146 
147  void writeTagAccess(Addr va, int context);
148 
150  Fault translateData(RequestPtr req, ThreadContext *tc, bool write);
151 
152  public:
153  typedef SparcTLBParams Params;
154  TLB(const Params *p);
155 
156  void takeOverFrom(BaseTLB *otlb) override {}
157 
158  void
159  demapPage(Addr vaddr, uint64_t asn) override
160  {
161  panic("demapPage(Addr) is not implemented.\n");
162  }
163 
164  void dumpAll();
165 
168  Translation *translation, Mode mode);
176  void GetTsbPtr(ThreadContext *tc, Addr addr, int ctx, Addr *ptrs);
177 
178  // Checkpointing
179  void serialize(CheckpointOut &cp) const override;
180  void unserialize(CheckpointIn &cp) override;
181 
183  uint64_t TteRead(int entry);
184 
185  private:
186  void writeSfsr(Addr a, bool write, ContextType ct,
187  bool se, FaultTypes ft, int asi);
188 
189  uint64_t MakeTsbPtr(TsbPageSize ps, uint64_t tag_access, uint64_t c0_tsb,
190  uint64_t c0_config, uint64_t cX_tsb, uint64_t cX_config);
191 
192 
195 };
196 
197 }
198 
199 #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:286
uint64_t cx_config
Definition: tlb.hh:62
void writeSfsr(bool write, ContextType ct, bool se, FaultTypes ft, int asi)
Definition: tlb.cc:381
int usedEntries
Definition: tlb.hh:73
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Fault translateInst(RequestPtr req, ThreadContext *tc)
Definition: tlb.cc:417
#define panic(...)
Definition: misc.hh:153
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Bitfield< 3 > am
Definition: miscregs.hh:130
Bitfield< 8 > a
Definition: miscregs.hh:1377
ip6_addr_t addr
Definition: inet.hh:335
uint64_t c0_config
Definition: tlb.hh:59
void clearUsedBits()
Definition: tlb.cc:81
bool validVirtualAddress(Addr va, bool am)
Checks if the virtual address provided is a valid one.
Definition: tlb.cc:371
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:1330
Bitfield< 4, 0 > mode
Definition: miscregs.hh:1385
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:196
ASI cacheAsi[2]
Definition: tlb.hh:194
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Cycles doMmuRegRead(ThreadContext *tc, Packet *pkt)
Definition: tlb.cc:865
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:1387
Fault translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode)
Definition: tlb.cc:835
RangeMap::iterator iterator
Definition: tlb_map.hh:48
void dumpAll()
Definition: tlb.cc:240
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:156
Definition: tlb.hh:53
Cycles doMmuRegWrite(ThreadContext *tc, Packet *pkt)
Definition: tlb.cc:1050
std::list< TlbEntry * > freeList
Definition: tlb.hh:79
TlbMap::iterator MapIter
Definition: tlb.hh:67
uint64_t cx_tsb_ps0
Definition: tlb.hh:60
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:254
uint64_t cx_tsb_ps1
Definition: tlb.hh:61
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:327
TlbEntry * cacheEntry[2]
Definition: tlb.hh:193
Fault finalizePhysical(RequestPtr req, ThreadContext *tc, Mode mode) const
Definition: tlb.cc:859
TlbEntry * tlb
Definition: tlb.hh:70
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
TlbMap lookupTable
Definition: tlb.hh:67
Bitfield< 8 > va
Definition: miscregs.hh:1473
void writeTagAccess(Addr va, int context)
Definition: tlb.cc:398
Fault translateData(RequestPtr req, ThreadContext *tc, bool write)
Definition: tlb.cc:531
Mode
Definition: tlb.hh:61
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:95
SparcTLBParams Params
Definition: tlb.hh:153
void GetTsbPtr(ThreadContext *tc, Addr addr, int ctx, Addr *ptrs)
Definition: tlb.cc:1303
std::ostream CheckpointOut
Definition: serialize.hh:67
uint64_t tag_access
Definition: tlb.hh:64
uint64_t TagRead(int entry)
Given an entry id, read that tlb entries' tag.
Definition: tlb.cc:355
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:1357
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:159
uint64_t TteRead(int entry)
Give an entry id, read that tlb entries' tte.
Definition: tlb.cc:342
uint64_t c0_tsb_ps1
Definition: tlb.hh:58
int lastReplaced
Definition: tlb.hh:74
uint64_t sfsr
Definition: tlb.hh:63
TLB(const Params *p)
Definition: tlb.cc:53
bool cacheValid
Definition: tlb.hh:77
int size
Definition: tlb.hh:72
uint64_t c0_tsb_ps0
Definition: tlb.hh:57
uint64_t sfar
Definition: tlb.hh:56
Fault translateFunctional(RequestPtr req, ThreadContext *tc, Mode mode)
Stub function for compilation support with CheckerCPU.
Definition: tlb.cc:852
uint64_t cacheState
Definition: tlb.hh:76
void demapAll(int partition_id)
Remove all non-locked entries from the tlb that match partition id.
Definition: tlb.cc:308
Bitfield< 18, 16 > ps
Definition: miscregs.hh:1701
Bitfield< 0 > p
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
ASI
Definition: asi.hh:38
void translateTiming(RequestPtr req, ThreadContext *tc, Translation *translation, Mode mode)
Definition: tlb.cc:844

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